BMLT Root Server
Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Private Member Functions | Private Attributes | List of all members
c_comdef_server Class Reference

This class is the main server class. It instantiates a PDO database object, and is the starting point for everything done and managed by the CoMDEF server system. More...

Public Member Functions

 __construct ($in_lang_enum=null)
 The initial setup call for the class. Part of setting up the server is establishing the database connection, and reading in all of the formats, which will be available in the GetFormatsObj() member function afterwards. More...
 
 Initialize ()
 This reads the Formats, Meeting and Service Entity IDs. More...
 
 GetLocalLang ()
 Returns the Server Local Language. More...
 
 ReadFormats ()
 This is an internal function that reads in all of the stored formats, in all provided languages, and instantiates local objects for them. Access them with the GetFormatsObj() member function afterwards. More...
 
 ReadUsers ()
 This is an internal function that reads in all of the stored users and instantiates local objects for them. Access them with the GetUsersObj() member function afterwards. More...
 
 ReadServiceBodies ()
 This is an internal function that reads in all of the stored service bodies and instantiates local objects for them. Access them with the GetServiceObj() member function afterwards. More...
 
 ReadServiceIDs ()
 This gathers the IDs of all the Service bodies that appear in meeting records. It is NOT a dump of the Service Bodies table. More...
 
 GetServiceBodyArray ()
 Simply returns a reference to the contained Service Body array. More...
 
 GetServiceBodyArrayHierarchical ()
 Returns the Service Body objects in a nested, hierarchical array, with "parents" containing "children.". More...
 
 GetNestedServiceBodyArray ($in_id=0)
 This reads the Service bodies in hierarchical order, and returns them in a multi-dimensional array that reflects the hierarchy. More...
 
 GetFormatsObj ()
 Simply returns a reference to the formats container. More...
 
 GetFormatsArray ()
 Simply returns an array of the format objects. More...
 
 GetUsedFormatsArray ()
 Simply returns an array of the format objects used by the meetings (no unused ones). More...
 
 GetUsedFormatIDs ()
 Return the shared IDs of the formats actually used by the contained meetings. This can be used to avoid showing format codes that are not relevant to the database. More...
 
 GetServiceIDs ()
 Simply returns the stored service IDs. More...
 
 GetAllServiceIDs ()
 Simply returns the stored service IDs for ALL Service Bodies. More...
 
 GetChangesFromSQL ($in_sql, $in_value_array=null)
 Given an SQL statement and a value array (for DBO prepared statements), return a new c_comdef_changes object, loaded with the instances of the changes that were returned from the query. More...
 

Static Public Member Functions

static MakeServer ()
 This is the factory for the server instantiation. It makes sure that only one instance exists. More...
 
static GetServer ()
 
static SetServer ($in_server_instance)
 Sets the server instance. More...
 
static ServerLangSortCallback ($in_lang_a, $in_lang_b)
 This is a callback to sort the server languages. The default server language will always be first, and the rest will be sorted alphabetically. More...
 
static DuplicateMeetingID ($in_meeting_id)
 This creates a new meeting that is an exact duplicate of the object for the meeting whose ID is passed in. The new meeting has a new ID, and is unpublished. More...
 
static DuplicateMeetingObj ($in_meeting_obj)
 This creates a new meeting that is an exact duplicate of the object passed in. The new meeting has a new ID, and is unpublished. More...
 
static AddNewMeeting ($in_service_body_bigint, $in_weekday_tinyint, $in_start_time_int, $in_lang_enum)
 Creates a new, relatively empty meeting in the database, with no data fields and minimal information. More...
 
static AddNewServiceBody ($in_name_string, $in_lang_enum, $in_principal_user_bigint, $in_description_string=null, $in_editors_string=null, $in_uri_string=null, $in_kml_uri_string=null, $in_worldid_mixed=null, $in_sb_type=null, $in_sb_owner=null)
 Creates a new Service Body in the Database. More...
 
static AddNewUser ($in_user_login, $in_user_unencrypted_password, $in_user_level, $in_user_email, $in_name_string=null, $in_description_string=null, $in_lang_enum=null, $in_owner_id=-1)
 Creates a new user in the Database. More...
 
static TrimChanges ($in_type, $in_id)
 trims the changes for the given item. More...
 
static AddNewChange ($in_user_id_bigint, $in_change_type, $in_service_body_id_bigint, $in_before_string, $in_after_string, $in_object_class_string, $in_before_obj_id_bigint, $in_after_obj_id_bigint, $in_before_obj_lang_enum=null, $in_after_obj_lang_enum=null, $in_name_string=null, $in_description_string=null, $in_lang_enum=null)
 Creates a new change record in the Database. More...
 
static GetNamespace ()
 Simply returns the namespace of this server. More...
 
static GetFormatTableName_obj ()
 Simply returns the name of the format table. More...
 
static GetMeetingTableName_obj ()
 Simply returns the name of the meetings table. More...
 
static GetChangesTableName_obj ()
 Simply returns the name of the changes table. More...
 
static GetServiceBodiesTableName_obj ()
 Simply returns the name of the service bodies table. More...
 
static GetUserTableName_obj ()
 Simply returns the name of the user table. More...
 
static GetDatabaseVersionTableName_obj ()
 
static GetServerLangs ()
 Get the local readable string for the server languages. More...
 
static GetFormatLangs ()
 
static GetServerUsersObj ()
 Get the object list for the server's registered users. More...
 
static GetUserByIDObj ($in_user_id_bigint)
 Get the object for a single user, given an ID. More...
 
static GetUserByLogin ($in_login)
 Given a login, looks up the user, and returns a reference to that user object. More...
 
static GetUserByLoginCredentials ($in_login, $in_password)
 Given a login and password, looks up the user, and returns a reference to that user object. More...
 
static GetCurrentUserObj ($in_is_ajax=false)
 Get the current logged-in user, as a c_comdef_user instance. More...
 
static IsUserServerAdmin ($in_user_obj=null, $in_is_ajax=false)
 Find out if the user is a server admin. More...
 
static IsUserServiceBodyAdmin ($in_user_obj=null, $in_is_ajax=false)
 Find out if the user is a service body admin. More...
 
static GetEncryptedPW ($in_login, $in_password)
 Given a login and password, looks up the user, and returns an encrypted password for that user. More...
 
static GetUsersByLevelObj ($in_user_level_bigint, $in_or_higher=false, $in_include_disabled=false)
 Get the objects for all users of a certain user level. More...
 
static GetServiceBodyByIDObj ($in_service_body_id_bigint)
 Get the object for a single service body, given an ID. More...
 
static GetServiceBodyHierarchyIDs ($in_service_body_id_bigint)
 Return the IDs of an entire Service body hierarchy. More...
 
static IsFormatKeyUnique ($in_key_string, $in_lang_enum)
 Given an ID and a language for a format, as well as a code, returns true if the code does NOT appear in the DB. More...
 
static GetOneFormat ($in_id_bigint, $in_lang_enum)
 Given an ID and a language for a format, it returns one instance. More...
 
static DoesMeetingExist ($in_id_bigint)
 Given an ID for a meeting, it returns true if the meeting currently exists. More...
 
static GetOneMeeting ($in_id_bigint, $test_only=false)
 Given an ID for a meeting, it returns one instance. More...
 
static GetOneChange ($in_id_bigint)
 Given an ID for a change, it returns one instance. More...
 
static GetOneUser ($in_id_bigint)
 Given an ID for a user, it returns one instance. More...
 
static GetMeetingsByID ($in_id_bigint_array)
 Get a series of meetings, each identified by an ID. This does not filter by any of the other major criteria. It is designed to facilitate direct access to meeting objects. More...
 
static GetMeetings ($in_service_body_id_bigint_array=null, $in_lang_filter_array=null, $in_weekday_tinyint_array=null, $in_formats=null, $in_start_after=null, $in_start_before=null, $in_end_before=null, $in_min_duration=null, $in_max_duration=null, $in_search_rect_array=null, $in_first=null, &$in_num=null, $in_published=0)
 Given a set of one or more main criteria, returns a new c_comdef_meetings object with instances of those meetings, loaded from the database. More...
 
static GetMeetingsForAServiceBody ($in_sb_id)
 Returns a c_comdef_meetings_object, containing all the meetings directly "owned" by the Service Body whose ID is submitted. More...
 
static GetAllMeetings (&$in_out_numResults, $in_numResults=null, $in_startIndex=null)
 Returns a c_comdef_meetings_object, containing all the meetings (Published and unpublished). More...
 
static GetCoverageArea ()
 Returns a set of two coordinates that define a rectangle that encloses all of the meetings. More...
 
static GetChangesFromIDAndType ($in_type, $in_id=null, $in_start_date=null, $in_end_date=null)
 Gets a list of all change objects of a certain type, or only one, if the change affects a certain class, and an ID is given for that class (not the change ID -the ID of the changed object). More...
 
static GetChangesFromOTypeAndCType ($in_o_type, $in_change_type)
 This function allows you to get a list of changes by object type, and change type (such as all deleted meetings, or all rolled-back formats). More...
 
static getKmPerLonAtLat ($dLatitude)
 Returns the number of Km per degree of longitude, adjusted for Latitude. More...
 
static GetSquareForRadius ($in_radius, $in_long_in_degrees, $in_lat_in_degrees)
 This is a static utility function that takes a specified radius and center point and calculates a square, in longitude and latitude points, that encompasses that radius. This greatly narrows the scope of the search, so the radius calculation will simply eliminate any meetings that are "in the corners.". More...
 
static MySQLGetRadiusSQLClause ($in_published=false, $in_weekday=null)
 Return SQL for a radius circle around the given coordinates. This is a special function for MySQL. More...
 
static HuntForRadius ($in_search_result_count, $in_long_in_degrees, $in_lat_in_degrees, $in_weekday_tinyint_array)
 Find the smallest radius that contains at least the given number of meetings. The way this works is that the center is set, and the optimal radius is selected in kilometers to deliver that many meetings. The radius starts at 25 Km (about 10 miles), and goes up or down in 5Km "clicks." Under 5Km, it reduces to 0.5Km "clicks." It will not go out more than 100Km. More...
 
static GetLocalStrings ($in_lang_enum=null)
 This gets the appropriate language files, and puts all the the strings into an associative array. If a language enum is passed in, and the language directory exists, then the strings are loaded from that directory. If nothing is passed in, the first place we look is in the HTTP query, to see if a 'lang_enum' query is present. If it is there, we use that. If not, we use the base server language. More...
 
static GetUserServiceBodies ($in_user_id=null)
 Return all the Service Bodies this user is authorized with. More...
 
static GetDatabaseVersion ()
 

Static Public Attributes

static $server_instance = null
 This is the SINGLETON server instance. There can only be one... More...
 
static $server_local_strings = null
 This contains a cache of the local strings. More...
 

Static Private Member Functions

static ParseMeetingsByFormats ($in_meetings, $in_formats)
 This is an alternative to the MySQL REGEXP test. It will go through all the meetings returned by a broad query, and remove any that do not contain all of the given formats. More...
 
static GetMeetingsFromSQL ($in_sql, $in_value_array=null)
 Given an SQL statement and a value array (for PDO prepared statements), return a new c_comdef_meetings object, loaded with the instances of the meetings that were returned from the query. More...
 

Private Attributes

 $_format_table_name = null
 This is the name of the Formats table in the database. More...
 
 $_meeting_table_name = null
 This is the name of the Meetings table in the database. More...
 
 $_changes_table_name = null
 This is the name of the Changes table in the database. More...
 
 $_user_table_name = null
 This is the name of the user table in the database. More...
 
 $_db_version_table_name = null
 This is the name of the database version table in the database. More...
 
 $_service_bodies_table_name = null
 This is the name of the Service Bodies table in the database. More...
 
 $_formats_obj = null
 This is the container for the loaded formats. More...
 
 $_used_format_ids = null
 This is the container for the loaded formats that are actually used in the meetings. Each element is a format shared ID. More...
 
 $_users_obj = null
 This is the container for the loaded users. More...
 
 $_service_ids = null
 This has the IDs of all the Service entities that "own" meetings on the server. More...
 
 $_server_lang_names = null
 This contains the names of the server languages, in their languages. It is an associative array, based on the language enums. More...
 
 $_format_lang_names = null
 This contains the names of additional languages for which formats are defined, in the main language of the server. It is an associative array, based on the language enums. More...
 
 $_server_namespace = null
 This contains the server namespace, which is used to uniquely identify data from this server. The default is the server URI, with "/CoMDEF" appended. More...
 
 $_service_obj_array = null
 This contains the actual Service Body objects as a simple array. More...
 

Detailed Description

This class is the main server class. It instantiates a PDO database object, and is the starting point for everything done and managed by the CoMDEF server system.

Definition at line 47 of file c_comdef_server.class.php.

Constructor & Destructor Documentation

__construct (   $in_lang_enum = null)

The initial setup call for the class. Part of setting up the server is establishing the database connection, and reading in all of the formats, which will be available in the GetFormatsObj() member function afterwards.

Parameters
$in_lang_enumIt is possible to force a different language via this parameter.

Definition at line 134 of file c_comdef_server.class.php.

References $comdef_global_language, $http_vars, and c_comdef_dbsingleton\init().

136  {
138 
139  try {
140  self::SetServer($this);
141  include(dirname(__FILE__)."/config/get-config.php");
142 
143  if (!isset($dbType)) {
144  $dbType = 'mysql';
145  }
146 
147  if (!isset($dbServer)) {
148  $dbServer = 'localhost';
149  }
150 
151  if (!isset($dbPrefix)) {
152  $dbPrefix = 'na';
153  }
154 
155  c_comdef_dbsingleton::init($dbType, $dbServer, $dbName, $dbUser, $dbPassword, 'utf8');
156 
157  // These are all the base names of the SQL tables.
158  $this->_format_table_name = $dbPrefix."_comdef_formats";
159  $this->_meeting_table_name = $dbPrefix."_comdef_meetings";
160  $this->_changes_table_name = $dbPrefix."_comdef_changes";
161  $this->_service_bodies_table_name = $dbPrefix."_comdef_service_bodies";
162  $this->_user_table_name = $dbPrefix."_comdef_users";
163  $this->_db_version_table_name = $dbPrefix."_comdef_db_version";
164 
165  if (isset($serverNamespace) && (null !== $serverNamespace)) {
166  $this->_server_namespace = $serverNamespace;
167  } else {
168  $this->_server_namespace = "http://".$_SERVER['SERVER_NAME']."/CoMDEF";
169  }
170 
171  // Brute-force protection against selecting a language that isn't supported by the resources at hand.
172  if (!file_exists(dirname(__FILE__)."/../local_server/server_admin/lang/".$comdef_global_language."/name.txt")) {
173  $comdef_global_language = "en";
174  }
175 
176  global $http_vars;
177 
178  if (isset($in_lang_enum) && $in_lang_enum) { // If a different language was specified, we force that into place now.
179  if (isset($http_vars) && is_array($http_vars)) {
180  $http_vars['lang_enum'] = $in_lang_enum;
181  }
182 
183  if (file_exists(dirname(__FILE__)."/../local_server/server_admin/lang/".$in_lang_enum."/name.txt")) {
184  $comdef_global_language = $in_lang_enum;
185  }
186  } elseif (isset($http_vars) && is_array($http_vars) && count($http_vars) && isset($http_vars['lang_enum'])) {
187  $lang_name = $http_vars['lang_enum'];
188 
189  if (file_exists(dirname(__FILE__)."/../local_server/server_admin/lang/".$lang_name."/name.txt")) {
190  $comdef_global_language = $lang_name;
191  }
192  } elseif (isset($_SESSION) && is_array($_SESSION) && isset($_SESSION['lang_enum'])) {
193  $lang_name = $_SESSION['lang_enum'];
194 
195  if (isset($http_vars) && is_array($http_vars)) {
196  $http_vars['lang_enum'] = $in_lang_enum;
197  }
198 
199  if (file_exists(dirname(__FILE__)."/../local_server/server_admin/lang/".$lang_name."/name.txt")) {
200  $comdef_global_language = $lang_name;
201  }
202  }
203 
204  if (isset($_SESSION) && is_array($_SESSION)) {
205  $_SESSION['lang_enum'] = $comdef_global_language;
206  }
207 
208  $this->_local_type_lang_enum = $comdef_global_language;
209 
210  $dh = opendir(dirname(__FILE__).'/../local_server/server_admin/lang/');
211  $server_lang_names = array();
212 
213  if ($dh) {
214  while (false !== ($enum = readdir($dh))) {
215  $file_path = dirname(dirname(__FILE__))."/local_server/server_admin/lang/$enum/name.txt";
216  if (file_exists($file_path)) {
217  $server_lang_names[$enum] = trim(file_get_contents($file_path));
218  }
219  }
220 
221  closedir($dh);
222  }
223 
224  uksort($server_lang_names, 'c_comdef_server::ServerLangSortCallback');
225 
226  $this->_server_lang_names = $server_lang_names;
227  if (isset($format_lang_names) && is_array($format_lang_names)) {
228  $this->_format_lang_names = $format_lang_names;
229  } else {
230  $this->_format_lang_names = [];
231  }
232  $this->Initialize();
233  } catch (Exception $err) {
234  throw ( $err );
235  }
236  }
global $comdef_global_language
The local server language enum (Will default to English)
global $http_vars
Definition: index.php:21
Initialize()
This reads the Formats, Meeting and Service Entity IDs.
static init($driver, $host, $database, $user=null, $password=null, $charset=null)
Initializes connection param class members.

Member Function Documentation

static AddNewChange (   $in_user_id_bigint,
  $in_change_type,
  $in_service_body_id_bigint,
  $in_before_string,
  $in_after_string,
  $in_object_class_string,
  $in_before_obj_id_bigint,
  $in_after_obj_id_bigint,
  $in_before_obj_lang_enum = null,
  $in_after_obj_lang_enum = null,
  $in_name_string = null,
  $in_description_string = null,
  $in_lang_enum = null 
)
static

Creates a new change record in the Database.

Returns
the ID of the user. Null is it failed.
Parameters
$in_user_id_bigintInteger. The ID of the user making the change.
$in_service_body_id_bigintInteger. The ID of the Service body for which the user was acting.
$in_before_stringSerialized object string. The "before" object, in serialized form.
$in_after_stringSerialized object string. The "after" object, in serialized form.
$in_object_class_stringThe class of the objects.
$in_before_obj_id_bigintInteger, The ID of the Before Object.
$in_after_obj_id_bigintInteger, The ID of the After Object.
$in_before_obj_lang_enumEnum, the language of the Before Object.
$in_after_obj_lang_enumEnum. The language of the After Object.
$in_name_stringThe change's Name (Optional)
$in_description_stringThe description of the change (Optional)
$in_lang_enumThe language for the change (Optional -If not supplied, the server default will be used)

Definition at line 965 of file c_comdef_server.class.php.

References $comdef_global_language.

Referenced by c_comdef_format\DeleteFromDB(), c_comdef_service_body\DeleteFromDB(), c_comdef_user\DeleteFromDB(), c_comdef_meeting\DeleteFromDB(), c_comdef_format\UpdateToDB(), c_comdef_user\UpdateToDB(), c_comdef_service_body\UpdateToDB(), and c_comdef_meeting\UpdateToDB().

985  {
986  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
987  $id = null;
988 
989  if (!$in_lang_enum) {
990  $in_lang_enum = self::GetServer()->GetLocalLang();
991  }
992 
993  if (!$in_lang_enum) {
995  $in_lang_enum = $comdef_global_language;
996  }
997 
998  // Should never happen.
999  if (!$in_lang_enum) {
1000  $in_lang_enum = "en";
1001  }
1002 
1003  $change_obj = new c_comdef_change(self::GetServer(), $in_change_type, $in_user_id_bigint, $in_service_body_id_bigint, $in_before_string, $in_after_string, $in_object_class_string, $in_before_obj_id_bigint, $in_after_obj_id_bigint, $in_before_obj_lang_enum, $in_after_obj_lang_enum, null, $in_name_string, $in_description_string, $in_lang_enum);
1004 
1005  if ($change_obj instanceof c_comdef_change) {
1006  try {
1007  $change_obj->UpdateToDB();
1008 
1009  $id = $change_obj->GetID();
1010  } catch (Exception $e) { // We just eat the exception and return null.
1011  $id = null;
1012  }
1013  }
1014 
1015  $cid = $in_before_obj_id_bigint;
1016  if (!$cid) {
1017  $cid = $in_after_obj_id_bigint;
1018  }
1019 
1020  self::TrimChanges($in_object_class_string, $cid);
1021 
1022  return $id;
1023  }
global $comdef_global_language
The local server language enum (Will default to English)
A Class for Change Record Objects.
static AddNewMeeting (   $in_service_body_bigint,
  $in_weekday_tinyint,
  $in_start_time_int,
  $in_lang_enum 
)
static

Creates a new, relatively empty meeting in the database, with no data fields and minimal information.

Returns
the ID of the meeting. Null is it failed.
Parameters
$in_service_body_bigintThe ID of the Service Body that "owns" this meeting.
$in_weekday_tinyintThe index of the weekday on which the meeting is held (0 = Sunday, 6 = Saturday).
$in_start_time_intThe time, in standard PHP Epoch time, at which the meeting starts.
$in_lang_enumThe language for the meeting.

Definition at line 764 of file c_comdef_server.class.php.

References $comdef_global_language.

Referenced by c_comdef_admin_xml_handler\process_meeting_modify().

769  {
770  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
771  $id = null;
772 
773  if (!$in_lang_enum) {
774  $in_lang_enum = self::GetServer()->GetLocalLang();
775  }
776 
777  if (!$in_lang_enum) {
779  $in_lang_enum = $comdef_global_language;
780  }
781 
782  // Should never happen.
783  if (!$in_lang_enum) {
784  $in_lang_enum = "en";
785  }
786 
787  $meeting_data = array ( 'service_body_bigint'=>intval($in_service_body_bigint), 'weekday_tinyint'=>intval($in_weekday_tinyint), 'start_time'=>intval($in_start_time_int), 'lang_enum'=>$in_lang_enum );
788 
789  $new_meeting = new c_comdef_meeting(self::GetServer(), $meeting_data);
790 
791  if ($new_meeting instanceof c_comdef_meeting) {
792  $my_localized_strings = self::GetServer()->GetLocalStrings();
793  $data =& $new_meeting->GetMeetingData();
794  $data['longitude'] = floatval($my_localized_strings['search_spec_map_center']['longitude']);
795  $data['latitude'] = floatval($my_localized_strings['search_spec_map_center']['latitude']);
796 
797  $new_meeting->UpdateToDB();
798  $id = $new_meeting->GetID();
799  }
800 
801  return $id;
802  }
A class to hold a single meeting object.
global $comdef_global_language
The local server language enum (Will default to English)
static AddNewServiceBody (   $in_name_string,
  $in_lang_enum,
  $in_principal_user_bigint,
  $in_description_string = null,
  $in_editors_string = null,
  $in_uri_string = null,
  $in_kml_uri_string = null,
  $in_worldid_mixed = null,
  $in_sb_type = null,
  $in_sb_owner = null 
)
static

Creates a new Service Body in the Database.

Returns
the ID of the Service Body. Null is it failed.
Parameters
$in_name_stringThe Service Body's Name
$in_lang_enumThe language for the Service Body
$in_principal_user_bigintThe ID of the principal Service Body Administrator
$in_description_stringThe description of the Service Body (Optional)
$in_editors_stringThe IDs of the editors, as a CSV string (Optional)
$in_uri_stringThe Service Body Web Site URI (Optional)
$in_kml_uri_stringThe URI of a KML file that contains the Service Boundaries of the Service Body (Optional)
$in_worldid_mixedThe World ID (if one is available) (Optional)
$in_sb_ownerAn integer. The ID of the Service Body that "owns" this Service Body.

Definition at line 810 of file c_comdef_server.class.php.

References $comdef_global_language.

829  {
830  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
831  $id = null;
832 
833  if (!$in_lang_enum) {
834  $in_lang_enum = self::GetServer()->GetLocalLang();
835  }
836 
837  if (!$in_lang_enum) {
839  $in_lang_enum = $comdef_global_language;
840  }
841 
842  // Should never happen.
843  if (!$in_lang_enum) {
844  $in_lang_enum = "en";
845  }
846 
847  $service_body = new c_comdef_service_body(self::GetServer(), null, $in_principal_user_bigint, $in_editors_string, $in_kml_uri_string, $in_uri_string, $in_name_string, $in_description_string, $in_lang_enum, $in_worldid_mixed, $in_sb_type, $in_sb_owner);
848 
849  if ($service_body instanceof c_comdef_service_body) {
850  try {
851  $service_body->UpdateToDB();
852  $id = $service_body->GetID();
853  $service_body = null;
854 
855  self::GetServer()->ReadServiceBodies();
856  } catch (Exception $e) { // We just eat the exception and return null.
857  $id = null;
858  }
859  }
860 
861  return $id;
862  }
A Class for Service Body Objects.
global $comdef_global_language
The local server language enum (Will default to English)
static AddNewUser (   $in_user_login,
  $in_user_unencrypted_password,
  $in_user_level,
  $in_user_email,
  $in_name_string = null,
  $in_description_string = null,
  $in_lang_enum = null,
  $in_owner_id = -1 
)
static

Creates a new user in the Database.

Returns
the ID of the user. Null is it failed.
Parameters
$in_user_loginThe login for this user
$in_user_unencrypted_passwordThe unencrypted password for this user
$in_user_levelThe level of this user
$in_user_emailThe email address for this user
$in_name_stringThe user's Name (Optional)
$in_description_stringThe description of the user (Optional)
$in_lang_enumThe language for the user (Optional -If not supplied, the server default will be used)
$in_owner_idThe id of the user that owns this user

Definition at line 870 of file c_comdef_server.class.php.

References $comdef_global_language, and FullCrypt().

879  {
880  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
881  $id = null;
882 
883  if (!$in_lang_enum) {
884  $in_lang_enum = self::GetServer()->GetLocalLang();
885  }
886 
887  if (!$in_lang_enum) {
889  $in_lang_enum = $comdef_global_language;
890  }
891 
892  // Should never happen.
893  if (!$in_lang_enum) {
894  $in_lang_enum = "en";
895  }
896 
897  $encrypted_password = FullCrypt(trim($in_user_unencrypted_password));
898 
899  $user_obj = new c_comdef_user(self::GetServer(), null, $in_user_level, $in_user_email, $in_user_login, $encrypted_password, $in_lang_enum, $in_name_string, $in_description_string, $in_owner_id);
900 
901  if ($user_obj instanceof c_comdef_user) {
902  try {
903  $user_obj->UpdateToDB();
904  $id = $user_obj->GetID();
905  $user_obj = null;
906 
907  self::GetServer()->ReadUsers();
908  } catch (Exception $e) { // We just eat the exception and return null.
909  $id = null;
910  }
911  }
912 
913  return $id;
914  }
This class handles BMLT users. One instance is created for each user on the server.
global $comdef_global_language
The local server language enum (Will default to English)
FullCrypt($in_string, $in_salt=null, &$crypt_method=null)
Encrypts a string, using the most effective encryption.
static DoesMeetingExist (   $in_id_bigint)
static

Given an ID for a meeting, it returns true if the meeting currently exists.

Returns
true if the meeting exists; false, otherwise.
Exceptions
anexception if the SQL query fails.
Parameters
$in_id_bigintThe ID of the meeting (An integer)

Definition at line 1458 of file c_comdef_server.class.php.

References $ret, and c_comdef_dbsingleton\preparedQuery().

1460  {
1461  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1462  $sql = "SELECT id_bigint FROM `".self::GetMeetingTableName_obj()."_main` WHERE ".self::GetMeetingTableName_obj()."_main.id_bigint=? LIMIT 1";
1463 
1464  $ret = false;
1465 
1466  $rows = c_comdef_dbsingleton::preparedQuery($sql, array ( $in_id_bigint ));
1467  if (is_array($rows) && count($rows)) {
1468  $ret = true;
1469  }
1470 
1471  return $ret;
1472  }
$ret
Definition: contact.php:226
static preparedQuery($sql, $params=array(), $fetchKeyPair=false)
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statement...
static DuplicateMeetingID (   $in_meeting_id)
static

This creates a new meeting that is an exact duplicate of the object for the meeting whose ID is passed in. The new meeting has a new ID, and is unpublished.

Returns
an integer, with the ID of the new meeting. 0 If it fails.
Parameters
$in_meeting_idThe ID of the meeting to be copied.

Definition at line 709 of file c_comdef_server.class.php.

References $ret.

711  {
712  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
713  $ret = 0;
714 
715  $meeting_to_copy = self::GetOneMeeting($in_meeting_id);
716 
717  if ($meeting_to_copy instanceof c_comdef_meeting) {
718  $copy = self::DuplicateMeetingObj($meeting_to_copy);
719 
720  if ($copy instanceof c_comdef_meeting) {
721  $ret = $copy->GetID();
722  }
723  }
724 
725  return $ret;
726  }
A class to hold a single meeting object.
$ret
Definition: contact.php:226
static DuplicateMeetingObj (   $in_meeting_obj)
static

This creates a new meeting that is an exact duplicate of the object passed in. The new meeting has a new ID, and is unpublished.

Returns
a reference to a c_comdef_meeting object, representing the new meeting. Null if it fails.
Parameters
$in_meeting_objA reference to the meeting object to be copied.

Definition at line 735 of file c_comdef_server.class.php.

737  {
738  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
739  $new_meeting = null;
740 
741  if ($in_meeting_obj instanceof c_comdef_meeting) {
742  $meeting_data = $in_meeting_obj->GetMeetingData();
743  $meeting_data['id_bigint'] = 0;
744  $meeting_data['published'] = 0;
745  $meeting_data['copy'] = $in_meeting_obj->GetID();
746 
747  $new_meeting = new c_comdef_meeting(self::GetServer(), $meeting_data);
748 
749  if ($new_meeting instanceof c_comdef_meeting) {
750  $new_meeting->UpdateToDB();
751  }
752  }
753 
754  return $new_meeting;
755  }
A class to hold a single meeting object.
static GetAllMeetings ( $in_out_numResults,
  $in_numResults = null,
  $in_startIndex = null 
)
static

Returns a c_comdef_meetings_object, containing all the meetings (Published and unpublished).

Returns
a new c_comdef_meetings object, containing the meetings. Null if it failed.
Exceptions
anexception if the SQL query fails.
Parameters
$in_out_numResultsThis must be supplied. It is a pass-by-reference that indicates how many meetings are being returned.
$in_numResultsThis is how many results we want in this call.
$in_startIndexThis is the 0-based starting index

Definition at line 2080 of file c_comdef_server.class.php.

References $ret.

2084  {
2085  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
2086  $in_out_numResults = 0;
2087 
2088  if (!isset($in_startIndex)) {
2089  $in_startIndex = 0;
2090  }
2091 
2092  if (isset($in_numResults)) {
2093  $in_numResults += $in_startIndex;
2094  } else {
2095  $in_startIndex = null;
2096  }
2097 
2098  $sql = "SELECT * FROM `".self::GetMeetingTableName_obj()."_main`";
2099 
2100  if ($in_startIndex || $in_numResults) {
2101  $sql .= ' LIMIT ';
2102 
2103  $sql .= $in_startIndex.', '.$in_numResults;
2104  }
2105 
2106  $ret = self::GetMeetingsFromSQL($sql);
2107 
2108  if ($ret instanceof c_comdef_meetings) {
2109  $in_out_numResults = $ret->GetNumMeetings();
2110  }
2111 
2112  return $ret;
2113  }
$ret
Definition: contact.php:226
A class to hold a collection of c_comdef_meeting objects.
GetAllServiceIDs ( )

Simply returns the stored service IDs for ALL Service Bodies.

Returns
a reference to the array containing all the Service entity IDs. Null if none. NOTE: These are ALL IDs that appear (even ones not used for meetings).

Definition at line 676 of file c_comdef_server.class.php.

References $ret.

677  {
678  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
679  $ret = null;
680 
681  $ar = $this->GetServiceBodyArray();
682 
683  if (is_array($ar) && count($ar)) {
684  foreach ($ar as &$sb) {
685  if ($sb instanceof c_comdef_service_body) {
686  $key = $sb->GetID();
687  $value = $key;
688  $name = trim($sb->GetLocalName());
689  if ($name) {
690  $key = $name;
691  }
692 
693  $ret[$key] = $value;
694  }
695  }
696  }
697 
698  return $ret;
699  }
A Class for Service Body Objects.
$ret
Definition: contact.php:226
GetServiceBodyArray()
Simply returns a reference to the contained Service Body array.
static GetChangesFromIDAndType (   $in_type,
  $in_id = null,
  $in_start_date = null,
  $in_end_date = null 
)
static

Gets a list of all change objects of a certain type, or only one, if the change affects a certain class, and an ID is given for that class (not the change ID -the ID of the changed object).

Returns
a new c_comdef_changes object, containing the changes. Null if it failed.
Exceptions
anexception if the SQL query fails.
Parameters
$in_idThe ID for the object. If not specified, all changes for the given type will be returned (WARNING: Could be a great many).
$in_start_dateIf you specify a start date (In PHP time() format), then only changes on, or after this date will be returned.
$in_end_dateIf you specify an end date (In PHP time() format), then only changes that occurred on, or before this date will be returned.

Definition at line 2270 of file c_comdef_server.class.php.

Referenced by c_comdef_admin_xml_handler\get_changes_as_csv(), c_comdef_admin_xml_handler\get_deleted_meetings_as_csv(), GetChanges(), c_comdef_admin_xml_handler\process_restore_deleted_meeting(), and c_comdef_admin_xml_handler\process_rollback_meeting().

2281  {
2282  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
2283  $sql = "SELECT * FROM `".self::GetChangesTableName_obj()."` WHERE";
2284 
2285  if (null != $in_id) {
2286  $in_id = intval($in_id);
2287  $sql .= " ((before_id_bigint=$in_id) OR (after_id_bigint=$in_id)) AND";
2288  }
2289 
2290  if (intval($in_start_date)) {
2291  $start_date = date('Y-m-d 00:00:00', intval($in_start_date));
2292  $sql .= " (change_date>='$start_date') AND";
2293  }
2294 
2295  if (intval($in_end_date)) {
2296  $end_date = date('Y-m-d 23:59:59', intval($in_end_date));
2297  $sql .= " (change_date<='$end_date') AND";
2298  }
2299 
2300  $sql .= " (object_class_string=?) ORDER BY change_date DESC";
2301 
2302  return self::GetServer()->GetChangesFromSQL($sql, array ( $in_type ));
2303  }
static GetChangesFromOTypeAndCType (   $in_o_type,
  $in_change_type 
)
static

This function allows you to get a list of changes by object type, and change type (such as all deleted meetings, or all rolled-back formats).

Returns
a new c_comdef_changes object, containing the changes. Null if it failed.
Exceptions
anexception if the SQL query fails.

Definition at line 2315 of file c_comdef_server.class.php.

2330  {
2331  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
2332  $sql = "SELECT * FROM `".self::GetChangesTableName_obj()."` WHERE (object_class_string=?) AND (change_type_enum=?) ORDER BY change_date DESC";
2333 
2334  return self::GetServer()->GetChangesFromSQL($sql, array ( $in_o_type, $in_change_type ));
2335  }
GetChangesFromSQL (   $in_sql,
  $in_value_array = null 
)

Given an SQL statement and a value array (for DBO prepared statements), return a new c_comdef_changes object, loaded with the instances of the changes that were returned from the query.

Returns
a new c_comdef_changes object, containing the changes. Null if it failed.
Exceptions
anexception if the SQL query fails.
Parameters
$in_sqlThe prepared statement SQL query
$in_value_arrayAn array of values for the prepared statement.

Definition at line 2568 of file c_comdef_server.class.php.

References c_comdef_dbsingleton\preparedQuery().

2571  {
2572  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
2573  $rows = c_comdef_dbsingleton::preparedQuery($in_sql, $in_value_array);
2574 
2575  $this_changes_object = null;
2576 
2577  if (is_array($rows) && count($rows)) {
2578  // We now instantiate a c_comdef_changes object, and create our c_comdef_change objects.
2579  $this_changes_object = new c_comdef_changes($this, $rows);
2580  }
2581 
2582  return $this_changes_object;
2583  }
static preparedQuery($sql, $params=array(), $fetchKeyPair=false)
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statement...
A class to hold a collection of c_comdef_change objects.
static GetChangesTableName_obj ( )
static

Simply returns the name of the changes table.

Returns
A string, containing the name of the changes table.

Definition at line 1067 of file c_comdef_server.class.php.

1068  {
1069  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1070  return self::$server_instance->_changes_table_name;
1071  }
static GetCoverageArea ( )
static

Returns a set of two coordinates that define a rectangle that encloses all of the meetings.

Returns
a dictionary, with the two coordinates.

Definition at line 2155 of file c_comdef_server.class.php.

References $ret, and c_comdef_dbsingleton\preparedQuery().

Referenced by GetCoverageArea().

2156  {
2157  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
2158  $sql = "SELECT longitude, latitude FROM `".self::GetMeetingTableName_obj()."_main` WHERE `published`='1'";
2159 
2160  $ret = null;
2161 
2162  try {
2163  $arr = array();
2164  $rows = c_comdef_dbsingleton::preparedQuery($sql, $arr);
2165  if (is_array($rows) && count($rows)) {
2166  $nw_corner = array ( "longitude" => false, "latitude" => false );
2167  $se_corner = array ( "longitude" => false, "latitude" => false );
2168 
2169  foreach ($rows as $row) {
2170  $lon = max(-180.0, min(180.0, floatval($row["longitude"])));
2171  $lat = max(-90.0, min(90.0, floatval($row["latitude"])));
2172  if (!(($lon == 0) && ($lat == 0)) && (abs($lat) < 90)) {
2173  if ($nw_corner["longitude"] === false) {
2174  $nw_corner["longitude"] = $lon;
2175  } else {
2176  // OK. The IDL (International Date Line) gives us gas. We need to see if the two values are on either side of it.
2177  // If so, then we'll need to reverse the longitude checks.
2178  if ((abs($lon) > 90) && (0 <= $lon) && (0 > $nw_corner["longitude"])) {
2179  $nw_corner["longitude"] = $lon;
2180  } else if ((abs($lon) > 90) && (0 > $lon) && (0 <= $nw_corner["longitude"])) {
2181  continue;
2182  } else {
2183  $nw_corner["longitude"] = min($lon, $nw_corner["longitude"]);
2184  }
2185  }
2186 
2187  if ($se_corner["longitude"] === false) {
2188  $se_corner["longitude"] = $lon;
2189  } else {
2190  if ((abs($lon) > 90) && (0 > $lon) && (0 <= $se_corner["longitude"])) {
2191  $se_corner["longitude"] = $lon;
2192  } else if ((abs($lon) > 90) && (0 <= $lon) && (0 > $se_corner["longitude"])) {
2193  continue;
2194  } else {
2195  $se_corner["longitude"] = max($lon, $se_corner["longitude"]);
2196  }
2197  }
2198 
2199  if ($nw_corner["latitude"] === false) {
2200  $nw_corner["latitude"] = $lat;
2201  } else {
2202  $nw_corner["latitude"] = max($lat, $nw_corner["latitude"]);
2203  }
2204 
2205  if ($se_corner["latitude"] === false) {
2206  $se_corner["latitude"] = $lat;
2207  } else {
2208  $se_corner["latitude"] = min($lat, $se_corner["latitude"]);
2209  }
2210  }
2211  }
2212  }
2213 
2214  $ret["nw_corner"] = $nw_corner;
2215  $ret["se_corner"] = $se_corner;
2216  } catch (Exception $e) {
2217  $ret = null;
2218  }
2219 
2220  return $ret;
2221  }
$ret
Definition: contact.php:226
static preparedQuery($sql, $params=array(), $fetchKeyPair=false)
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statement...
static GetCurrentUserObj (   $in_is_ajax = false)
static

Get the current logged-in user, as a c_comdef_user instance.

Returns
a reference to a c_comdef_user object, containing the user. Null if it failed.
Parameters
$in_is_ajaxIf it's an AJAX handler, this is true.

Definition at line 1207 of file c_comdef_server.class.php.

References $ret.

Referenced by c_comdef_format\DeleteFromDB(), c_comdef_service_body\DeleteFromDB(), c_comdef_user\DeleteFromDB(), c_comdef_meeting\DeleteFromDB(), c_comdef_meeting\DeleteFromDB_NoRecord(), DisplaySearchResultsCSV(), GetMeetings(), c_comdef_admin_ajax_handler\HandleUserChange(), c_comdef_service_body\IsUserInServiceBody(), c_comdef_service_body\IsUserInServiceBodyHierarchy(), c_comdef_meetings\RemoveInvalidMeetings(), c_comdef_admin_ajax_handler\SetMeetingDataValues(), SetUpSearch(), c_comdef_format\UpdateToDB(), c_comdef_user\UpdateToDB(), c_comdef_service_body\UpdateToDB(), c_comdef_meeting\UpdateToDB(), c_comdef_format\UserCanEdit(), c_comdef_user\UserCanEdit(), c_comdef_service_body\UserCanEdit(), c_comdef_meeting\UserCanEdit(), c_comdef_service_body\UserCanEditMeetings(), c_comdef_service_body\UserCanObserve(), and c_comdef_meeting\UserCanObserve().

1209  {
1210  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1211  include(dirname(__FILE__).'/config/get-config.php');
1212 
1213  $ret = null;
1214 
1215  if (!isset($_SESSION)) {
1216  session_start();
1217  }
1218 
1219  if (isset($_SESSION[$admin_session_name])) {
1220  list ( $login_id, $encrypted_password ) = explode("\t", $_SESSION[$admin_session_name]);
1221  $ret = self::GetUserByLoginCredentials($login_id, $encrypted_password);
1222  }
1223 
1224  return $ret;
1225  }
$ret
Definition: contact.php:226
static GetDatabaseVersion ( )
static

Definition at line 2759 of file c_comdef_server.class.php.

References c_comdef_dbsingleton\preparedQuery().

Referenced by GetServerInfo().

2760  {
2761  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
2762  $sql = "SELECT version FROM `".self::GetDatabaseVersionTableName_obj()."`";
2764  if (!is_array($rows) || !count($rows)) {
2765  return 0;
2766  }
2767  $row = $rows[0];
2768  return intval($row['version']);
2769  }
static preparedQuery($sql, $params=array(), $fetchKeyPair=false)
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statement...
static GetDatabaseVersionTableName_obj ( )
static

Definition at line 1098 of file c_comdef_server.class.php.

1099  {
1100  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1101  return self::$server_instance->_db_version_table_name;
1102  }
static GetEncryptedPW (   $in_login,
  $in_password 
)
static

Given a login and password, looks up the user, and returns an encrypted password for that user.

Returns
a string, with the encrypted password. Null if none.
Parameters
$in_loginA string. The login ID.
$in_passwordA string. the UNENCRYPTED password for the user.

Definition at line 1282 of file c_comdef_server.class.php.

References $ret.

1285  {
1286  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1287  $ret = null;
1288 
1289  $users_obj = self::GetServer()->_users_obj;
1290 
1291  if ($users_obj instanceof c_comdef_users) {
1292  $ret = $users_obj->GetEncryptedPW($in_login, $in_password);
1293  }
1294 
1295  return $ret;
1296  }
$ret
Definition: contact.php:226
A class to hold a collection of c_comdef_users objects.
static GetFormatLangs ( )
static

Definition at line 1116 of file c_comdef_server.class.php.

1117  {
1118  return array_merge(self::GetServer()->_server_lang_names, self::GetServer()->_format_lang_names);
1119  }
GetFormatsArray ( )

Simply returns an array of the format objects.

Returns
An array of c_comdef_format objects.

Definition at line 607 of file c_comdef_server.class.php.

608  {
609  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
610  return ($this->GetFormatsObj() instanceof c_comdef_formats) ? $this->GetFormatsObj()->GetFormatsArray() : null;
611  }
GetFormatsObj()
Simply returns a reference to the formats container.
Include the format class.
GetFormatsObj ( )

Simply returns a reference to the formats container.

Returns
A reference to the formats container object.

Definition at line 591 of file c_comdef_server.class.php.

592  {
593  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
594  if (!$this->_formats_obj) {
595  $this->ReadFormats();
596  }
597 
598  return $this->_formats_obj;
599  }
$_formats_obj
This is the container for the loaded formats.
ReadFormats()
This is an internal function that reads in all of the stored formats, in all provided languages...
static GetFormatTableName_obj ( )
static

Simply returns the name of the format table.

Returns
A string, containing the name of the format table.

Definition at line 1043 of file c_comdef_server.class.php.

1044  {
1045  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1046  return self::$server_instance->_format_table_name;
1047  }
static getKmPerLonAtLat (   $dLatitude)
static

Returns the number of Km per degree of longitude, adjusted for Latitude.

Returns
a floating point number, with the number of Km per degree longitude at the given latitude..
Parameters
$dLatitudeThe latitude (in degrees).

Definition at line 2343 of file c_comdef_server.class.php.

2345  {
2346  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
2347  return 111.321 * cos(deg2rad($dLatitude));
2348  }
GetLocalLang ( )

Returns the Server Local Language.

Returns
a string, with the language enum.

Definition at line 282 of file c_comdef_server.class.php.

References $comdef_global_language, and $lang_enum.

283  {
284  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
285  $lang_enum = $this->_local_type_lang_enum;
286 
287  if (!$lang_enum) {
290  }
291 
292  // Should never happen.
293  if (!$lang_enum) {
294  $lang_enum = "en";
295  }
296 
297  return $lang_enum;
298  }
global $comdef_global_language
The local server language enum (Will default to English)
$lang_enum
Definition: index.php:23
static GetLocalStrings (   $in_lang_enum = null)
static

This gets the appropriate language files, and puts all the the strings into an associative array. If a language enum is passed in, and the language directory exists, then the strings are loaded from that directory. If nothing is passed in, the first place we look is in the HTTP query, to see if a 'lang_enum' query is present. If it is there, we use that. If not, we use the base server language.

Returns
an associative array of local strings. Null if it failed.
  • 'name' The name of the language, in the language itself.
  • 'enum' The code for the language.
  • 'weekdays' An array of weekday names. 0 -> Sunday, 6 -> Saturday
  • 'prompt_delimiter' The character used to delimit prompts (usually a colon ':').
  • 'comdef_map_radius_ranges' An array of floating point numbers that indicate the choices for the radius selector (in miles).
  • 'comdef_search_admin_strings' An associative array, with strings used only in administration.
  • 'comdef_format_types' An associative array that maps format classes to their descriptions.
  • 'change_type_strings' An associative array that maps the types of changes to their descriptions.
  • 'detailed_change_strings' An associative array that maps detailed descriptions of itemized changes.
  • 'end_change_report' The character used to end a change report (usually a period '.').

< This is a format string for the way the address line is displayed in the "more details" screen.

< The same, but for the list.

< The default range (min, max), in Km.

Parameters
$in_lang_enumAn enumeration string, indicating the language desired. If provided, it overrides all else.

Definition at line 2606 of file c_comdef_server.class.php.

References $_GET, $change_type_strings, $comdef_global_list_address, $comdef_global_more_details_address, $comdef_map_radius_ranges, $comdef_server_admin_strings, $detailed_change_strings, $email_contact_strings, $lang_enum, $server, $server_local_strings, c_comdef_service_body__ASC__, c_comdef_service_body__COP__, c_comdef_service_body__GRP__, c_comdef_service_body__MAS__, c_comdef_service_body__RSC__, c_comdef_service_body__WSC__, c_comdef_service_body__ZFM__, and defined.

Referenced by c_comdef_admin_xml_handler\__construct(), c_comdef_admin_ajax_handler\__construct(), c_comdef_admin_main_console\__construct(), BMLT_FuncNAWSReturnOpenOrClosed(), bmlt_populate_format_dictionary(), BuildTime(), c_comdef_admin_bar(), c_comdef_htmlspecialchars(), c_comdef_LoginForm(), c_comdef_change\DescribeChange(), c_comdef_change\DetailedChangeDescription(), DisplaySearchResultsCSV(), c_comdef_admin_xml_handler\get_changes_as_csv(), c_comdef_admin_xml_handler\get_deleted_meetings_as_csv(), c_comdef_admin_xml_handler\get_meeting_data(), c_comdef_meeting\GetAddressDataItemBuilder(), c_comdef_meeting\GetAddressDataItemKeys(), GetChanges(), GetGeocodeFromString(), c_comdef_meeting\GetMainDataTemplate(), c_comdef_meetings\GetMeetingsByString(), GetServerInfo(), GetServiceBodies(), parse_redirect(), prepareSimpleLine(), c_comdef_admin_xml_handler\process_meeting_modify(), and SetUpSearch().

2608  {
2609  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
2611  // This will create the SINGLETON server if one does not yet exist.
2612  $server = self::MakeServer();
2613 
2614  if ($server instanceof c_comdef_server) {
2615  $lang_enum = $server->GetLocalLang();
2616 
2617  if (isset($_GET['lang_enum']) && $_GET['lang_enum']) {
2618  $lang_enum = $_GET['lang_enum'];
2619  }
2620 
2621  if (isset($_POST['lang_enum']) && $_POST['lang_enum']) {
2622  $lang_enum = $_POST['lang_enum'];
2623  }
2624 
2625  if (is_array($lang_enum) && count($lang_enum)) {
2626  $langs = array();
2627  foreach ($lang_enum as $lang) {
2628  if (file_exists(dirname(dirname(__FILE__)).'/local_server/server_admin/lang/'.$lang)) {
2629  array_push($langs, $lang);
2630  }
2631  }
2632  $lang_enum = implode(",", $langs);
2633  } elseif ($in_lang_enum && file_exists(dirname(dirname(__FILE__)).'/local_server/server_admin/lang/'.$in_lang_enum)) {
2634  $lang_enum = $in_lang_enum;
2635  }
2636 
2637  include(dirname(__FILE__)."/config/comdef-config.inc.php");
2638  include(dirname(dirname(__FILE__)).'/local_server/server_admin/lang/'.$lang_enum.'/server_admin_strings.inc.php');
2639 
2640  global $comdef_global_more_details_address, ///< This is a format string for the way the address line is displayed in the "more details" screen.
2641  $comdef_global_list_address; ///< The same, but for the list.
2642 
2643  c_comdef_server::$server_local_strings['default_meeting_published'] = isset($default_meeting_published) ? $default_meeting_published : true;
2644  c_comdef_server::$server_local_strings['week_starts_on'] = (isset($week_starts_on) && (-1 < $week_starts_on) && (7 > $week_starts_on)) ? $week_starts_on : 0;
2645  c_comdef_server::$server_local_strings['name'] = file_get_contents(dirname(dirname(__FILE__)).'/local_server/server_admin/lang/'.$lang_enum.'/name.txt');
2649  array ( 0.1, 100.0 ); ///< The default range (min, max), in Km.
2650  c_comdef_server::$server_local_strings['include_service_body_email_in_semantic'] = false;
2651  if (isset($g_include_service_body_email_in_semantic)) {
2652  c_comdef_server::$server_local_strings['include_service_body_email_in_semantic'] = $g_include_service_body_email_in_semantic;
2653  }
2654 
2655  c_comdef_server::$server_local_strings['auto_geocoding_enabled'] = isset($auto_geocoding_enabled) ? $auto_geocoding_enabled : true;
2656  c_comdef_server::$server_local_strings['sort_formats'] = isset($sort_formats) ? $sort_formats : true;
2657  c_comdef_server::$server_local_strings['meeting_counties_and_sub_provinces'] = isset($meeting_counties_and_sub_provinces) ? $meeting_counties_and_sub_provinces : array();
2658  c_comdef_server::$server_local_strings['meeting_states_and_provinces'] = isset($meeting_states_and_provinces) ? $meeting_states_and_provinces : array();
2659  c_comdef_server::$server_local_strings['google_api_key'] = isset($gkey) ? $gkey : '';
2660  c_comdef_server::$server_local_strings['region_bias'] = isset($region_bias) ? $region_bias : 'us';
2661  c_comdef_server::$server_local_strings['default_duration_time'] = isset($default_duration_time) ? $default_duration_time : '01:00:00';
2662  c_comdef_server::$server_local_strings['default_minute_interval'] = isset($default_minute_interval) ? $default_minute_interval : 5;
2663  c_comdef_server::$server_local_strings['search_spec_map_center'] = $search_spec_map_center;
2667  c_comdef_server::$server_local_strings['prompt_delimiter'] = defined('__PROMPT_DELIMITER__') ? __PROMPT_DELIMITER__ : ':';
2668  c_comdef_server::$server_local_strings['end_change_report'] = defined('_END_CHANGE_REPORT') ? _END_CHANGE_REPORT : '.';
2669  c_comdef_server::$server_local_strings['charset'] = defined('__HTML_DISPLAY_CHARSET__') ? __HTML_DISPLAY_CHARSET__ : 'UTF-8';
2670  c_comdef_server::$server_local_strings['time_format'] = $time_format;
2671  c_comdef_server::$server_local_strings['min_pw_len'] = intval($min_pw_len);
2672  c_comdef_server::$server_local_strings['number_of_meetings_for_auto'] = $number_of_meetings_for_auto;
2673  c_comdef_server::$server_local_strings['comdef_global_more_details_address'] = $comdef_global_more_details_address;
2676  c_comdef_server::$server_local_strings['default_sorts'] = array ( 'weekday' => array('weekday_tinyint','location_municipality','location_city_subsection','start_time','location_neighborhood'),
2677  'time' => array('weekday_tinyint','start_time','location_municipality','location_city_subsection','location_neighborhood'),
2678  'town' => array('location_municipality','location_city_subsection','location_neighborhood','weekday_tinyint','start_time'),
2679  'state' => array('location_province','location_municipality','location_city_subsection','weekday_tinyint','start_time'),
2680  'weekday_state' => array('weekday_tinyint','location_province','location_municipality','start_time','location_city_subsection')
2681  );
2682 
2683  c_comdef_server::$server_local_strings['weekdays'] = $comdef_server_admin_strings['meeting_search_weekdays_names'];
2684  c_comdef_server::$server_local_strings['service_body_types'] = array ( c_comdef_service_body__GRP__ => $comdef_server_admin_strings['service_body_editor_type_c_comdef_service_body__GRP__'],
2685  c_comdef_service_body__COP__ => $comdef_server_admin_strings['service_body_editor_type_c_comdef_service_body__COP__'],
2686  c_comdef_service_body__ASC__ => $comdef_server_admin_strings['service_body_editor_type_c_comdef_service_body__ASC__'],
2687  c_comdef_service_body__RSC__ => $comdef_server_admin_strings['service_body_editor_type_c_comdef_service_body__RSC__'],
2688  c_comdef_service_body__WSC__ => $comdef_server_admin_strings['service_body_editor_type_c_comdef_service_body__WSC__'],
2689  c_comdef_service_body__MAS__ => $comdef_server_admin_strings['service_body_editor_type_c_comdef_service_body__MAS__'],
2690  c_comdef_service_body__ZFM__ => $comdef_server_admin_strings['service_body_editor_type_c_comdef_service_body__ZFM__']
2691  );
2692 
2693  c_comdef_server::$server_local_strings['default_closed_status'] = (!isset($g_defaultClosedStatus) || $g_defaultClosedStatus) ? 1 : ((isset($g_defaultClosedStatus) && !$g_defaultClosedStatus) ? 0 : 1);
2694  if (trim($comdef_distance_units)) {
2695  c_comdef_server::$server_local_strings['dist_units'] = strtolower(trim($comdef_distance_units));
2696  } else {
2697  c_comdef_server::$server_local_strings['dist_units'] = 'mi';
2698  }
2699 
2700  if (isset($default_timezone) && $default_timezone) {
2701  date_default_timezone_set($default_timezone);
2702  }
2703 
2704  ini_set('default_charset', '');
2705  }
2706  }
2707 
2709  }
global $comdef_map_radius_ranges
const c_comdef_service_body__COP__
const c_comdef_service_body__WSC__
const c_comdef_service_body__RSC__
$lang_enum
Definition: index.php:23
global $comdef_global_more_details_address
This is a format string for the way the address line is displayed in the "more details" screen...
const c_comdef_service_body__ZFM__
const c_comdef_service_body__ASC__
static $server_local_strings
This contains a cache of the local strings.
This class is the main server class. It instantiates a PDO database object, and is the starting point...
defined('BMLT_EXEC') or define('BMLT_EXEC'
Definition: index.php:3
const c_comdef_service_body__GRP__
const c_comdef_service_body__MAS__
global $comdef_global_list_address
The same, but for the list.
$comdef_server_admin_strings
$_GET['switcher']
static GetMeetings (   $in_service_body_id_bigint_array = null,
  $in_lang_filter_array = null,
  $in_weekday_tinyint_array = null,
  $in_formats = null,
  $in_start_after = null,
  $in_start_before = null,
  $in_end_before = null,
  $in_min_duration = null,
  $in_max_duration = null,
  $in_search_rect_array = null,
  $in_first = null,
$in_num = null,
  $in_published = 0 
)
static

Given a set of one or more main criteria, returns a new c_comdef_meetings object with instances of those meetings, loaded from the database.

This is the big kahuna. Meeting searches will all use this function as a fulcrum for their searches.

NOTE TO UPTIGHT PROGRAMMERS: Yeah, it's a big, massive function with a gazillion multi-purpose parameters.

Learn to live with it. It works fine, and makes sense for the context. I could break it into a bunch of smaller functions, but that would increase the complexity and reduce performance.

Returns
a new c_comdef_meetings object, containing the meetings. Null if it failed.
Exceptions
anexception if the SQL query fails.
Parameters
$in_start_afterAn epoch time (seconds, as returned by time()), that denotes the earliest starting time allowed.
$in_start_beforeAn epoch time (seconds, as returned by time()), that denotes the latest starting time allowed.
$in_end_beforeAn epoch time (seconds, as returned by time()), that denotes the latest ending time allowed.
$in_min_durationThe number of seconds a meeting should last as a minimum.
$in_max_durationThe number of seconds a meeting can last, at most.

Definition at line 1639 of file c_comdef_server.class.php.

References $ret, GetCurrentUserObj(), c_comdef_meetings\GetDistance(), and c_comdef_dbsingleton\pdoInstance().

Referenced by c_comdef_meeting_search_manager\GetSearchResults_Obj().

1688  {
1689  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1690  $previous = false; // This is used to tell subsequent tests to use AND instead of WHERE
1691 
1692  $sql = "SELECT * FROM `".self::GetMeetingTableName_obj()."_main`";
1693  $ar = array ( );
1694 
1695  if (is_array($in_service_body_id_bigint_array) && count($in_service_body_id_bigint_array)) {
1696  $sql .= " WHERE (";
1697  $previous = true;
1698  $first = true;
1699  foreach ($in_service_body_id_bigint_array as $service_body_id) {
1700  $service_body_id = intval($service_body_id);
1701  $sql_x = "";
1702  if ($service_body_id < 0) {
1703  $service_body_id = abs($service_body_id);
1704  $sql_x = " NOT ";
1705 
1706  if (!$first) {
1707  $sql_x = " AND $sql_x";
1708  }
1709 
1710  $first = true; // This makes the OR get skipped.
1711  }
1712 
1713  if (!$first) {
1714  $sql_x .= " OR ";
1715  } else {
1716  $first = false;
1717  }
1718 
1719  $sql .= "$sql_x(".self::GetMeetingTableName_obj()."_main.service_body_bigint=?)";
1720  array_push($ar, $service_body_id);
1721  }
1722  $sql .= ")";
1723  }
1724 
1725  if (is_array($in_lang_filter_array) && count($in_lang_filter_array)) {
1726  if ($previous) {
1727  $sql .= " AND ";
1728  } else {
1729  $sql .= " WHERE ";
1730  $previous = true;
1731  }
1732 
1733  $sql .= "(";
1734 
1735  $first = true;
1736  foreach ($in_lang_filter_array as $lang) {
1737  $not = preg_match("|^\-(.*)|", $lang, $matches);
1738 
1739  $sql_x = "";
1740  if ($not) {
1741  $lang = $matches[1];
1742  $sql_x = " NOT ";
1743 
1744  if (!$first) {
1745  $sql_x = " AND $sql_x";
1746  }
1747 
1748  $first = true; // This makes the OR get skipped.
1749  }
1750 
1751  if (!$first) {
1752  $sql_x .= " OR ";
1753  } else {
1754  $first = false;
1755  }
1756 
1757  $sql .= "$sql_x(".self::GetMeetingTableName_obj()."_main.lang_enum=?)";
1758 
1759  array_push($ar, $lang);
1760  }
1761  $sql .= ")";
1762  }
1763 
1764  if (is_array($in_weekday_tinyint_array) && count($in_weekday_tinyint_array)) {
1765  $valid = false;
1766 
1767  foreach ($in_weekday_tinyint_array as $weekday) {
1768  if (abs(intval($weekday)) > 0 && abs(intval($weekday)) < 8) {
1769  $valid = true;
1770  }
1771  }
1772 
1773  if ($valid) {
1774  if ($previous) {
1775  $sql .= " AND ";
1776  } else {
1777  $sql .= " WHERE ";
1778  $previous = true;
1779  }
1780 
1781  $sql .= "(";
1782 
1783  $first = true;
1784  foreach ($in_weekday_tinyint_array as $weekday) {
1785  $weekday = intval($weekday);
1786  $sql_x = "";
1787  if ($weekday < 0) {
1788  $weekday = abs($weekday);
1789  $sql_x = " NOT ";
1790 
1791  if (!$first) {
1792  $sql_x = " AND $sql_x";
1793  }
1794 
1795  $first = true; // This makes the OR get skipped.
1796  }
1797 
1798  if (!$first) {
1799  $sql_x .= " OR ";
1800  } else {
1801  $first = false;
1802  }
1803 
1804  $sql .= "$sql_x(".self::GetMeetingTableName_obj()."_main.weekday_tinyint=?)";
1805  array_push($ar, $weekday-1);
1806  }
1807  $sql .= ")";
1808  }
1809  }
1810 
1811  // We explicitly set null entries, because we've seen problems with using nulls.
1812  if (null != $in_start_after) {
1813  $in_start_after = date("H:i:00", intval($in_start_after));
1814  } else {
1815  $in_start_after = "00:00:00";
1816  }
1817 
1818  if (null != $in_start_before) {
1819  $in_start_before = date("H:i:00", intval($in_start_before));
1820  } else {
1821  $in_start_before = "00:00:00";
1822  }
1823 
1824  if (null != $in_end_before) {
1825  $in_end_before = intval($in_end_before);
1826  } else {
1827  $in_end_before = null;
1828  }
1829 
1830  if (null != $in_min_duration) {
1831  $in_min_duration = date("H:i:00", intval($in_min_duration));
1832  } else {
1833  $in_min_duration = "00:00:00";
1834  }
1835 
1836  if (null != $in_max_duration) {
1837  $in_max_duration = date("H:i:00", intval($in_max_duration));
1838  } else {
1839  $in_max_duration = "00:00:00";
1840  }
1841 
1842  if ($in_start_after != "00:00:00") {
1843  if ($previous) {
1844  $sql .= " AND ";
1845  } else {
1846  $sql .= " WHERE ";
1847  $previous = true;
1848  }
1849  $sql .= self::GetMeetingTableName_obj()."_main.start_time>?";
1850 
1851  array_push($ar, $in_start_after);
1852  }
1853 
1854  if ($in_start_before != "00:00:00") {
1855  if ($previous) {
1856  $sql .= " AND ";
1857  } else {
1858  $sql .= " WHERE ";
1859  $previous = true;
1860  }
1861  $sql .= self::GetMeetingTableName_obj()."_main.start_time<?";
1862 
1863  array_push($ar, $in_start_before);
1864  }
1865 
1866  if ($in_end_before != null) {
1867  if ($previous) {
1868  $sql .= " AND ";
1869  } else {
1870  $sql .= " WHERE ";
1871  $previous = true;
1872  }
1873 
1874  $sql .= "TIME_TO_SEC(".self::GetMeetingTableName_obj()."_main.start_time+".self::GetMeetingTableName_obj()."_main.duration_time)<=?";
1875 
1876  array_push($ar, $in_end_before);
1877  }
1878 
1879  if ($in_min_duration != "00:00:00") {
1880  if ($previous) {
1881  $sql .= " AND ";
1882  } else {
1883  $sql .= " WHERE ";
1884  $previous = true;
1885  }
1886  $sql .= self::GetMeetingTableName_obj()."_main.duration_time>=?";
1887 
1888  array_push($ar, $in_min_duration);
1889  }
1890 
1891  if ($in_max_duration != "00:00:00") {
1892  if ($previous) {
1893  $sql .= " AND ";
1894  } else {
1895  $sql .= " WHERE ";
1896  $previous = true;
1897  }
1898  $sql .= self::GetMeetingTableName_obj()."_main.duration_time<=?";
1899 
1900  array_push($ar, $in_max_duration);
1901  }
1902 
1903  if (is_array($in_search_rect_array) && isset($in_search_rect_array['east']) && isset($in_search_rect_array['west']) && isset($in_search_rect_array['north']) && isset($in_search_rect_array['south'])) {
1904  if ($previous) {
1905  $sql .= " AND ";
1906  } else {
1907  $sql .= " WHERE ";
1908  $previous = true;
1909  }
1910 
1911  $east = floatval($in_search_rect_array['east']);
1912  $west = floatval($in_search_rect_array['west']);
1913  $north = floatval($in_search_rect_array['north']);
1914  $south = floatval($in_search_rect_array['south']);
1915  $sql .= "(";
1916  if ($east > $west) {
1917  $sql .= "(longitude >= $west) AND (longitude <= $east)";
1918  } else {
1919  $sql .= "(longitude <= $west) AND (longitude >= $east)";
1920  }
1921 
1922  $sql .= " AND (latitude <= $north) AND (latitude >= $south)";
1923  $sql .= ")";
1924  }
1925 
1927  // Logged-in users can see both published and unpublished meetings.
1928  if ($in_published != 0) {
1929  if ($previous) {
1930  $sql .= " AND ";
1931  } else {
1932  $sql .= " WHERE ";
1933  $previous = true;
1934  }
1935 
1936  if ($in_published == -1) {
1937  $sql .= "(published=0)";
1938  } else {
1939  $sql .= "(published=1)";
1940  }
1941  }
1942  } else // If we are not logged in, we can only see published meetings.
1943  {
1944  if ($previous) {
1945  $sql .= " AND ";
1946  } else {
1947  $sql .= " WHERE ";
1948  $previous = true;
1949  }
1950 
1951  $sql .= "(published=1)";
1952  }
1953 
1954  $ret = null;
1955 
1956  if (is_array($in_formats) && count($in_formats)) {
1957  // MySQL and Oracle allow the REGEXP test, but other DBs don't.
1958  if (('mysql' == c_comdef_dbsingleton::pdoInstance()->getAttribute(PDO::ATTR_DRIVER_NAME))
1959  || ('oracle' == c_comdef_dbsingleton::pdoInstance()->getAttribute(PDO::ATTR_DRIVER_NAME)) ) {
1960  if ($previous) {
1961  $sql .= " AND (";
1962  } else {
1963  $sql .= " WHERE (";
1964  }
1965 
1966  $column = self::GetMeetingTableName_obj()."_main.formats";
1967 
1968  $first = true;
1969 
1970  foreach ($in_formats as $format) {
1971  $format = trim($format);
1972 
1973  if ($format) {
1974  // This is why we don't need to scrub the input. No SQL injection here.
1975  $format = intval($format);
1976  if (!$first) {
1977  $sql .= " AND ";
1978  } else {
1979  $first = false;
1980  }
1981 
1982  // This is a test for if the format is a NOT.
1983  if ($format < 0) {
1984  $format = abs($format);
1985  $sql .= "NOT ";
1986  }
1987 
1988  $sql .= "($column REGEXP";
1989 
1990  // Oracle uses REGEXP_LIKE
1991  if ('oracle' == c_comdef_dbsingleton::pdoInstance()->getAttribute(PDO::ATTR_DRIVER_NAME)) {
1992  $sql .= "_LIKE";
1993  }
1994 
1995  $sql .= "'(^|,)$format(,|\$)')";
1996  }
1997  }
1998 
1999  $sql .= ")";
2000  } else // Non-MySQL, Non-Oracle servers don't have REGEX in their SQL, so we need to search by hand.
2001  {
2002  $sql .= " ORDER BY service_body_bigint, id_bigint";
2003  if (intval($in_num)) {
2004  $in_first = intval($in_first);
2005  $in_num = intval($in_num);
2006  $sql .= " LIMIT $in_first, $in_num";
2007  }
2008 
2009  $ret = self::GetMeetingsFromSQL($sql, $ar);
2010 
2011  if ($ret && intval($in_num)) {
2012  $in_num = $ret->GetNumMeetings();
2013  } elseif (intval($in_num)) {
2014  $in_num = 0;
2015  }
2016 
2017  $ret = self::ParseMeetingsByFormats($ret, $in_formats);
2018  }
2019  }
2020 
2021  if (!$ret) {
2022  $sql .= " ORDER BY service_body_bigint, id_bigint";
2023 
2024  if (intval($in_num)) {
2025  $in_first = intval($in_first);
2026  $in_num = intval($in_num);
2027  $sql .= " LIMIT $in_first, $in_num";
2028  }
2029 
2030  $ret = self::GetMeetingsFromSQL($sql, $ar);
2031 
2032  if (intval($in_num)) {
2033  $in_num = count($ret->GetMeetingObjects());
2034  }
2035 
2036  if ($ret && isset($east) && isset($west) && isset($north) && isset($south)) {
2037  $center_lat = ($north + $south) / 2.0;
2038  $center_long = ($east + $west) / 2.0;
2039  $meetings = $ret->GetMeetingObjects();
2040  foreach ($meetings as &$meeting) {
2041  $dist = floatval(c_comdef_meetings::GetDistance($center_lat, $center_long, $meeting->GetMeetingDataValue('latitude'), $meeting->GetMeetingDataValue('longitude')));
2042  $meeting->_distance_in_km = $dist;
2043  $meeting->_distance_in_miles = $dist / 1.609344;
2044  $meeting->AddDataField('distance_in_km', 'distance_in_km', $meeting->_distance_in_km, null, 0, true);
2045  $meeting->AddDataField('distance_in_miles', 'distance_in_miles', $meeting->_distance_in_miles, null, 0, true);
2046  }
2047  }
2048  }
2049  return $ret;
2050  }
static GetDistance($lat1, $lon1, $lat2, $lon2)
Uses the Vincenty calculation to estimate a distance between the two given lat/long pairs...
This class handles BMLT users. One instance is created for each user on the server.
$ret
Definition: contact.php:226
static pdoInstance($do_connect=false)
Provides access to internal PDO object in case this classes functionality is not enough.
static GetCurrentUserObj($in_is_ajax=false)
Get the current logged-in user, as a c_comdef_user instance.
static GetMeetingsByID (   $in_id_bigint_array)
static

Get a series of meetings, each identified by an ID. This does not filter by any of the other major criteria. It is designed to facilitate direct access to meeting objects.

Returns
a new c_comdef_meetings object, containing the meetings. Null if it failed.
Parameters
$in_id_bigint_arrayThe ID of the meetings (An array of integers)

Definition at line 1596 of file c_comdef_server.class.php.

Referenced by c_comdef_admin_xml_handler\get_deleted_meetings_as_csv(), and c_comdef_meeting_search_manager\GetSearchResults_Obj().

1598  {
1599  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1600  $sql = "SELECT * FROM `".self::GetMeetingTableName_obj()."_main` WHERE ";
1601 
1602  $first = true;
1603 
1604  // We don't actually care what the array contains. We're just counting them out.
1605  foreach ($in_id_bigint_array as $in_id_bigint) {
1606  if (!$first) {
1607  $sql .= " OR ";
1608  } else {
1609  $first = false;
1610  }
1611 
1612  $sql .= "(".self::GetMeetingTableName_obj()."_main.id_bigint=?)";
1613  }
1614 
1615  return self::GetMeetingsFromSQL($sql, $in_id_bigint_array);
1616  }
static GetMeetingsForAServiceBody (   $in_sb_id)
static

Returns a c_comdef_meetings_object, containing all the meetings directly "owned" by the Service Body whose ID is submitted.

Returns
a new c_comdef_meetings object, containing the meetings. Null if it failed.
Exceptions
anexception if the SQL query fails.
Parameters
$in_sb_idAn integer. The ID of the Service Body.

Definition at line 2062 of file c_comdef_server.class.php.

Referenced by c_comdef_admin_ajax_handler\HandleMeetingWorldIDsUpdate().

2064  {
2065  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
2066  $sql = "SELECT * FROM `".self::GetMeetingTableName_obj()."_main` WHERE ".self::GetMeetingTableName_obj()."_main.service_body_bigint=? ORDER BY id_bigint";
2067 
2068  return self::GetMeetingsFromSQL($sql, array ( $in_sb_id ));
2069  }
static GetMeetingsFromSQL (   $in_sql,
  $in_value_array = null 
)
staticprivate

Given an SQL statement and a value array (for PDO prepared statements), return a new c_comdef_meetings object, loaded with the instances of the meetings that were returned from the query.

Returns
a new c_comdef_meetings object, containing the meetings. Null if it failed.
Exceptions
anexception if the SQL query fails.
Parameters
$in_sqlThe prepared statement SQL query
$in_value_arrayAn array of values for the prepared statement.

Definition at line 2233 of file c_comdef_server.class.php.

References c_comdef_dbsingleton\preparedQuery(), and c_comdef_meeting\process_meeting_row().

2236  {
2237  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
2238  $rows = c_comdef_dbsingleton::preparedQuery($in_sql, $in_value_array);
2239 
2240  $meeting_data = array();
2241  $this_meetings_object = null;
2242 
2243  if (is_array($rows) && count($rows)) {
2244  foreach ($rows as $row) {
2245  // We use the static function in the c_comdef_meeting class to process the data for the meeting.
2246  $meeting_row = c_comdef_meeting::process_meeting_row($row);
2247  // At this point, we have all the data for this one meeting, culled from its three tables and aggregated into an array.
2248  // Add this to our aggregator array.
2249  $meeting_data[$row['id_bigint']] = $meeting_row;
2250  }
2251 
2252  // We now instantiate a c_comdef_meetings object, and create our c_comdef_meeting objects.
2253  $this_meetings_object = new c_comdef_meetings(self::GetServer(), $meeting_data);
2254  }
2255 
2256  return $this_meetings_object;
2257  }
static process_meeting_row($row, $data_rows=null, $longdata_rows=null)
This processes the data retrieved from a single main table meeting. It will look up the corollary dat...
static preparedQuery($sql, $params=array(), $fetchKeyPair=false)
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statement...
A class to hold a collection of c_comdef_meeting objects.
static GetMeetingTableName_obj ( )
static

Simply returns the name of the meetings table.

Returns
A string, containing the name of the meetings table.

Definition at line 1055 of file c_comdef_server.class.php.

Referenced by c_comdef_meeting\GetAllValuesForKey(), and NAWSImport\throwIfDuplicateMeetings().

1056  {
1057  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1058  return self::$server_instance->_meeting_table_name;
1059  }
static GetNamespace ( )
static

Simply returns the namespace of this server.

Returns
A string, with the namespace. The default is the server URI, with "/CoMDEF" appended.

Definition at line 1031 of file c_comdef_server.class.php.

1032  {
1033  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1034  return self::$server_instance->_server_namespace;
1035  }
GetNestedServiceBodyArray (   $in_id = 0)

This reads the Service bodies in hierarchical order, and returns them in a multi-dimensional array that reflects the hierarchy.

Returns
A multidimensional associative array, containing the Service bodies, as references, and structured in a manner that reflects the hierarchical arrangement of the Service bodies. The 'object' element contains a reference to the object itself, and the 'dependents' element (if it exists), reflects the Service bodies that are "owned" by this one.
Parameters
$in_idThe ID of the "top" Service body. If not supplied, we start at the top.

Definition at line 556 of file c_comdef_server.class.php.

558  {
559  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
560  $ret_array = null;
561 
562  if ($in_id) {
563  $sb = $this->GetServiceBodyByIDObj($in_id);
564  if ($sb instanceof c_comdef_service_body) {
565  $id = $sb->GetID();
566  $ret_array['object'] = $sb;
567  }
568  }
569 
570  foreach ($this->_service_obj_array as &$sb) {
571  if ($sb instanceof c_comdef_service_body) {
572  $id = $sb->GetID();
573 
574  $sb_parent = intval($sb->GetOwnerID());
575 
576  if ($sb_parent == $in_id) {
577  $ret_array['dependents'][$id] = $this->GetNestedServiceBodyArray($id);
578  }
579  }
580  }
581 
582  return $ret_array;
583  }
A Class for Service Body Objects.
GetNestedServiceBodyArray($in_id=0)
This reads the Service bodies in hierarchical order, and returns them in a multi-dimensional array th...
static GetServiceBodyByIDObj($in_service_body_id_bigint)
Get the object for a single service body, given an ID.
static GetOneChange (   $in_id_bigint)
static

Given an ID for a change, it returns one instance.

This will return one c_comdef_change object, with the parent this server (Not a c_comdef_changes object).

Returns
a new c_comdef_change object.Null if it failed.
Exceptions
anexception if the SQL query fails.
Parameters
$in_id_bigintThe ID of the change (An integer)

Definition at line 1524 of file c_comdef_server.class.php.

References $ret.

1526  {
1527  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1528  $ret = null;
1529 
1530  $sql = "SELECT * FROM `".self::GetChangesTableName_obj()."` WHERE id_bigint=? LIMIT 1";
1531 
1532  $changes = self::GetServer()->GetChangesFromSQL($sql, array ( $in_id_bigint ));
1533 
1534  if ($changes instanceof c_comdef_changes) {
1535  $c_array = $changes->GetChangesObjects();
1536 
1537  if (is_array($c_array) && count($c_array)) {
1538  // Just to spike an associative-only array. Silly, I know, but I've had problems in the past. PHP is wacky.
1539  foreach ($c_array as $change) {
1540  $ret = $change;
1541  break;
1542  }
1543  }
1544  }
1545 
1546  return $ret;
1547  }
$ret
Definition: contact.php:226
A class to hold a collection of c_comdef_change objects.
static GetOneFormat (   $in_id_bigint,
  $in_lang_enum 
)
static

Given an ID and a language for a format, it returns one instance.

This will return one c_comdef_format object, with the parent this server (Not a c_comdef_formats object).

Returns
a new c_comdef_format object.Null if it failed.
Exceptions
anexception if the SQL query fails.
Parameters
$in_id_bigintThe ID of the formatShared (An integer)
$in_lang_enumThe language for the format.

Definition at line 1423 of file c_comdef_server.class.php.

References c_comdef_dbsingleton\preparedQuery().

Referenced by c_comdef_format\DeleteFromDB(), and c_comdef_format\UpdateToDB().

1426  {
1427  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1428  $sql = "SELECT * FROM `".self::GetFormatTableName_obj()."` WHERE shared_id_bigint=? AND lang_enum=? LIMIT 1";
1429 
1430  $rows = c_comdef_dbsingleton::preparedQuery($sql, array ( $in_id_bigint, $in_lang_enum ));
1431  if (is_array($rows) && count($rows)) {
1432  $rs = $rows[0];
1433  // We use the static function in the c_comdef_meeting class to process the data for the meeting.
1434  return new c_comdef_format(
1435  self::GetServer(),
1436  $rs['shared_id_bigint'],
1437  $rs['format_type_enum'],
1438  $rs['key_string'],
1439  $rs['icon_blob'],
1440  $rs['worldid_mixed'],
1441  $rs['lang_enum'],
1442  $rs['name_string'],
1443  $rs['description_string']
1444  );
1445  }
1446 
1447  return null;
1448  }
static preparedQuery($sql, $params=array(), $fetchKeyPair=false)
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statement...
A Class for Format Codes.
static GetOneMeeting (   $in_id_bigint,
  $test_only = false 
)
static

Given an ID for a meeting, it returns one instance.

This will return one c_comdef_meeting object, with the parent this server (Not a c_comdef_meetings object).

Returns
a new c_comdef_meeting object.Null if it failed.
Exceptions
anexception if the SQL query fails.
Parameters
$in_id_bigintThe ID of the meeting (An integer)
$test_onlyIf true, then this function will only return Boolean true or false (true if the meeting exists)

Definition at line 1485 of file c_comdef_server.class.php.

References c_comdef_dbsingleton\preparedQuery(), and c_comdef_meeting\process_meeting_row().

Referenced by c_comdef_admin_xml_handler\get_changes_as_csv(), c_comdef_admin_xml_handler\get_meeting_data(), c_comdef_change\GetBeforeObject(), GetChanges(), c_comdef_meeting_search_manager\GetSingleMeetingByID(), c_comdef_admin_xml_handler\process_rollback_meeting(), and c_comdef_change\Rollback().

1488  {
1489  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1490  $sql = "SELECT * FROM `".self::GetMeetingTableName_obj()."_main` WHERE ".self::GetMeetingTableName_obj()."_main.id_bigint=? LIMIT 1";
1491 
1492  $rows = c_comdef_dbsingleton::preparedQuery($sql, array ( $in_id_bigint ));
1493  if (is_array($rows) && count($rows)) {
1494  if ($test_only) {
1495  return true;
1496  }
1497 
1498  foreach ($rows as $row) {
1499  // We use the static function in the c_comdef_meeting class to process the data for the meeting.
1500  $meeting_row = c_comdef_meeting::process_meeting_row($row);
1501  // One difference between this type of meeting and others, is that the parent is the server, not a c_comdef_meetngs object.
1502  return new c_comdef_meeting(self::GetServer(), $meeting_row);
1503  }
1504  }
1505 
1506  if ($test_only) {
1507  return false;
1508  }
1509 
1510  return null;
1511  }
static process_meeting_row($row, $data_rows=null, $longdata_rows=null)
This processes the data retrieved from a single main table meeting. It will look up the corollary dat...
A class to hold a single meeting object.
static preparedQuery($sql, $params=array(), $fetchKeyPair=false)
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statement...
static GetOneUser (   $in_id_bigint)
static

Given an ID for a user, it returns one instance.

This will return one c_comdef_user object, with the parent this server (Not a c_comdef_users object).

Returns
a new c_comdef_user object.Null if it failed.
Parameters
$in_id_bigintThe ID of the user (An integer)

Definition at line 1558 of file c_comdef_server.class.php.

References $ret, GetServer(), and c_comdef_dbsingleton\preparedQuery().

Referenced by c_comdef_user\DeleteFromDB(), c_comdef_change\Rollback(), c_comdef_service_body\SetEditors(), and c_comdef_user\UpdateToDB().

1560  {
1561  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1562  $ret = null;
1563 
1564  $sql = "SELECT * FROM `".self::GetUserTableName_obj()."` WHERE id_bigint=? LIMIT 1";
1565 
1566  $rows = c_comdef_dbsingleton::preparedQuery($sql, array ( $in_id_bigint ));
1567  if (is_array($rows) && count($rows)) {
1568  foreach ($rows as $row) {
1569  $ret = new c_comdef_user(
1571  $row['id_bigint'],
1572  $row['user_level_tinyint'],
1573  $row['email_address_string'],
1574  $row['login_string'],
1575  $row['password_string'],
1576  $row['lang_enum'],
1577  $row['name_string'],
1578  $row['description_string'],
1579  $row['owner_id_bigint'],
1580  $row['last_access_datetime']
1581  );
1582  }
1583  }
1584 
1585  return $ret;
1586  }
This class handles BMLT users. One instance is created for each user on the server.
$ret
Definition: contact.php:226
static preparedQuery($sql, $params=array(), $fetchKeyPair=false)
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statement...
static GetServer ( )
static
static GetServerLangs ( )
static

Get the local readable string for the server languages.

Returns
a reference to the array of strings, containing the server languages in human-readable, local form.

Definition at line 1110 of file c_comdef_server.class.php.

Referenced by GetServerInfo().

1111  {
1112  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1113  return self::GetServer()->_server_lang_names;
1114  }
static GetServerUsersObj ( )
static

Get the object list for the server's registered users.

Returns
a reference to the internal c_comdef_users object.

Definition at line 1126 of file c_comdef_server.class.php.

1127  {
1128  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1129  return self::GetServer()->_users_obj;
1130  }
static GetServiceBodiesTableName_obj ( )
static

Simply returns the name of the service bodies table.

Returns
A string, containing the name of the table.

Definition at line 1079 of file c_comdef_server.class.php.

Referenced by NAWSImport\throwIfDuplicateServiceBodies().

1080  {
1081  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1082  return self::$server_instance->_service_bodies_table_name;
1083  }
GetServiceBodyArray ( )

Simply returns a reference to the contained Service Body array.

Returns
A reference to an array of c_comdef_service_body objects.

Definition at line 521 of file c_comdef_server.class.php.

522  {
523  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
525  }
$_service_obj_array
This contains the actual Service Body objects as a simple array.
GetServiceBodyArrayHierarchical ( )

Returns the Service Body objects in a nested, hierarchical array, with "parents" containing "children.".

Returns
A nested associative array of references to c_comdef_service_body objects.

Definition at line 535 of file c_comdef_server.class.php.

536  {
537  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
538  $ret_array = $this->GetNestedServiceBodyArray(0);
539  return $ret_array;
540  }
GetNestedServiceBodyArray($in_id=0)
This reads the Service bodies in hierarchical order, and returns them in a multi-dimensional array th...
static GetServiceBodyByIDObj (   $in_service_body_id_bigint)
static

Get the object for a single service body, given an ID.

Returns
a reference to the internal c_comdef_service_body object for the service body. Null if not found.
Parameters
$in_service_body_id_bigintAn integer, containing the service body ID.

Definition at line 1333 of file c_comdef_server.class.php.

References $ret, and $server.

Referenced by c_comdef_meetings\CreateMeetingObjects(), c_comdef_service_body\DeleteFromDB(), c_comdef_admin_xml_handler\get_changes_as_csv(), c_comdef_admin_xml_handler\get_deleted_meetings_as_csv(), GetChanges(), c_comdef_service_body\GetOwner2IDObject(), c_comdef_service_body\GetOwnerIDObject(), c_comdef_meeting\GetServiceBodyObj(), c_comdef_admin_xml_handler\process_changes(), c_comdef_admin_xml_handler\process_deleted_meetings(), c_comdef_service_body\UpdateToDB(), c_comdef_service_body\UserCanEdit(), c_comdef_meeting\UserCanEdit(), c_comdef_service_body\UserCanEditMeetings(), c_comdef_service_body\UserCanObserve(), and c_comdef_meeting\UserCanObserve().

1335  {
1336  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1337  $ret = null;
1338  $server = self::GetServer();
1339  if ($server instanceof c_comdef_server) {
1340  $array_obj = $server->GetServiceBodyArray();
1341  if (is_array($array_obj) && count($array_obj)) {
1342  foreach ($array_obj as &$sb) {
1343  if ($sb instanceof c_comdef_service_body) {
1344  $id = $sb->GetID();
1345  if (intval($in_service_body_id_bigint) == intval($id)) {
1346  $ret = $sb;
1347  }
1348  }
1349  }
1350  }
1351  }
1352 
1353  return $ret;
1354  }
A Class for Service Body Objects.
$ret
Definition: contact.php:226
This class is the main server class. It instantiates a PDO database object, and is the starting point...
static GetServiceBodyHierarchyIDs (   $in_service_body_id_bigint)
static

Return the IDs of an entire Service body hierarchy.

Returns
an array of integers. These are the Service body IDs.
Parameters
$in_service_body_id_bigintAn integer, containing the service body ID.

Definition at line 1362 of file c_comdef_server.class.php.

References $ret, and $server.

Referenced by CSVHandleNawsDump().

1364  {
1365  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1366  $ret = array();
1367  $server = self::GetServer();
1368  if ($server instanceof c_comdef_server) {
1369  $array_obj = $server->GetServiceBodyArray();
1370  if (is_array($array_obj) && count($array_obj)) {
1371  foreach ($array_obj as &$sb) {
1372  if ($sb instanceof c_comdef_service_body) {
1373  $id = $sb->GetID();
1374  $parent_id = $sb->GetOwnerID();
1375  if (intval($in_service_body_id_bigint) == intval($id)) {
1376  array_push($ret, $id);
1377  } elseif (intval($in_service_body_id_bigint) == intval($parent_id)) {
1378  $ret = array_merge($ret, self::GetServiceBodyHierarchyIDs($id));
1379  }
1380  }
1381  }
1382  }
1383  }
1384 
1385  return $ret;
1386  }
A Class for Service Body Objects.
$ret
Definition: contact.php:226
This class is the main server class. It instantiates a PDO database object, and is the starting point...
GetServiceIDs ( )

Simply returns the stored service IDs.

Returns
a reference to the array containing all the Service entity IDs. NOTE: These are IDs that appear in meetings, and may not reflect those in the Server.

Definition at line 663 of file c_comdef_server.class.php.

664  {
665  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
666  return $this->_service_ids;
667  }
$_service_ids
This has the IDs of all the Service entities that "own" meetings on the server.
static GetSquareForRadius (   $in_radius,
  $in_long_in_degrees,
  $in_lat_in_degrees 
)
static

This is a static utility function that takes a specified radius and center point and calculates a square, in longitude and latitude points, that encompasses that radius. This greatly narrows the scope of the search, so the radius calculation will simply eliminate any meetings that are "in the corners.".

Returns
an array of floating-point values, in the following form:
  • ['east'] = longitude of the Eastern side of the rectangle
  • ['west'] = longitude of the Western side of the rectangle
  • ['north'] = latitude of the Northern side of the rectangle
  • ['south'] = latitude of the Southern side of the rectangle
Parameters
$in_radiusA positive floating-point number. The radius, in kilometers.
$in_long_in_degreesThe longitude needs to be specified in degrees.
$in_lat_in_degreesThe latitude needs to be specified in degrees.

Definition at line 2364 of file c_comdef_server.class.php.

Referenced by c_comdef_meeting_search_manager\GetSquareForRadius().

2368  {
2369  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
2370  $loc = null;
2371  $vert_radius = $in_radius / 111.000;
2372  $horiz_radius = $in_radius / (111.321 * cos(deg2rad($in_lat_in_degrees)));
2373 
2374  $loc['east'] = $in_long_in_degrees - $horiz_radius;
2375  $loc['west'] = $in_long_in_degrees + $horiz_radius;
2376  $loc['north'] = $in_lat_in_degrees + $vert_radius;
2377  $loc['south'] = $in_lat_in_degrees - $vert_radius;
2378 
2379  return $loc;
2380  }
GetUsedFormatIDs ( )

Return the shared IDs of the formats actually used by the contained meetings. This can be used to avoid showing format codes that are not relevant to the database.

Returns
an array of Int, with the ones most frequently represented at the top.

Definition at line 646 of file c_comdef_server.class.php.

647  {
648  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
649  if (!$this->_used_format_ids) {
650  $this->ReadFormats();
651  }
652 
654  }
$_used_format_ids
This is the container for the loaded formats that are actually used in the meetings. Each element is a format shared ID.
ReadFormats()
This is an internal function that reads in all of the stored formats, in all provided languages...
GetUsedFormatsArray ( )

Simply returns an array of the format objects used by the meetings (no unused ones).

Returns
An array of c_comdef_format objects.

Definition at line 619 of file c_comdef_server.class.php.

References $ret.

620  {
621  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
622  $ret = null;
623  $formats_array = $this->GetFormatsArray();
624  $all_formats = $formats_array[$this->GetLocalLang()];
625 
626  if (is_array($all_formats) && count($all_formats) && is_array($this->GetUsedFormatIDs()) && count($this->GetUsedFormatIDs())) {
627  $ret = array();
628 
629  foreach ($all_formats as $format) {
630  if (in_array($format->GetSharedID(), $this->GetUsedFormatIDs())) {
631  $ret[$format->GetSharedID()] = $format;
632  }
633  }
634  }
635 
636  return $ret;
637  }
GetFormatsArray()
Simply returns an array of the format objects.
$ret
Definition: contact.php:226
GetUsedFormatIDs()
Return the shared IDs of the formats actually used by the contained meetings. This can be used to avo...
GetLocalLang()
Returns the Server Local Language.
static GetUserByIDObj (   $in_user_id_bigint)
static

Get the object for a single user, given an ID.

Returns
a reference to the internal c_comdef_user object for the user. Null if not found.
Parameters
$in_user_id_bigintAn integer, containing the user ID.

Definition at line 1138 of file c_comdef_server.class.php.

References $ret.

Referenced by c_comdef_admin_xml_handler\get_changes_as_csv(), c_comdef_admin_xml_handler\get_deleted_meetings_as_csv(), GetChanges(), c_comdef_service_body\GetEditorsAsObjects(), and c_comdef_service_body\GetPrincipalUserObj().

1140  {
1141  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1142  $ret = null;
1143 
1144  if (0 < intval($in_user_id_bigint)) {
1145  $users_obj = self::GetServer()->_users_obj;
1146 
1147  if ($users_obj instanceof c_comdef_users) {
1148  $ret = $users_obj->GetUserByID($in_user_id_bigint);
1149  }
1150  }
1151 
1152  return $ret;
1153  }
$ret
Definition: contact.php:226
A class to hold a collection of c_comdef_users objects.
static GetUserByLogin (   $in_login)
static

Given a login, looks up the user, and returns a reference to that user object.

Returns
a reference to a c_comdef_user object. Null if none.
Parameters
$in_loginA string. The login ID.

Definition at line 1162 of file c_comdef_server.class.php.

References $ret.

1164  {
1165  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1166  $ret = null;
1167 
1168  $users_obj = self::GetServer()->_users_obj;
1169 
1170  if ($users_obj instanceof c_comdef_users) {
1171  $ret = $users_obj->GetUserByLogin($in_login);
1172  }
1173 
1174  return $ret;
1175  }
$ret
Definition: contact.php:226
A class to hold a collection of c_comdef_users objects.
static GetUserByLoginCredentials (   $in_login,
  $in_password 
)
static

Given a login and password, looks up the user, and returns a reference to that user object.

Returns
a reference to a c_comdef_user object. Null if none.
Parameters
$in_loginA string. The login ID.
$in_passwordA string. the ENCRYPTED password for the user.

Definition at line 1184 of file c_comdef_server.class.php.

References $ret.

1187  {
1188  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1189  $ret = null;
1190 
1191  $users_obj = self::GetServer()->_users_obj;
1192 
1193  if ($users_obj instanceof c_comdef_users) {
1194  $ret = $users_obj->GetUserByLoginCredentials($in_login, $in_password);
1195  }
1196 
1197  return $ret;
1198  }
$ret
Definition: contact.php:226
A class to hold a collection of c_comdef_users objects.
static GetUsersByLevelObj (   $in_user_level_bigint,
  $in_or_higher = false,
  $in_include_disabled = false 
)
static

Get the objects for all users of a certain user level.

Returns
an associative array, with references to the c_comdef_user objects for the relevant users as values, and the user IDs as keys. Null if not found.
Parameters
$in_user_level_bigintAn integer, containing the user level.
$in_or_higherA Boolean. Set this to true to get all users of the given level or higher (numerically lower). Default is false, so only users of the exact level are given.
$in_include_disabledA Boolean. Set this to true to allow disabled users to be included.

Definition at line 1304 of file c_comdef_server.class.php.

References _USER_LEVEL_DISABLED.

1308  {
1309  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1310  $ret_array = null;
1311 
1312  $users_obj = self::GetServer()->_users_obj;
1313 
1314  if ($users_obj instanceof c_comdef_users) {
1315  $user_array = $users_obj->GetUsersArray();
1316 
1317  foreach ($user_array as &$user_obj) {
1318  if (($user_obj->GetUserLevel() > 0) && ($in_include_disabled || ($user_obj->GetUserLevel() != _USER_LEVEL_DISABLED)) && (($user_obj->GetUserLevel() == $in_user_level_bigint) || ($in_or_higher && ($user_obj->GetUserLevel() < $in_user_level_bigint)))) {
1319  $ret_array[$user_obj->GetID()] = $user_obj;
1320  }
1321  }
1322  }
1323 
1324  return $ret_array;
1325  }
const _USER_LEVEL_DISABLED
A class to hold a collection of c_comdef_users objects.
static GetUserServiceBodies (   $in_user_id = null)
static

Return all the Service Bodies this user is authorized with.

Returns
an associative array. The key is the ID of the Service Body, and the value is:
  • 'principal' If the user is a principal admin
  • 'editor' If the user is a secondary editor. Returns null if the user is not cleared for any Service Body.
Parameters
$in_user_idThe ID of the user. If not provided, the current user is checked.

Definition at line 2720 of file c_comdef_server.class.php.

References $ret, and GetServer().

Referenced by c_comdef_admin_ajax_handler\HandleMeetingWorldIDsUpdate().

2722  {
2723  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
2724  $ret = null;
2725 
2726  if (!$in_user_id) {
2727  $in_user_id = self::GetCurrentUserObj()->GetID();
2728  }
2729 
2730  $service_bodies = c_comdef_server::GetServer()->GetServiceBodyArray();
2731 
2732  if (is_array($service_bodies) && count($service_bodies)) {
2733  foreach ($service_bodies as &$service_body) {
2734  $is_editor = null;
2735  if ($service_body instanceof c_comdef_service_body) {
2736  $editors = $service_body->GetEditors();
2737 
2738  if (is_array($editors) && count($editors)) {
2739  if (in_array($in_user_id, $editors)) {
2740  $is_editor = 'editor';
2741  }
2742  }
2743 
2744  if ($service_body->GetPrincipalUserID() == $in_user_id) {
2745  $is_editor = 'principal';
2746  }
2747  }
2748 
2749  if ($is_editor) {
2750  $ret[$service_body->GetID()] = $is_editor;
2751  }
2752  }
2753  }
2754 
2755  return $ret;
2756  }
A Class for Service Body Objects.
$ret
Definition: contact.php:226
static GetUserTableName_obj ( )
static

Simply returns the name of the user table.

Returns
A string, containing the name of the table.

Definition at line 1091 of file c_comdef_server.class.php.

1092  {
1093  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1094  return self::$server_instance->_user_table_name;
1095  }
static HuntForRadius (   $in_search_result_count,
  $in_long_in_degrees,
  $in_lat_in_degrees,
  $in_weekday_tinyint_array 
)
static

Find the smallest radius that contains at least the given number of meetings. The way this works is that the center is set, and the optimal radius is selected in kilometers to deliver that many meetings. The radius starts at 25 Km (about 10 miles), and goes up or down in 5Km "clicks." Under 5Km, it reduces to 0.5Km "clicks." It will not go out more than 100Km.

When it passes the threshold for the number of meetings in the square, the radius is selected, and the _search_radius is set to the number of Kilometers.

We are not looking for an exact meeting count. It should select the first radius that contains AT LEAST the number of meetings requested.

If not enough meetings are found, the radius ends up at 0.

Returns
a radius, in Km, for a result. Null if none found.
Exceptions
anexception if the SQL query fails.
Parameters
$in_search_result_countA positive integer. It specifies the number of meetings to find.
$in_long_in_degreesThe longitude needs to be specified in degrees.
$in_lat_in_degreesThe latitude needs to be specified in degrees.
$in_weekday_tinyint_arrayAn array of weekdays in which to filter for.

Definition at line 2479 of file c_comdef_server.class.php.

References $ret, GetServer(), MySQLGetRadiusSQLClause(), and c_comdef_dbsingleton\preparedQuery().

Referenced by GetGeocodeFromString(), and c_comdef_meeting_search_manager\GetSquareForRadius().

2484  {
2485  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
2486  $ret = null;
2487 
2488  $localized_strings = self::GetLocalStrings();
2489  $sql1 = "SELECT COUNT(*) FROM `".self::GetMeetingTableName_obj()."_main` WHERE";
2490  $sql3 = '';
2491 
2492  if (is_array($in_weekday_tinyint_array) && count($in_weekday_tinyint_array)) {
2493  $sql1 .= " (";
2494 
2495  $first = true;
2496  foreach ($in_weekday_tinyint_array as $weekday) {
2497  $weekday = intval($weekday);
2498  $sql_x = "";
2499  if ($weekday < 0) {
2500  $weekday = abs($weekday);
2501  $sql_x = " NOT ";
2502 
2503  if (!$first) {
2504  $sql_x = " AND $sql_x";
2505  }
2506 
2507  $first = true; // This makes the OR get skipped.
2508  }
2509 
2510  if (!$first) {
2511  $sql_x .= " OR ";
2512  } else {
2513  $first = false;
2514  }
2515 
2516  $sql1 .= "$sql_x(".self::GetMeetingTableName_obj()."_main.weekday_tinyint=".strval($weekday - 1).")";
2517  }
2518  $sql1 .= ") AND (";
2519  $sql3 = ")";
2520  }
2521 
2522  $ranges = $localized_strings['comdef_map_radius_ranges'];
2523  $current_radius = 0.0;
2524 
2525  foreach ($ranges as $radius) {
2526  $radius = floatval($radius) * (($localized_strings['dist_units'] == 'mi') ? 1.609344 : 1.0);
2527  $current_radius = $radius;
2528  $arr = array ();
2529 
2530  $show_published_only = (c_comdef_server::GetServer()->GetCurrentUserObj() == null); // We only show published meetings to regular users.
2531  $arr = array ( $in_lat_in_degrees, $in_long_in_degrees, $radius );
2532 
2533  if ($show_published_only) {
2534  $arr[] = true;
2535  }
2536 
2537  $sql = c_comdef_server::MySQLGetRadiusSQLClause($show_published_only, $in_weekday_tinyint_array);
2538 
2539  try {
2540  $rows = c_comdef_dbsingleton::preparedQuery($sql, $arr);
2541  } catch (Exception $e) {
2542  break;
2543  }
2544 
2545  $count = 0;
2546 
2547  if (is_array($rows) && count($rows)) {
2548  $count = intval($rows[0]["count(*)"]);
2549 
2550  if ($count > $in_search_result_count) {
2551  break;
2552  }
2553  }
2554  }
2555  return $current_radius;
2556  }
$ret
Definition: contact.php:226
static preparedQuery($sql, $params=array(), $fetchKeyPair=false)
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statement...
static MySQLGetRadiusSQLClause($in_published=false, $in_weekday=null)
Return SQL for a radius circle around the given coordinates. This is a special function for MySQL...
Initialize ( )

This reads the Formats, Meeting and Service Entity IDs.

Definition at line 268 of file c_comdef_server.class.php.

269  {
270  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
271  $this->ReadUsers();
272  $this->ReadServiceBodies();
273  $this->ReadServiceIDs();
274  }
ReadServiceBodies()
This is an internal function that reads in all of the stored service bodies and instantiates local ob...
ReadServiceIDs()
This gathers the IDs of all the Service bodies that appear in meeting records. It is NOT a dump of th...
ReadUsers()
This is an internal function that reads in all of the stored users and instantiates local objects for...
static IsFormatKeyUnique (   $in_key_string,
  $in_lang_enum 
)
static

Given an ID and a language for a format, as well as a code, returns true if the code does NOT appear in the DB.

Returns
true, if the format key is unique for the language.
Exceptions
anexception if the SQL query fails.
Parameters
$in_key_stringA string. The key for which to search.
$in_lang_enumThe language for the format.

Definition at line 1397 of file c_comdef_server.class.php.

References c_comdef_dbsingleton\preparedQuery().

1400  {
1401  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1402  $sql = "SELECT * FROM `".self::GetFormatTableName_obj()."` WHERE key_string=? AND lang_enum=?";
1403 
1404  $rows = c_comdef_dbsingleton::preparedQuery($sql, array ( $in_key_string, $in_lang_enum ));
1405  if (is_array($rows) && count($rows)) {
1406  return false;
1407  }
1408 
1409  return true;
1410  }
static preparedQuery($sql, $params=array(), $fetchKeyPair=false)
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statement...
static IsUserServerAdmin (   $in_user_obj = null,
  $in_is_ajax = false 
)
static

Find out if the user is a server admin.

Returns
a boolean. True if the user is a server admin.
Parameters
$in_user_objA reference to a c_comdef_user object instance. If null, the current user will be checked.
$in_is_ajaxIf it's an AJAX handler, we don't regenerate the session. Some browsers seem antsy about that.

Definition at line 1233 of file c_comdef_server.class.php.

References $ret, and _USER_LEVEL_SERVER_ADMIN.

Referenced by c_comdef_admin_ajax_handler\DeleteMeetingChanges(), c_comdef_admin_ajax_handler\DeleteServiceBodyChanges(), c_comdef_admin_ajax_handler\DeleteUserChanges(), c_comdef_admin_ajax_handler\HandleDeleteFormat(), c_comdef_admin_ajax_handler\HandleDeleteServiceBody(), c_comdef_admin_ajax_handler\HandleDeleteUser(), c_comdef_admin_ajax_handler\HandleFormatChange(), c_comdef_admin_ajax_handler\HandleMeetingWorldIDsUpdate(), c_comdef_admin_ajax_handler\HandleNAWSImport(), c_comdef_admin_ajax_handler\HandleServiceBodyCreate(), c_comdef_admin_ajax_handler\HandleUserChange(), c_comdef_admin_ajax_handler\HandleUserCreate(), c_comdef_format\UserCanEdit(), c_comdef_user\UserCanEdit(), c_comdef_service_body\UserCanEdit(), and c_comdef_meeting\UserCanEdit().

1236  {
1237  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1238  $ret = false;
1239 
1240  if (!($in_user_obj instanceof c_comdef_user)) {
1241  $in_user_obj = self::GetCurrentUserObj($in_is_ajax);
1242  }
1243 
1244  if ($in_user_obj instanceof c_comdef_user) {
1245  $ret = ($in_user_obj->GetUserLevel() == _USER_LEVEL_SERVER_ADMIN);
1246  }
1247 
1248  return $ret;
1249  }
This class handles BMLT users. One instance is created for each user on the server.
$ret
Definition: contact.php:226
const _USER_LEVEL_SERVER_ADMIN
static IsUserServiceBodyAdmin (   $in_user_obj = null,
  $in_is_ajax = false 
)
static

Find out if the user is a service body admin.

Returns
a boolean. True if the user is a service body admin.
Parameters
$in_user_objA reference to a c_comdef_user object instance. If null, the current user will be checked.
$in_is_ajaxIf it's an AJAX handler, we don't regenerate the session. Some browsers seem antsy about that.

Definition at line 1258 of file c_comdef_server.class.php.

References $ret, and _USER_LEVEL_SERVICE_BODY_ADMIN.

Referenced by c_comdef_admin_ajax_handler\HandleMeetingWorldIDsUpdate(), c_comdef_admin_ajax_handler\HandleUserChange(), and c_comdef_user\UserCanEdit().

1261  {
1262  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1263  $ret = false;
1264 
1265  if (!($in_user_obj instanceof c_comdef_user)) {
1266  $in_user_obj = self::GetCurrentUserObj($in_is_ajax);
1267  }
1268 
1269  if ($in_user_obj instanceof c_comdef_user) {
1270  $ret = ($in_user_obj->GetUserLevel() == _USER_LEVEL_SERVICE_BODY_ADMIN);
1271  }
1272 
1273  return $ret;
1274  }
This class handles BMLT users. One instance is created for each user on the server.
$ret
Definition: contact.php:226
const _USER_LEVEL_SERVICE_BODY_ADMIN
static MakeServer ( )
static

This is the factory for the server instantiation. It makes sure that only one instance exists.

Returns
the Server instance. Either a new one, or the existing one.

Definition at line 92 of file c_comdef_server.class.php.

Referenced by c_comdef_admin_ajax_handler\__construct(), c_comdef_admin_main_console\__construct(), c_comdef_meeting_search_manager\__construct(), bmlt_populate_format_dictionary(), c_comdef_admin_bar(), dropEverything(), and NAWSImport\import().

93  {
94  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
95  if (!(self::$server_instance instanceof c_comdef_server)) {
96  self::$server_instance = new c_comdef_server;
97  }
98 
99  return self::$server_instance;
100  }
This class is the main server class. It instantiates a PDO database object, and is the starting point...
static MySQLGetRadiusSQLClause (   $in_published = false,
  $in_weekday = null 
)
static

Return SQL for a radius circle around the given coordinates. This is a special function for MySQL.

Returns
a string, containing the SQL clause. This will be a prepared statement, with variable slots for: latitude of the centerpoint, in degrees (floating-point) longitude of the centerpoint, in degrees (floating point) radius, in kilometers (floating point) if $in_published is TRUE, then there will be an additional placeholder for published (0 not published, 1, published) There will be an additional 'distance' slot in the response, with the distance from the centerpoint. A limit. This should be 10 more than what we are looking for. This speeds up the query.
Parameters
$in_publishedIf TRUE, then we will have a slot for published status.
$in_weekdayThis is an array of weekdays we are looking for (integers).

Definition at line 2396 of file c_comdef_server.class.php.

Referenced by HuntForRadius().

2399  {
2400  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
2401  // I adapted this from here: http://www.plumislandmedia.net/mysql/haversine-mysql-nearest-loc/ Thanks, Ollie!
2402  $sql = "SELECT COUNT(*) FROM ( SELECT *,
2403  p.distance_unit
2404  * DEGREES(ACOS(COS(RADIANS(p.latpoint))
2405  * COS(RADIANS(z.latitude))
2406  * COS(RADIANS(p.longpoint) - RADIANS(z.longitude))
2407  + SIN(RADIANS(p.latpoint))
2408  * SIN(RADIANS(z.latitude)))) AS distance
2409  FROM `".self::GetMeetingTableName_obj()."_main` AS z
2410  JOIN ( /* these are the query parameters */
2411  SELECT ? AS latpoint, ? AS longpoint,
2412  ? AS radius, 111.045 AS distance_unit
2413  ) AS p ON 1=1
2414  WHERE z.latitude
2415  BETWEEN p.latpoint - (p.radius / p.distance_unit)
2416  AND p.latpoint + (p.radius / p.distance_unit)
2417  AND z.longitude
2418  BETWEEN p.longpoint - (p.radius / (p.distance_unit * COS(RADIANS(p.latpoint))))
2419  AND p.longpoint + (p.radius / (p.distance_unit * COS(RADIANS(p.latpoint))))
2420  ) AS d
2421  WHERE (distance <= radius)";
2422 
2423  if ($in_published) {
2424  $sql .= " AND (published = ?)";
2425  }
2426 
2427  // Belt and suspenders...
2428  if (isset($in_weekday) && (null != $in_weekday) && is_array($in_weekday) && count($in_weekday)) {
2429  $wd_yes_array = array();
2430  $wd_no_array = array();
2431 
2432  $sql .= " AND (";
2433  foreach ($in_weekday as $weekday) {
2434  if (0 > intval($weekday)) {
2435  $wd_no_array[] = "(weekday_tinyInt <> ".abs(intval($weekday)).")";
2436  } else {
2437  $wd_yes_array[] = "(weekday_tinyInt = ".intval($weekday).")";
2438  }
2439  }
2440 
2441  if (count($wd_yes_array)) {
2442  $sql .= implode(" OR ", $wd_yes_array);
2443  }
2444 
2445  if (count($wd_no_array)) {
2446  $sql .= implode(" AND ", $wd_no_array);
2447  }
2448 
2449  $sql .= ")";
2450  }
2451 
2452  $sql .= "\nORDER BY distance;";
2453 
2454  return $sql;
2455  }
static ParseMeetingsByFormats (   $in_meetings,
  $in_formats 
)
staticprivate

This is an alternative to the MySQL REGEXP test. It will go through all the meetings returned by a broad query, and remove any that do not contain all of the given formats.

Returns
the passed-in c_comdef_meetings object, containing the remaining meetings. Null if it failed.
Parameters
$in_meetingsThe result of c_comdef_server::GetMeetingsFromSQL()
$in_formatsAn array of integers. These are formats. The filtering will be an "AND" filtering, so qualified meetings must have all of the given formats.

Definition at line 2123 of file c_comdef_server.class.php.

2126  {
2127  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
2128  $meetings = $in_meetings->GetMeetingObjects();
2129  foreach ($meetings as &$meeting) {
2130  $data = $meeting->GetMeetingData();
2131  $formats = $data['formats'];
2132  $found = 0;
2133  foreach ($formats as $key => $value) {
2134  if (false !== array_search(intval($key), $in_formats)) {
2135  $found++;
2136  }
2137  }
2138 
2139  // If we didn't find them all, we nuke the meeting.
2140  if ($found != count($in_formats)) {
2141  $in_meetings->RemoveMeeting($meeting->GetID());
2142  }
2143  }
2144 
2145  return ( $in_meetings );
2146  }
ReadFormats ( )

This is an internal function that reads in all of the stored formats, in all provided languages, and instantiates local objects for them. Access them with the GetFormatsObj() member function afterwards.

Read in all the formats, and instantiate an array of objects.

We aren't allowed to have two formats for the same language, and the same shared ID.

We use a combination of the language and the shared ID as the keys, which allows us to sort better.

Create our internal container, and give it the array.

Definition at line 307 of file c_comdef_server.class.php.

References c_comdef_dbsingleton\preparedQuery().

308  {
309  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
310  $this->_used_format_ids = array ();
311  $sql = "SELECT * FROM `".self::GetFormatTableName_obj()."` ORDER BY shared_id_bigint, lang_enum";
312 
314 
315  if (is_array($rows) && count($rows)) {
316  $obj_array = array();
317  /// Read in all the formats, and instantiate an array of objects.
318  foreach ($rows as $rs) {
319  /// We aren't allowed to have two formats for the same language, and the same shared ID.
320  if (!isset($rs['lang_enum']) || !isset($obj_array[$rs['lang_enum']]) || !isset($obj_array[$rs['lang_enum']][$rs['shared_id_bigint']]) || !is_object($obj_array[$rs['lang_enum']][$rs['shared_id_bigint']])) {
321  /// We use a combination of the language and the shared ID as the keys, which allows us to sort better.
322  $obj_array[$rs['lang_enum']][$rs['shared_id_bigint']] = new c_comdef_format(
323  $this,
324  $rs['shared_id_bigint'],
325  $rs['format_type_enum'],
326  $rs['key_string'],
327  $rs['icon_blob'],
328  $rs['worldid_mixed'],
329  $rs['lang_enum'],
330  $rs['name_string'],
331  $rs['description_string']
332  );
333  }
334  }
335 
336  /// Create our internal container, and give it the array.
337  $this->_formats_obj = new c_comdef_formats($this, $obj_array);
338 
339  // Now that we have all our formats, we quickly read in the formats from all the meetings, and filter out just the ones that are actually used.
340  $sql = "SELECT `formats` FROM `".self::GetMeetingTableName_obj()."_main`";
341 
343 
344  if (is_array($rows) && count($rows)) {
345  $format_codes = array();
346  // Read each of the format CSV lists, split the list, and then check each one in our tracker.
347  foreach ($rows as $row) {
348  $codes = explode(',', $row['formats']);
349  foreach ($codes as $code) {
350  $index = "ID-$code"; // We do this, because some PHP processors refuse to allow pure ints to be associative properties.
351  if (!isset($format_codes[$index])) {
352  $format_codes[$index] = 1;
353  } else {
354  $format_codes[$index] = intval($format_codes[$index]) + 1; // Do it this way, just in case the PHP interpreter gets funny about interpreting as int.
355  }
356  }
357  }
358 
359  // At this point format_codes is an associative array with only the formats actually used. The format code is in the key. We sort them so that the most frequent ones are at the beginning.
360  // We go through that, and extract our codes.
361 
362  arsort($format_codes);
363  $format_codes = array_keys($format_codes);
364 
365  foreach ($format_codes as $format_id) {
366  $format_id_num = intval(preg_replace("|ID\-(.*)|", "$1", $format_id));
367  if ($format_id_num) {
368  array_push($this->_used_format_ids, $format_id_num);
369  }
370  }
371  }
372  }
373  }
static preparedQuery($sql, $params=array(), $fetchKeyPair=false)
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statement...
A Class for Format Codes.
Include the format class.
ReadServiceBodies ( )

This is an internal function that reads in all of the stored service bodies and instantiates local objects for them. Access them with the GetServiceObj() member function afterwards.

Read in all the service bodies, and instantiate an array of objects.

Definition at line 433 of file c_comdef_server.class.php.

References c_comdef_dbsingleton\preparedQuery().

434  {
435  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
436  $this->_service_obj_array = array();
437 
438  $sql = "SELECT * FROM `".self::GetServiceBodiesTableName_obj()."` ORDER BY id_bigint";
439 
441 
442  if (is_array($rows) && count($rows)) {
443  /// Read in all the service bodies, and instantiate an array of objects.
444  foreach ($rows as $row) {
445  array_push($this->_service_obj_array, new c_comdef_service_body(
446  $this,
447  $row['id_bigint'],
448  $row['principal_user_bigint'],
449  $row['editors_string'],
450  $row['kml_file_uri_string'],
451  $row['uri_string'],
452  $row['name_string'],
453  $row['description_string'],
454  $row['lang_enum'],
455  $row['worldid_mixed'],
456  $row['sb_type'],
457  $row['sb_owner'],
458  $row['sb_owner_2'],
459  $row['sb_meeting_email']
460  ));
461  }
462 
463  // What we do here, is look for orphans, and assign them a parent ID of 0.
464  for ($c = 0; $c < count($this->_service_obj_array); $c++) {
465  $parent_id = $this->_service_obj_array[$c]->GetOwnerID();
466  $found = false;
467  for ($i = 0; $i < count($this->_service_obj_array); $i++) {
468  $id = $this->_service_obj_array[$i]->GetID();
469  if ($id == $parent_id) {
470  $found = true;
471  break;
472  }
473  }
474 
475  if (!$found) {
476  $this->_service_obj_array[$c]->SetOwnerID(0);
477  }
478  }
479  }
480  }
A Class for Service Body Objects.
static preparedQuery($sql, $params=array(), $fetchKeyPair=false)
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statement...
ReadServiceIDs ( )

This gathers the IDs of all the Service bodies that appear in meeting records. It is NOT a dump of the Service Bodies table.

Definition at line 487 of file c_comdef_server.class.php.

References c_comdef_dbsingleton\preparedQuery().

488  {
489  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
490  $sql = "SELECT service_body_bigint FROM `".self::GetMeetingTableName_obj()."_main` ORDER BY service_body_bigint";
491 
493 
494  // Just makes sure that old allocations are explicitly gone.
495  $this->_service_ids = null;
496  $this->_service_ids = array();
497 
498  if (is_array($rows) && count($rows)) {
499  foreach ($rows as $rs) {
500  $key = $rs['service_body_bigint'];
501  $value = $key;
502  $obj = self::GetServiceBodyByIDObj($key);
503  if ($obj instanceof c_comdef_service_body) {
504  $name = trim($obj->GetLocalName());
505  if ($name) {
506  $key = $name;
507  }
508  }
509  $this->_service_ids[$key] = $value;
510  }
511  }
512  }
A Class for Service Body Objects.
static preparedQuery($sql, $params=array(), $fetchKeyPair=false)
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statement...
ReadUsers ( )

This is an internal function that reads in all of the stored users and instantiates local objects for them. Access them with the GetUsersObj() member function afterwards.

Read in all the users, and instantiate an array of objects.

Create our internal container, and give it the array.

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

References c_comdef_dbsingleton\preparedQuery().

382  {
383  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
384  // First, we make sure we explicitly delete any old ones.
385 
386  if ($this->_users_obj instanceof c_comdef_users) {
387  $ar = $this->_users_obj->GetUsersArray();
388 
389  foreach ($ar as &$u) {
390  $u = null;
391  }
392 
393  $this->_users_obj = null;
394  }
395 
396  $sql = "SELECT * FROM `".self::GetUserTableName_obj()."` ORDER BY id_bigint";
397 
399 
400  if (is_array($rows) && count($rows)) {
401  $obj_array = array();
402  /// Read in all the users, and instantiate an array of objects.
403  foreach ($rows as $row) {
404  $time = explode(" ", $row['last_access_datetime']);
405  $t0 = explode("-", $time[0]);
406  $t1 = explode(":", $time[1]);
407  $obj_array[$row['id_bigint']] = new c_comdef_user(
408  $this,
409  $row['id_bigint'],
410  $row['user_level_tinyint'],
411  $row['email_address_string'],
412  $row['login_string'],
413  $row['password_string'],
414  $row['lang_enum'],
415  $row['name_string'],
416  $row['description_string'],
417  $row['owner_id_bigint'],
418  mktime($t1[0], $t1[1], $t1[2], $t0[1], $t0[2], $t0[0])
419  );
420  }
421 
422  /// Create our internal container, and give it the array.
423  $this->_users_obj = new c_comdef_users($this, $obj_array);
424  }
425  }
This class handles BMLT users. One instance is created for each user on the server.
static preparedQuery($sql, $params=array(), $fetchKeyPair=false)
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statement...
A class to hold a collection of c_comdef_users objects.
static ServerLangSortCallback (   $in_lang_a,
  $in_lang_b 
)
static

This is a callback to sort the server languages. The default server language will always be first, and the rest will be sorted alphabetically.

Returns
an integer. -1 if goes before b, 1 if otherwise, 0 if neither.

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

References $ret, and GetServer().

248  {
249  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
250  $server_lang = c_comdef_server::GetServer()->GetLocalLang();
251  $ret = 0;
252 
253  if ($in_lang_a == $server_lang) {
254  $ret = -1;
255  } elseif ($in_lang_b == $server_lang) {
256  $ret = 1;
257  } else {
258  $ret = strncasecmp($in_lang_a, $in_lang_b, 3);
259  }
260 
261  return $ret;
262  }
$ret
Definition: contact.php:226
static SetServer (   $in_server_instance)
static

Sets the server instance.

Definition at line 116 of file c_comdef_server.class.php.

117  {
118  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
119  if ($in_server_instance != self::GetServer()) {
120  if (null !== self::GetServer()) {
121  self::$server_instance = null;
122  }
123 
124  self::$server_instance = $in_server_instance;
125  }
126  }
static TrimChanges (   $in_type,
  $in_id 
)
static

trims the changes for the given item.

Definition at line 920 of file c_comdef_server.class.php.

929  {
930  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
931  include(dirname(__FILE__)."/config/get-config.php");
932 
933  $change_limit = 0;
934 
935  if ($in_type == 'c_comdef_meeting') {
936  $change_limit = $change_depth_for_meetings;
937  }
938 
939  if ($change_limit) {
940  // Get rid of oldest change first.
941  $changes = self::GetChangesFromIDAndType($in_type, $in_id);
942 
943  if ($changes instanceof c_comdef_changes) {
944  $ch_objs = $changes->GetChangesObjects();
945 
946  if (is_array($ch_objs)) {
947  $counted = count($ch_objs);
948 
949  while ($counted-- > $change_limit) {
950  $ch_objs[$counted]->DeleteFromDB();
951  }
952  }
953 
954  $changes = null;
955  }
956  }
957  }
A class to hold a collection of c_comdef_change objects.

Member Data Documentation

$_changes_table_name = null
private

This is the name of the Changes table in the database.

Definition at line 61 of file c_comdef_server.class.php.

$_db_version_table_name = null
private

This is the name of the database version table in the database.

Definition at line 65 of file c_comdef_server.class.php.

$_format_lang_names = null
private

This contains the names of additional languages for which formats are defined, in the main language of the server. It is an associative array, based on the language enums.

Definition at line 79 of file c_comdef_server.class.php.

$_format_table_name = null
private

This is the name of the Formats table in the database.

Definition at line 57 of file c_comdef_server.class.php.

$_formats_obj = null
private

This is the container for the loaded formats.

Definition at line 69 of file c_comdef_server.class.php.

$_meeting_table_name = null
private

This is the name of the Meetings table in the database.

Definition at line 59 of file c_comdef_server.class.php.

$_server_lang_names = null
private

This contains the names of the server languages, in their languages. It is an associative array, based on the language enums.

Definition at line 77 of file c_comdef_server.class.php.

$_server_namespace = null
private

This contains the server namespace, which is used to uniquely identify data from this server. The default is the server URI, with "/CoMDEF" appended.

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

$_service_bodies_table_name = null
private

This is the name of the Service Bodies table in the database.

Definition at line 67 of file c_comdef_server.class.php.

$_service_ids = null
private

This has the IDs of all the Service entities that "own" meetings on the server.

Definition at line 75 of file c_comdef_server.class.php.

$_service_obj_array = null
private

This contains the actual Service Body objects as a simple array.

Definition at line 83 of file c_comdef_server.class.php.

$_used_format_ids = null
private

This is the container for the loaded formats that are actually used in the meetings. Each element is a format shared ID.

Definition at line 71 of file c_comdef_server.class.php.

$_user_table_name = null
private

This is the name of the user table in the database.

Definition at line 63 of file c_comdef_server.class.php.

$_users_obj = null
private

This is the container for the loaded users.

Definition at line 73 of file c_comdef_server.class.php.

$server_instance = null
static

This is the SINGLETON server instance. There can only be one...

Definition at line 52 of file c_comdef_server.class.php.

$server_local_strings = null
static

This contains a cache of the local strings.

Definition at line 54 of file c_comdef_server.class.php.

Referenced by GetLocalStrings().


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