BMLT Satellite Driver
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. *. More...
 
 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. *.
More...
 
 get_m_root_uri ()
 Accessor -Return the value of the Root URI. Perform "cleaning" if necessary. * *. More...
 
 get_m_error_message ()
 Accessor -Return the value of the class error message (if any). * *. More...
 
get_m_current_transaction ()
 Accessor -Return a reference to the class transaction "bucket." * *. More...
 
get_m_outgoing_parameters ()
 Accessor -Return the transaction stimulus array. * *. More...
 
 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. * *.
More...
 
 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. * *.
More...
 
 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. * *.
More...
 
 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. * *.
More...
 
 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. * *.
More...
 
 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. * *.
More...
 
 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. * *.
More...
 
 is_legal_transaction_key ( $in_parameter_key, $in_sub_key=null)
 See if a given parameter key is valid for an outgoing parameter. * *. More...
 
 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. * *.
More...
 
 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. * *. More...
 
 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. *.
More...
 
 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 * *. More...
 
 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. * *.
More...
 
 get_serialized_transaction ()
 Return the query parameter list for the next transaction in a serialized * string. * *. More...
 

Static Public Member Functions

static get_m_supported_protocols ()
 Accessor -Return the array of supported protocols. * *. More...
 
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. * *. More...
 

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 923 of file bmlt_satellite_controller.class.php.

924  {
925  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
926  $ret = null;
927 
928  $new_array = unserialize($in_serialized_list);
929  if (isset($new_array) && is_array($new_array) && count($new_array)) {
930  $ret = array();
931  $this->set_m_current_transaction(null); // Clear current transactions.
932  foreach ($new_array as $param_key => $param_value) {
933  if ($this->is_legal_transaction_key($param_key, $param_value)) {
934  $this->set_current_transaction_parameter($param_key, $param_value);
935  } else {
936  $ret[] = $param_key;
937  }
938  }
939  }
940 
941  return $ret;
942  }
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 1051 of file bmlt_satellite_controller.class.php.

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

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_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 690 of file bmlt_satellite_controller.class.php.

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

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 1017 of file bmlt_satellite_controller.class.php.

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

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  $info_file = new DOMDocument();
424  if ($data && $data !== '{}' && $data !== '[]') {
425  $ret = array();
426  $data = json_decode($data, true);
427  foreach ($data as $key => $value) {
428  $ret[$key] = $value;
429  $ret[$key]["json_data"] = json_encode($ret[$key]["json_data"]);
430  }
431  }
432  } elseif (!$this->get_m_error_message()) {
433  $this->set_m_error_message('get_meeting_changes: Invalid URI (' . $uri . ')');
434  }
435 
436  return $ret;
437  }
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 951 of file bmlt_satellite_controller.class.php.

952  {
953  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
954  return serialize($this->get_m_current_transaction());
955  }
& 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 451 of file bmlt_satellite_controller.class.php.

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

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

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 500 of file bmlt_satellite_controller.class.php.

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

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 599 of file bmlt_satellite_controller.class.php.

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

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

References get_m_outgoing_parameters().

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

◆ 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 860 of file bmlt_satellite_controller.class.php.

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

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 652 of file bmlt_satellite_controller.class.php.

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

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 723 of file bmlt_satellite_controller.class.php.

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

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: