BMLT Satellite Driver
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
bmlt_satellite_controller Class Reference

Provides low-level communication to the BMLT Root Server. More...

Public Member Functions

 __construct ($in_root_uri_string=null)
 Constructor -Set the value of the Root URI. * If a URI is passed in, then the object establishes and tests a connection, and * loads up the standard outgoing parameters. * This object requires that the server be of version 1.8.6 or greater. *.
 
 set_m_root_uri ( $in_root_uri_string, $in_skip_flush=false)
 Accessor -Set the value of the Root URI. *

  • NOTE: If the server URI changes, the parameters are flushed. *.

 
 get_m_root_uri ()
 Accessor -Return the value of the Root URI. Perform "cleaning" if necessary. * *.
 
 get_m_error_message ()
 Accessor -Return the value of the class error message (if any). * *.
 
get_m_current_transaction ()
 Accessor -Return a reference to the class transaction "bucket." * *.
 
get_m_outgoing_parameters ()
 Accessor -Return the transaction stimulus array. * *.
 
 get_server_version ($in_force_refresh=false)
 Test the stored URI to see if it points to a valid root server, and return * the server version. *

  • This will cache the response in the incoming parameter ('m_server_version'), and * will return the cached value, if possible. *
  • This will set or clear the internal $m_error_message data member. * *.

 
 get_server_langs ($in_force_refresh=false)
 Return the server supported languages. *

  • This will cache the response in the outgoing parameters ('langs'), and will return * the cached value, if possible. *
  • This will set or clear the internal $m_error_message data member. * *.

 
 get_meeting_changes ( $in_start_date=null, $in_end_date=null, $in_meeting_id=null, $in_service_body_id=null)
 Return meeting changes between two dates. *

  • This requires that the server be version 1.8.13 or greater. * This queries the server for meeting change records between (and including) the two * dates given. The dates are optional. However, not supplying them means that the * entire server change record is returned, which is quite a mouthful. You can specify * just one of the parameters (all the changes after a date to now, or all of the * changes since the server started until a certain date). *
  • There is no caching of this call. It is always real-time. *
  • The dates are given as PHP UNIX times (integer epoch times). *
  • This will set or clear the internal $m_error_message data member. * *.

 
 get_server_formats ($in_force_refresh=false)
 Return the server supported formats. *

  • This will cache the response in the outgoing parameters ('formats'), and will * return the cached value, if possible. *
  • This will set or clear the internal $m_error_message data member. * *.

 
 get_server_service_bodies ($in_force_refresh=false)
 Return the server's Service bodies, in hierarchical fashion. *

  • This will cache the response in the outgoing parameters ('services'), and will * return the cached value, if possible. *
  • This will set or clear the internal $m_error_message data member. * *.

 
 get_server_meeting_keys ($in_force_refresh=false)
 Return a list of the supported meeting_key values.. *

  • Each root server can define its own meeting data item keys, so we need to fetch the * ones defined by this server. We do this by parsing the dynamically-generated * schema document from the server. *
  • This will cache the response in the outgoing parameters ('meeting_keys'), and will * return the cached value, if possible. *
  • This will set or clear the internal $m_error_message data member. * *.

 
 get_transaction_key_values ($in_parameter_key)
 See if a given parameter key is valid for an outgoing parameter. *

  • This will set or clear the error message. * *.

 
 is_legal_transaction_key ( $in_parameter_key, $in_sub_key=null)
 See if a given parameter key is valid for an outgoing parameter. * *.
 
 set_current_transaction_parameter ( $in_parameter_key, $in_parameter_value=null)
 Add a transaction parameter to a transaction being built. *

  • This will set or clear the error message. * *.

 
 clear_m_error_message ()
 Clear the Error Message. *.
 
get_m_outgoing_parameter ( $in_parameter_key_string, $in_parameter_secondary_key_string=null)
 Return a value from the transaction stimuli array. * *.
 
 set_m_outgoing_parameter ( $in_parameter_key_string, $in_parameter_value_mixed)
 Set a parameter value to the transaction stimulus array. *

  • The outgoing array is "pre-keyed" with the possible parameters. You cannot change * the keys or access the values by reference. *
  • This will set or clear the internal $m_error_message data member. *.

 
 flush_parameters ()
 Flush all the parameters, and the dynamically-filled outgoing ones. *.
 
 load_standard_outgoing_parameters ()
 Read all the standard parameters from the server *

  • This will set or clear the internal $m_error_message data member. *.

 
 meeting_search ()
 Execute a meeting search transaction * *.
 
 apply_serialized_transaction ($in_serialized_list)
 Unserialize a serialized transaction. *

  • This allows you to save a transaction, and re-use it. The transaction is not * executed. You still need to call meeting_search(). However, this replaces the setup * steps (set_current_transaction_parameter). It clears the transaction parameters * before it starts, so you cannot rely on any previous data being in the transaction * array. You can add transaction data afterward. * *.

 
 get_serialized_transaction ()
 Return the query parameter list for the next transaction in a serialized * string. * *.
 

Static Public Member Functions

static get_m_supported_protocols ()
 Accessor -Return the array of supported protocols. * *.
 
static call_curl ( $in_uri, $in_post=false, &$error_message=null, &$http_status=null)
 This is a function that returns the results of an HTTP call to a URI. * It is a lot more secure than file_get_contents, but does the same thing. * *.
 

Detailed Description

Provides low-level communication to the BMLT Root Server.

Version
1.1.1

This file is part of the Basic Meeting List Toolbox (BMLT).

Find out more at: https://bmlt.app

BMLT is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

BMLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this code. If not, see http://www.gnu.org/licenses/.

This is the main class for the Satellite Controller. It establishes a liaison * with the root server. *

Definition at line 37 of file bmlt_satellite_controller.class.php.

Constructor & Destructor Documentation

◆ __construct()

bmlt_satellite_controller::__construct (   $in_root_uri_string = null)

Constructor -Set the value of the Root URI. * If a URI is passed in, then the object establishes and tests a connection, and * loads up the standard outgoing parameters. * This object requires that the server be of version 1.8.6 or greater. *.

Parameters
$in_root_uri_stringThe URI to the root server, can be null

Definition at line 81 of file bmlt_satellite_controller.class.php.

82 {
83 if ($in_root_uri_string) {
84 // Don't need to flush the params, as we'll be doing that next.
85 $this->set_m_root_uri($in_root_uri_string, true);
86 }
87
88 // Initialize the parameters.
89 $this->flush_parameters();
90
91 // OK, now we talk to the server, and fill up on the various server-specific things.
92 if ($in_root_uri_string) {
93 // The first thing we do, is get the server version. We must have version 1.8.6 or greater.
94 $version = $this->get_server_version();
95 if (!$this->get_m_error_message()) {
96 $version_int = intval(str_replace('.', '', $version));
97 if ($version_int > 185) {
98 if (!extension_loaded('curl')) { // Must have cURL. This puppy won't work without cURL.
99 $this->set_m_error_message('__construct: The cURL extension is not available! This code will not work on this server!');
100 } else {
102 }
103 } else {
104 $this->set_m_error_message('__construct: The root server at (' . $in_root_uri_string . ') is too old (it is version ' . $version . ')! It needs to be at least Version 1.8.6!');
105 }
106 }
107 }
108 }
get_server_version($in_force_refresh=false)
Test the stored URI to see if it points to a valid root server, and return * the server version....
set_m_root_uri( $in_root_uri_string, $in_skip_flush=false)
Accessor -Set the value of the Root URI. *NOTE: If the server URI changes, the parameters are flushed...
get_m_error_message()
Accessor -Return the value of the class error message (if any). * *.
load_standard_outgoing_parameters()
Read all the standard parameters from the server *This will set or clear the internal $m_error_messag...
flush_parameters()
Flush all the parameters, and the dynamically-filled outgoing ones. *.

References flush_parameters(), get_m_error_message(), get_server_version(), load_standard_outgoing_parameters(), and set_m_root_uri().

Member Function Documentation

◆ apply_serialized_transaction()

bmlt_satellite_controller::apply_serialized_transaction (   $in_serialized_list)

Unserialize a serialized transaction. *

  • This allows you to save a transaction, and re-use it. The transaction is not * executed. You still need to call meeting_search(). However, this replaces the setup * steps (set_current_transaction_parameter). It clears the transaction parameters * before it starts, so you cannot rely on any previous data being in the transaction * array. You can add transaction data afterward. * *.

Returns
An array of string. If any of the given parameters cannot be set, their * key is given here. It is not an error. Null if everything fit. *
Parameters
$in_serialized_listA string that holds the serialized transaction list.

Definition at line 922 of file bmlt_satellite_controller.class.php.

923 {
924 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
925 $ret = null;
926
927 $new_array = unserialize($in_serialized_list);
928 if (isset($new_array) && is_array($new_array) && count($new_array)) {
929 $ret = array();
930 $this->set_m_current_transaction(null); // Clear current transactions.
931 foreach ($new_array as $param_key => $param_value) {
932 if ($this->is_legal_transaction_key($param_key, $param_value)) {
933 $this->set_current_transaction_parameter($param_key, $param_value);
934 } else {
935 $ret[] = $param_key;
936 }
937 }
938 }
939
940 return $ret;
941 }
is_legal_transaction_key( $in_parameter_key, $in_sub_key=null)
See if a given parameter key is valid for an outgoing parameter. * *.
set_current_transaction_parameter( $in_parameter_key, $in_parameter_value=null)
Add a transaction parameter to a transaction being built. *This will set or clear the error message....

References is_legal_transaction_key(), and set_current_transaction_parameter().

◆ call_curl()

static bmlt_satellite_controller::call_curl (   $in_uri,
  $in_post = false,
$error_message = null,
$http_status = null 
)
static

This is a function that returns the results of an HTTP call to a URI. * It is a lot more secure than file_get_contents, but does the same thing. * *.

Returns
a string, containing the response. Null if the call fails to get any data. *
Parameters
$in_uriA string. The URI to call.
$in_postIf false, the transaction is a GET, not a POST. Default is true.
$error_messageA string. If provided, any error message will be placed here.
$http_statusOptional reference to a string. Returns the HTTP call status.

Definition at line 1050 of file bmlt_satellite_controller.class.php.

1055 {
1056 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1057 $ret = null;
1058
1059 // Make sure we don't give any false positives.
1060 if ($error_message) {
1061 $error_message = null;
1062 }
1063
1064 if (!extension_loaded('curl')) { // Must have cURL.
1065 // If there is no error message variable passed, we die quietly.
1066 if (isset($error_message)) {
1067 $error_message = 'call_curl: The cURL extension is not available! This code will not work on this server!';
1068 }
1069 } else {
1070 // This gets the session as a cookie.
1071 if (isset($_COOKIE['PHPSESSID']) && $_COOKIE['PHPSESSID']) {
1072 $strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';
1073
1074 session_write_close();
1075 }
1076
1077 // Create a new cURL resource.
1078 $resource = curl_init();
1079
1080 if (isset($strCookie) && $strCookie) {
1081 curl_setopt($resource, CURLOPT_COOKIE, $strCookie);
1082 }
1083
1084 // If we will be POSTing this transaction, we split up the URI.
1085 if ($in_post) {
1086 curl_setopt($resource, CURLOPT_POST, true);
1087
1088 $spli = explode("?", $in_uri, 2);
1089
1090 if (is_array($spli) && (1 < count($spli))) {
1091 $in_uri = $spli[0];
1092 $in_params = $spli[1];
1093 // Convert query string into an array using parse_str(). parse_str() will decode values along the way.
1094 parse_str($in_params, $temp);
1095
1096 // Now rebuild the query string using http_build_query(). It will re-encode values along the way.
1097 // It will also take original query string params that have no value and appends a "=" to them
1098 // thus giving them and empty value.
1099 $in_params = http_build_query($temp);
1100
1101 curl_setopt($resource, CURLOPT_POSTFIELDS, $in_params);
1102 }
1103 }
1104
1105 if (isset($strCookie) && $strCookie) {
1106 curl_setopt($resource, CURLOPT_COOKIE, $strCookie);
1107 }
1108
1109 // Set url to call.
1110 curl_setopt($resource, CURLOPT_URL, $in_uri);
1111
1112 // Make curl_exec() function (see below) return requested content as a string (unless call fails).
1113 curl_setopt($resource, CURLOPT_RETURNTRANSFER, true);
1114
1115 // By default, cURL prepends response headers to string returned from call to curl_exec().
1116 // You can control this with the below setting.
1117 // Setting it to false will remove headers from beginning of string.
1118 // If you WANT the headers, see the Yahoo documentation on how to parse with them from the string.
1119 curl_setopt($resource, CURLOPT_HEADER, false);
1120
1121 // Allow cURL to follow any 'location:' headers (redirection) sent by server (if needed set to true, else false- defaults to false anyway).
1122// Disabled, because some servers disable this for security reasons.
1123// curl_setopt ( $resource, CURLOPT_FOLLOWLOCATION, true );
1124
1125 // Set maximum times to allow redirection (use only if needed as per above setting. 3 is sort of arbitrary here).
1126 curl_setopt($resource, CURLOPT_MAXREDIRS, 3);
1127
1128 // Set connection timeout in seconds (very good idea).
1129 curl_setopt($resource, CURLOPT_CONNECTTIMEOUT, 10);
1130
1131 // Direct cURL to send request header to server allowing compressed content to be returned and decompressed automatically (use only if needed).
1132 curl_setopt($resource, CURLOPT_ENCODING, 'gzip,deflate');
1133
1134 // Pretend we're a browser, so that anti-cURL settings don't pooch us.
1135 curl_setopt($resource, CURLOPT_USERAGENT, "cURL Mozilla/5.0 (Windows NT 5.1; rv:21.0) Gecko/20130401 Firefox/21.0");
1136
1137 // Trust meeeee...
1138 curl_setopt($resource, CURLOPT_SSL_VERIFYPEER, false);
1139
1140 // Execute cURL call and return results in $content variable.
1141 $content = curl_exec($resource);
1142
1143 // Check if curl_exec() call failed (returns false on failure) and handle failure.
1144 if ($content === false) {
1145 // If there is no error message variable passed, we die quietly.
1146 if (isset($error_message)) {
1147 // Cram as much info into the error message as possible.
1148 $error_message = "call_curl: curl failure calling $in_uri, " . curl_error($resource) . "\n" . curl_errno($resource);
1149 }
1150 } else {
1151 // Do what you want with returned content (e.g. HTML, etc) here or AFTER curl_close() call below as it is stored in the $content variable.
1152
1153 // You MIGHT want to get the HTTP status code returned by server (e.g. 200, 400, 500).
1154 // If that is the case then this is how to do it.
1155 $http_status = curl_getinfo($resource, CURLINFO_HTTP_CODE);
1156 }
1157
1158 // Close cURL and free resource.
1159 curl_close($resource);
1160
1161 // Maybe echo $contents of $content variable here.
1162 if ($content !== false) {
1163 $ret = $content;
1164 }
1165 }
1166
1167 return $ret;
1168 }

Referenced by get_meeting_changes(), get_server_formats(), get_server_langs(), get_server_meeting_keys(), get_server_service_bodies(), get_server_version(), and meeting_search().

◆ clear_m_error_message()

bmlt_satellite_controller::clear_m_error_message ( )

Clear the Error Message. *.

Definition at line 677 of file bmlt_satellite_controller.class.php.

678 {
679 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
680 $this->m_error_message = null;
681 }

Referenced by flush_parameters(), and load_standard_outgoing_parameters().

◆ flush_parameters()

bmlt_satellite_controller::flush_parameters ( )

Flush all the parameters, and the dynamically-filled outgoing ones. *.

Definition at line 815 of file bmlt_satellite_controller.class.php.

816 {
817 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
818 $this->set_m_server_version(null);
819 $this->set_m_current_transaction(null);
820 $this->set_default_outgoing();
821 $this->clear_m_error_message();
822 }
clear_m_error_message()
Clear the Error Message. *.

References clear_m_error_message().

Referenced by __construct(), and set_m_root_uri().

◆ get_m_current_transaction()

& bmlt_satellite_controller::get_m_current_transaction ( )

Accessor -Return a reference to the class transaction "bucket." * *.

Returns
A reference to an array of mixed. *

Definition at line 233 of file bmlt_satellite_controller.class.php.

234 {
235 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
236 return $this->m_current_transaction;
237 }

Referenced by get_serialized_transaction(), and set_current_transaction_parameter().

◆ get_m_error_message()

bmlt_satellite_controller::get_m_error_message ( )

Accessor -Return the value of the class error message (if any). * *.

Returns
A string. *

Definition at line 211 of file bmlt_satellite_controller.class.php.

212 {
213 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
214 return $this->m_error_message;
215 }

Referenced by __construct(), get_meeting_changes(), get_server_formats(), get_server_langs(), get_server_meeting_keys(), get_server_service_bodies(), get_server_version(), load_standard_outgoing_parameters(), and meeting_search().

◆ get_m_outgoing_parameter()

& bmlt_satellite_controller::get_m_outgoing_parameter (   $in_parameter_key_string,
  $in_parameter_secondary_key_string = null 
)

Return a value from the transaction stimuli array. * *.

Returns
A reference to a mixed. This is the value in the array. *
Parameters
$in_parameter_key_stringA string. The parameter key
$in_parameter_secondary_key_stringIf the parameter has an embedded array, a key for that (optional)

Definition at line 689 of file bmlt_satellite_controller.class.php.

692 {
693 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
694 $ret = null;
695
696 if (!isset($this->m_outgoing_parameters[$in_parameter_key_string])) {
697 $this->set_m_error_message('get_m_outgoing_parameter: Invalid Key: "' . $in_parameter_key_string . '"');
698 } else {
699 if (isset($in_parameter_secondary_key_string)) {
700 if (!isset($this->m_outgoing_parameters[$in_parameter_key_string][$in_parameter_secondary_key_string])) {
701 $this->set_m_error_message('get_m_outgoing_parameter: Invalid Secondary Key: "' . $in_parameter_secondary_key_string . '"');
702 } else {
703 $ret =& $this->m_outgoing_parameters[$in_parameter_key_string][$in_parameter_secondary_key_string];
704 }
705 } else {
706 $ret =& $this->m_outgoing_parameters[$in_parameter_key_string];
707 }
708 }
709
710 return $ret;
711 }

Referenced by get_server_formats(), get_server_langs(), get_server_meeting_keys(), and get_server_service_bodies().

◆ get_m_outgoing_parameters()

& bmlt_satellite_controller::get_m_outgoing_parameters ( )

Accessor -Return the transaction stimulus array. * *.

Returns
A reference to an array of mixed. *

Definition at line 245 of file bmlt_satellite_controller.class.php.

246 {
247 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
248 return $this->m_outgoing_parameters;
249 }

Referenced by get_transaction_key_values(), and is_legal_transaction_key().

◆ get_m_root_uri()

bmlt_satellite_controller::get_m_root_uri ( )

Accessor -Return the value of the Root URI. Perform "cleaning" if necessary. * *.

Returns
A string. The root URI, with the protocol preamble. If none is given, * "http" is used. Also, there is no trailing slash. *

Definition at line 140 of file bmlt_satellite_controller.class.php.

141 {
142 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
143 $ret_string = $this->m_root_uri_string;
144 $protocols = self::get_m_supported_protocols();
145 $protocol = $protocols[0]; // Element zero has the default protocol.
146
147 // We check for a supported protocol, here. It must be HTTP or HTTPS.
148 $matches = array();
149 $uri = ''; // This will be the base URI to the main_server directory.
150 // See if we have a protocol preamble. Separate the URI into components.
151 if (preg_match('|^(.*?):\/\/(.*?)/?$|', $ret_string, $matches)) {
152 $protocol = strtolower($matches[1]);
153 // See if we are a supported protocol.
154 if (!in_array($protocol, $protocols)) {
155 $protocol = $protocols[0]; // The default protocol is in element zero.
156 }
157
158 $uri = $matches[2]; // This strips off any trailing slash.
159 } else {
160 // Strip off any trailing slash.
161 preg_match('|^(.*?)\/?$|', $ret_string, $matches);
162 $uri = $matches[1];
163 }
164
165 // At this point, we have a protocol, and a URI that has had its trailing slash removed.
166 // Reassemble them into a "cleaned" return string.
167
168 $ret_string = $protocol . '://' . $uri;
169
170 return $ret_string;
171 }
static get_m_supported_protocols()
Accessor -Return the array of supported protocols. * *.

References get_m_supported_protocols().

Referenced by get_meeting_changes(), get_server_formats(), get_server_langs(), get_server_meeting_keys(), get_server_service_bodies(), get_server_version(), and meeting_search().

◆ get_m_supported_protocols()

static bmlt_satellite_controller::get_m_supported_protocols ( )
static

Accessor -Return the array of supported protocols. * *.

Returns
An array of strings. *

Definition at line 1016 of file bmlt_satellite_controller.class.php.

1017 {
1018 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1019 return self::$m_supported_protocols;
1020 }

Referenced by get_m_root_uri().

◆ get_meeting_changes()

bmlt_satellite_controller::get_meeting_changes (   $in_start_date = null,
  $in_end_date = null,
  $in_meeting_id = null,
  $in_service_body_id = null 
)

Return meeting changes between two dates. *

  • This requires that the server be version 1.8.13 or greater. * This queries the server for meeting change records between (and including) the two * dates given. The dates are optional. However, not supplying them means that the * entire server change record is returned, which is quite a mouthful. You can specify * just one of the parameters (all the changes after a date to now, or all of the * changes since the server started until a certain date). *
  • There is no caching of this call. It is always real-time. *
  • The dates are given as PHP UNIX times (integer epoch times). *
  • This will set or clear the internal $m_error_message data member. * *.

Returns
An indexed array containing the change records as associative arrays. *
Parameters
$in_start_dateOptional. If given (a PHP time() format UNIX Epoch time), the changes will be loaded from midnight (00:00:00) of the date of the time.
$in_end_dateOptional. If given (a PHP time() format UNIX Epoch time), the changes will be loaded until midnight (23:59:59) of the date of the time.
$in_meeting_idIf supplied, an ID for a particular meeting. Only changes for that meeting will be returned.
$in_service_body_idIf supplied, an ID for a particular Service body. Only changes for meetings within that Service body will be returned.

Definition at line 381 of file bmlt_satellite_controller.class.php.

386 {
387 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
388 $ret = null;
389
390 $error_message = null; // We will collect any error messages.
391
392 // We start by clearing any internal error message.
393 $this->set_m_error_message($error_message);
394
395 $uri = $this->get_m_root_uri(); // Get the cleaned URI.
396
397 $uri .= '/client_interface/json/?switcher=GetChanges'; // We will load the JSON data.
398
399 if (intval($in_start_date)) {
400 $uri .= '&start_date=' . date('Y-m-d', intval($in_start_date));
401 }
402
403 if (intval($in_end_date)) {
404 $uri .= '&end_date=' . date('Y-m-d', intval($in_end_date));
405 }
406
407 if (intval($in_meeting_id)) {
408 $uri .= '&meeting_id=' . intval($in_meeting_id);
409 }
410
411 if (intval($in_service_body_id)) {
412 $uri .= '&service_body_id=' . intval($in_service_body_id);
413 }
414
415 // Get the JSON data from the remote server. We will use GET.
416 $data = self::call_curl($uri, false, $error_message);
417
418 // Save any internal error message from the transaction.
419 $this->set_m_error_message($error_message);
420
421 // If we get a valid response, we then parse the JSON.
422 if (!$this->get_m_error_message() && $data) {
423 if ($data && $data !== '{}' && $data !== '[]') {
424 $ret = array();
425 $data = json_decode($data, true);
426 foreach ($data as $key => $value) {
427 $ret[$key] = $value;
428 $ret[$key]["json_data"] = json_encode($ret[$key]["json_data"]);
429 }
430 }
431 } elseif (!$this->get_m_error_message()) {
432 $this->set_m_error_message('get_meeting_changes: Invalid URI (' . $uri . ')');
433 }
434
435 return $ret;
436 }
static call_curl( $in_uri, $in_post=false, &$error_message=null, &$http_status=null)
This is a function that returns the results of an HTTP call to a URI. * It is a lot more secure than ...
get_m_root_uri()
Accessor -Return the value of the Root URI. Perform "cleaning" if necessary. * *.

References call_curl(), get_m_error_message(), and get_m_root_uri().

◆ get_serialized_transaction()

bmlt_satellite_controller::get_serialized_transaction ( )

Return the query parameter list for the next transaction in a serialized * string. * *.

Returns
A string. The transaction parameter list in a serialized form. *

Definition at line 950 of file bmlt_satellite_controller.class.php.

951 {
952 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
953 return serialize($this->get_m_current_transaction());
954 }
& get_m_current_transaction()
Accessor -Return a reference to the class transaction "bucket." * *.

References get_m_current_transaction().

◆ get_server_formats()

bmlt_satellite_controller::get_server_formats (   $in_force_refresh = false)

Return the server supported formats. *

  • This will cache the response in the outgoing parameters ('formats'), and will * return the cached value, if possible. *
  • This will set or clear the internal $m_error_message data member. * *.

Returns
An associative array containing the formats as arrays. The array index is * that format's shared ID, for quick lookup. *
Parameters
$in_force_refreshIf this is true, then the server will be queried, even if there is a cache.

Definition at line 450 of file bmlt_satellite_controller.class.php.

451 {
452 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
453 $ret = null;
454
455 $error_message = null; // We will collect any error messages.
456
457 // We start by clearing any internal error message.
458 $this->set_m_error_message($error_message);
459
460 if ($in_force_refresh || !is_array($this->get_m_outgoing_parameter('formats')) || !count($this->get_m_outgoing_parameter('formats'))) {
461 $uri = $this->get_m_root_uri(); // Get the cleaned URI.
462
463 $uri .= '/client_interface/json/?switcher=GetFormats'; // We will load the JSON.
464
465 // Get the JSON data from the remote server. We will use GET.
466 $data = self::call_curl($uri, false, $error_message);
467
468 // Save any internal error message from the transaction.
469 $this->set_m_error_message($error_message);
470
471 // If we get a valid response, we then parse the JSON.
472 if (!$this->get_m_error_message() && $data) {
473 $ret = array();
474 $data = json_decode($data, true);
475 foreach ($data as $format) {
476 $ret[$format['id']] = $format;
477 }
478 } elseif (!$this->get_m_error_message()) {
479 $this->set_m_error_message('get_server_formats: Invalid URI (' . $uri . ')');
480 }
481 } else {
482 $ret = $this->get_m_outgoing_parameter('formats');
483 }
484
485 return $ret;
486 }
& get_m_outgoing_parameter( $in_parameter_key_string, $in_parameter_secondary_key_string=null)
Return a value from the transaction stimuli array. * *.

References call_curl(), get_m_error_message(), get_m_outgoing_parameter(), and get_m_root_uri().

Referenced by load_standard_outgoing_parameters().

◆ get_server_langs()

bmlt_satellite_controller::get_server_langs (   $in_force_refresh = false)

Return the server supported languages. *

  • This will cache the response in the outgoing parameters ('langs'), and will return * the cached value, if possible. *
  • This will set or clear the internal $m_error_message data member. * *.

Returns
An associative array, containing the server languages (the key will * indicate the language key, and the value will be an array with the readable * name of the language, and a "default" if this is the server's "native" language). *
Parameters
$in_force_refreshIf this is true, then the server will be queried, even if there is a cache.

Definition at line 317 of file bmlt_satellite_controller.class.php.

318 {
319 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
320 $ret = null;
321
322 $error_message = null; // We will collect any error messages.
323
324 // We start by clearing any internal error message.
325 $this->set_m_error_message($error_message);
326
327 if ($in_force_refresh || !is_array($this->get_m_outgoing_parameter('langs')) || !count($this->get_m_outgoing_parameter('langs'))) {
328 $uri = $this->get_m_root_uri(); // Get the cleaned URI.
329
330 $uri .= '/client_interface/json/?switcher=GetServerInfo'; // We will load the JSON.
331
332 // Get the JSON data from the remote server. We will use GET.
333 $data = self::call_curl($uri, false, $error_message);
334
335 // Save any internal error message from the transaction.
336 $this->set_m_error_message($error_message);
337
338 // If we get a valid response, we then parse the JSON.
339 if (!$this->get_m_error_message() && $data) {
340 $ret = array();
341
342 $data = json_decode($data, true);
343 $langs = explode(",", $data[0]["langs"]);
344 $default_lang = $data[0]["nativeLang"];
345 foreach ($langs as $lang) {
346 $ret[$lang]['name'] = $lang;
347 $ret[$lang]['default'] = $lang === $default_lang ? true : false;
348 }
349 $this->set_m_outgoing_parameter('langs', $ret);
350 }
351
352 if (!$ret && !$this->get_m_error_message()) {
353 $this->set_m_error_message('get_server_langs: Invalid URI (' . $uri . ')');
354 }
355 } else {
356 $ret = $this->get_m_outgoing_parameter('langs');
357 }
358
359 return $ret;
360 }
set_m_outgoing_parameter( $in_parameter_key_string, $in_parameter_value_mixed)
Set a parameter value to the transaction stimulus array. *The outgoing array is "pre-keyed" with the ...

References call_curl(), get_m_error_message(), get_m_outgoing_parameter(), get_m_root_uri(), and set_m_outgoing_parameter().

Referenced by load_standard_outgoing_parameters().

◆ get_server_meeting_keys()

bmlt_satellite_controller::get_server_meeting_keys (   $in_force_refresh = false)

Return a list of the supported meeting_key values.. *

  • Each root server can define its own meeting data item keys, so we need to fetch the * ones defined by this server. We do this by parsing the dynamically-generated * schema document from the server. *
  • This will cache the response in the outgoing parameters ('meeting_keys'), and will * return the cached value, if possible. *
  • This will set or clear the internal $m_error_message data member. * *.

Returns
An array of strings, containing the server meeting_key values. *
Parameters
$in_force_refreshIf this is true, then the server will be queried, even if there is a cache.

Definition at line 552 of file bmlt_satellite_controller.class.php.

553 {
554 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
555 $ret = null;
556
557 $error_message = null; // We will collect any error messages.
558
559 // We start by clearing any internal error message.
560 $this->set_m_error_message($error_message);
561
562 if ($in_force_refresh || !is_array($this->get_m_outgoing_parameter('meeting_key')) || !count($this->get_m_outgoing_parameter('meeting_key'))) {
563 $uri = $this->get_m_root_uri(); // Get the cleaned URI.
564
565 $uri .= '/client_interface/json/?switcher=GetFieldKeys'; // We will load the JSON.
566
567 // Get the JSON data from the remote server. We will use GET.
568 $data = self::call_curl($uri, false, $error_message);
569 // Save any internal error message from the transaction.
570 $this->set_m_error_message($error_message);
571
572 // If we get a valid response, we then parse the JSON.
573 if (!$this->get_m_error_message() && $data) {
574 $data = json_decode($data, true);
575 foreach ($data as $field_key) {
576 $ret[] = $field_key["key"];
577 }
578 } elseif (!$this->get_m_error_message()) {
579 $this->set_m_error_message('get_server_meeting_keys: Invalid URI (' . $uri . ')');
580 }
581 } else {
582 $ret = $this->get_m_outgoing_parameter('meeting_key');
583 }
584
585 return $ret;
586 }

References call_curl(), get_m_error_message(), get_m_outgoing_parameter(), and get_m_root_uri().

Referenced by load_standard_outgoing_parameters().

◆ get_server_service_bodies()

bmlt_satellite_controller::get_server_service_bodies (   $in_force_refresh = false)

Return the server's Service bodies, in hierarchical fashion. *

  • This will cache the response in the outgoing parameters ('services'), and will * return the cached value, if possible. *
  • This will set or clear the internal $m_error_message data member. * *.

Returns
An associative array, containing the server Service bodies
Parameters
$in_force_refreshIf this is true, then the server will be queried, even if there is a cache.

Definition at line 499 of file bmlt_satellite_controller.class.php.

500 {
501 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
502 $ret = null;
503
504 $error_message = null; // We will collect any error messages.
505
506 // We start by clearing any internal error message.
507 $this->set_m_error_message($error_message);
508
509 if ($in_force_refresh || !is_array($this->get_m_outgoing_parameter('services')) || !count($this->get_m_outgoing_parameter('services'))) {
510 $uri = $this->get_m_root_uri(); // Get the cleaned URI.
511
512 $uri .= '/client_interface/json/?switcher=GetServiceBodies'; // We will load the JSON.
513
514 // Get the JSON data from the remote server. We will use GET.
515 $data = self::call_curl($uri, false, $error_message);
516
517 // Save any internal error message from the transaction.
518 $this->set_m_error_message($error_message);
519
520 // If we get a valid response, we then parse the JSON.
521 if (!$this->get_m_error_message() && $data) {
522 $ret = array();
523 $data = json_decode($data, true);
524 foreach ($data as $serviceBody) {
525 $ret[$serviceBody['id']] = $serviceBody;
526 }
527 } elseif (!$this->get_m_error_message()) {
528 $this->set_m_error_message('get_server_service_bodies: Invalid URI (' . $uri . ')');
529 }
530 } else {
531 $ret = $this->get_m_outgoing_parameter('services');
532 }
533
534 return $ret;
535 }

References call_curl(), get_m_error_message(), get_m_outgoing_parameter(), and get_m_root_uri().

Referenced by load_standard_outgoing_parameters().

◆ get_server_version()

bmlt_satellite_controller::get_server_version (   $in_force_refresh = false)

Test the stored URI to see if it points to a valid root server, and return * the server version. *

  • This will cache the response in the incoming parameter ('m_server_version'), and * will return the cached value, if possible. *
  • This will set or clear the internal $m_error_message data member. * *.

Returns
A string, containing the server version. Null if the test fails. *
Parameters
$in_force_refreshIf this is true, then the server will be queried, even if there is a cache.

Definition at line 266 of file bmlt_satellite_controller.class.php.

267 {
268 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
269 $ret = null;
270
271 $error_message = null; // We will collect any error messages.
272
273 // We start by clearing any internal error message.
274 $this->set_m_error_message($error_message);
275
276 if ($in_force_refresh || !$this->get_m_server_version()) {
277 $uri = $this->get_m_root_uri(); // Get the cleaned URI.
278
279 $uri .= '/client_interface/json/?switcher=GetServerInfo'; // We will load the JSON.
280
281 // Get the JSON data from the remote server. We will use GET.
282 $data = self::call_curl($uri, false, $error_message);
283
284 // Save any internal error message from the transaction.
285 $this->set_m_error_message($error_message);
286
287 // If we get a valid response, we then parse the JSON.
288 if (!$this->get_m_error_message() && $data) {
289 $info = json_decode($data, true);
290 $ret = $info[0]["version"];
291 $this->set_m_server_version($ret);
292 }
293
294 if (!$ret && !$this->get_m_error_message()) {
295 $this->set_m_error_message('get_server_version: Invalid URI (' . $uri . ')');
296 }
297 } else {
298 $ret = $this->get_m_server_version();
299 }
300
301 return $ret;
302 }

References call_curl(), get_m_error_message(), and get_m_root_uri().

Referenced by __construct().

◆ get_transaction_key_values()

bmlt_satellite_controller::get_transaction_key_values (   $in_parameter_key)

See if a given parameter key is valid for an outgoing parameter. *

  • This will set or clear the error message. * *.

Returns
An array, or null. If an array, it will be an array of possible values. * Null is not an error. It simply means that this transaction key does not have a set * of preset values. *
Parameters
$in_parameter_keyA string. The key for this parameter..

Definition at line 598 of file bmlt_satellite_controller.class.php.

599 {
600 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
601 $ret = null;
602
603 $this->set_m_error_message(null); // Clear the error message.
604
605 if ($this->is_legal_transaction_key($in_parameter_key)) {
606 // We start by getting a reference to the outgoing parameters array.
607 $outgoing_parameters =& $this->get_m_outgoing_parameters();
608
609 // We only respond with keys if the parameter value is a non-empty array.
610 if (is_array($outgoing_parameters[$in_parameter_key]) && count($outgoing_parameters[$in_parameter_key])) {
611 $ret = $outgoing_parameters[$in_parameter_key];
612 }
613 } else {
614 $this->set_m_error_message('get_transaction_key_values: Invalid Parameter Key: "' . $in_parameter_key . '"');
615 }
616
617 return $ret;
618 }
& get_m_outgoing_parameters()
Accessor -Return the transaction stimulus array. * *.

References get_m_outgoing_parameters(), and is_legal_transaction_key().

◆ is_legal_transaction_key()

bmlt_satellite_controller::is_legal_transaction_key (   $in_parameter_key,
  $in_sub_key = null 
)

See if a given parameter key is valid for an outgoing parameter. * *.

Returns
A Boolean. True if it is legal, false, otherwise. *
Parameters
$in_parameter_keyA string. The key for this parameter.
$in_sub_keyOptional. If this is a meeting_key value, see if it is legal. Ignored, otherwise.

Definition at line 626 of file bmlt_satellite_controller.class.php.

629 {
630 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
631 // We start by getting a reference to the outgoing parameters array.
632 $legal_entities =& $this->get_m_outgoing_parameters();
633
634 $ret = array_key_exists($in_parameter_key, $legal_entities);
635
636 if (($in_parameter_key == 'meeting_key') && isset($in_sub_key)) {
637 $ret = $ret && array_key_exists($in_sub_key, $legal_entities[$in_parameter_key]);
638 }
639
640 return $ret;
641 }

References get_m_outgoing_parameters().

Referenced by apply_serialized_transaction(), get_transaction_key_values(), and set_current_transaction_parameter().

◆ load_standard_outgoing_parameters()

bmlt_satellite_controller::load_standard_outgoing_parameters ( )

Read all the standard parameters from the server *

  • This will set or clear the internal $m_error_message data member. *.

Definition at line 830 of file bmlt_satellite_controller.class.php.

831 {
832 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
833 // We start off with a clean slate.
834 $this->clear_m_error_message();
835 $this->set_m_outgoing_parameter('meeting_key', array());
836 $this->set_m_outgoing_parameter('services', array());
837 $this->set_m_outgoing_parameter('formats', array());
838 $this->set_m_outgoing_parameter('langs', array());
839 // Now, we get the values from the server.
840 $this->get_server_formats();
841 if (!$this->get_m_error_message()) {
842 $this->get_server_langs();
843 if (!$this->get_m_error_message()) {
845 if (!$this->get_m_error_message()) {
847 }
848 }
849 }
850 }
get_server_service_bodies($in_force_refresh=false)
Return the server's Service bodies, in hierarchical fashion. *This will cache the response in the out...
get_server_meeting_keys($in_force_refresh=false)
Return a list of the supported meeting_key values.. *Each root server can define its own meeting data...
get_server_formats($in_force_refresh=false)
Return the server supported formats. *This will cache the response in the outgoing parameters ('forma...
get_server_langs($in_force_refresh=false)
Return the server supported languages. *This will cache the response in the outgoing parameters ('lan...

References clear_m_error_message(), get_m_error_message(), get_server_formats(), get_server_langs(), get_server_meeting_keys(), get_server_service_bodies(), and set_m_outgoing_parameter().

Referenced by __construct().

◆ meeting_search()

bmlt_satellite_controller::meeting_search ( )

Execute a meeting search transaction * *.

Returns
An array of meeting data (mixed). Each element of the array will, itself, * be an array, and will contain the meeting data. Null if no meetings were found. *

Definition at line 859 of file bmlt_satellite_controller.class.php.

860 {
861 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
862 $ret = null;
863
864 $error_message = null; // We will collect any error messages.
865
866 // We start by clearing any internal error message.
867 $this->set_m_error_message($error_message);
868
869 $uri = $this->get_m_root_uri(); // Get the cleaned URI.
870
871 // For meeting searches, we ask for the response to be compressed, as it can be verbose.
872 $uri .= '/client_interface/json/?switcher=GetSearchResults'; // We will load the JSON.
873
874 $serialized_list = null;
875
876 if ($transaction_params = $this->build_transaction_parameter_list($serialized_list)) {
877 $uri .= $transaction_params;
878 }
879 // Get the JSON data from the remote server. We will use GET.
880 $data = self::call_curl($uri, false, $error_message);
881
882 $ret['uri'] = $uri;
883 $ret['serialized'] = $serialized_list;
884
885 // Save any internal error message from the transaction.
886 $this->set_m_error_message($error_message);
887
888 if (!$this->get_m_error_message() && $data) {
889 // We now have a whole bunch of meetings. Time to process the response, and turn it into usable data.
890
891 if ($data && $data !== '{}' && $data !== '[]') {
892 $data = json_decode($data, true);
893 foreach ($data as $meeting) {
894 $item = self::extract_meeting_data($meeting);
895 // Needs to be a valid meeting.
896 if ($item) {
897 // We save each meeting in an element with its ID as the key.
898 $ret['meetings'][] = $item;
899 }
900 }
901 }
902 } elseif (!$this->get_m_error_message()) {
903 $this->set_m_error_message('meeting_search: Invalid URI (' . $uri . ')');
904 }
905
906 return $ret;
907 }

References call_curl(), get_m_error_message(), and get_m_root_uri().

◆ set_current_transaction_parameter()

bmlt_satellite_controller::set_current_transaction_parameter (   $in_parameter_key,
  $in_parameter_value = null 
)

Add a transaction parameter to a transaction being built. *

  • This will set or clear the error message. * *.

Returns
A Boolean. True if it is OK, false, otherwise. *
Parameters
$in_parameter_keyA string. The key for this parameter. If there is one already set, this will overwrite that.
$in_parameter_valueMixed. It can be any value. If an array, then the value will be presented as multiple values.

Definition at line 651 of file bmlt_satellite_controller.class.php.

654 {
655 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
656 $ret = false;
657
658 $this->set_m_error_message(null); // Clear the error message.
659
660 if ($this->is_legal_transaction_key($in_parameter_key, $in_parameter_value)) {
661 // We start by getting a reference to our transaction array.
662 $transaction_array =& $this->get_m_current_transaction();
663
664 $transaction_array[$in_parameter_key] = $in_parameter_value;
665 $ret = true;
666 } else {
667 $this->set_m_error_message('set_current_transaction_parameter: Invalid Parameter Key: "' . $in_parameter_key . '"');
668 }
669
670 return $ret;
671 }

References get_m_current_transaction(), and is_legal_transaction_key().

Referenced by apply_serialized_transaction().

◆ set_m_outgoing_parameter()

bmlt_satellite_controller::set_m_outgoing_parameter (   $in_parameter_key_string,
  $in_parameter_value_mixed 
)

Set a parameter value to the transaction stimulus array. *

  • The outgoing array is "pre-keyed" with the possible parameters. You cannot change * the keys or access the values by reference. *
  • This will set or clear the internal $m_error_message data member. *.

Parameters
$in_parameter_key_stringA string. The parameter key
$in_parameter_value_mixedA mixed value

Definition at line 722 of file bmlt_satellite_controller.class.php.

725 {
726 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
727 // We start by clearing any internal error message.
728 $this->set_m_error_message(null);
729
730 if (isset($this->m_outgoing_parameters[$in_parameter_key_string])) { // Null is not allowed.
731 if ($in_parameter_value_mixed === null) {
732 $in_parameter_value_mixed = '';
733 }
734 $this->m_outgoing_parameters[$in_parameter_key_string] = $in_parameter_value_mixed;
735 } else {
736 $this->set_m_error_message('set_m_outgoing_parameter: Invalid Key: "' . $in_parameter_key_string . '"');
737 }
738 }

Referenced by get_server_langs(), and load_standard_outgoing_parameters().

◆ set_m_root_uri()

bmlt_satellite_controller::set_m_root_uri (   $in_root_uri_string,
  $in_skip_flush = false 
)

Accessor -Set the value of the Root URI. *

  • NOTE: If the server URI changes, the parameters are flushed. *.

Parameters
$in_skip_flushOptional. If true, the parameters won't be flushed, even if they need to be.

Definition at line 120 of file bmlt_satellite_controller.class.php.

123 {
124 // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
125 // If we are selecting a new server, or changing servers, we flush all stored parameters.
126 if (!$in_skip_flush && strcmp($in_root_uri_string, $this->m_root_uri_string ?? '')) {
127 $this->flush_parameters();
128 }
129
130 $this->m_root_uri_string = $in_root_uri_string;
131 }

References flush_parameters().

Referenced by __construct().


The documentation for this class was generated from the following file: