Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Private Member Functions | Private Attributes
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...

List of all members.

Public Member Functions

 __construct ()
 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.
 Initialize ()
 This reads the Formats, Meeting and Service Entity IDs.
 GetLocalLang ()
 Returns the Server Local Language.
 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.
 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.
 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.
 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.
GetServiceBodyArray ()
 Simply returns a reference to the contained Service Body array.
 GetServiceBodyArrayHierarchical ()
 Returns the Service Body objects in a nested, hierarchical array, with "parents" containing "children.".
 GetNestedServiceBodyArray ($in_id=0)
 This reads the Service bodies in hierarchical order, and returns them in a multi-dimensional array that reflects the hierarchy.
 GetFormatsObj ()
 Simply returns a reference to the formats container.
GetServiceIDs ()
 Simply returns the stored service IDs.
GetAllServiceIDs ()
 Simply returns the stored service IDs for ALL Service Bodies.
 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.

Static Public Member Functions

static MakeServer ()
 This is the factory for the server instantiation. It makes sure that only one instance exists.
static GetServer ()
static SetServer ($in_server_instance)
 Sets the server instance.
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.
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.
static GetNewMeetingID ()
 Gets an unused ID from the end of the table and returns it. It also sets that ID into the table AUTO_INCREMENT, so it can't get re-used.
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.
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.
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)
 Creates a new user in the Database.
static TrimChanges ($in_type, $in_id)
 trims the changes for the given item.
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.
static GetNamespace ()
 Simply returns the namespace of this server.
static GetFormatTableName_obj ()
 Simply returns the name of the format table.
static GetMeetingTableName_obj ()
 Simply returns the name of the meetings table.
static GetChangesTableName_obj ()
 Simply returns the name of the changes table.
static GetServiceBodiesTableName_obj ()
 Simply returns the name of the service bodies table.
static GetUserTableName_obj ()
 Simply returns the name of the user table.
static & GetServerLangs ()
 Get the local readable string for the server languages.
static & GetServerUsersObj ()
 Get the object list for the server's registered users.
static & GetUserByIDObj ($in_user_id_bigint)
 Get the object for a single user, given an ID.
static & GetUserByLoginCredentials ($in_login, $in_password)
 Given a login and password, looks up the user, and returns a reference to that user object.
static & GetCurrentUserObj ($in_is_ajax=false)
 Get the current logged-in user, as a c_comdef_user instance.
static IsUserServerAdmin ($in_user_obj=null, $in_is_ajax=false)
 Find out if the user is a server admin.
static GetEncryptedPW ($in_login, $in_password)
 Given a login and password, looks up the user, and returns an encrypted password for that user.
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.
static & GetServiceBodyByIDObj ($in_service_body_id_bigint)
 Get the object for a single service body, given an ID.
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.
static GetOneFormat ($in_id_bigint, $in_lang_enum)
 Given an ID and a language for a format, it returns one instance.
static DoesMeetingExist ($in_id_bigint)
 Given an ID for a meeting, it returns true if the meeting currently exists.
static GetOneMeeting ($in_id_bigint, $test_only=false)
 Given an ID for a meeting, it returns one instance.
static GetOneChange ($in_id_bigint)
 Given an ID for a change, it returns one instance.
static GetOneUser ($in_id_bigint)
 Given an ID for a user, it returns one instance.
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.
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_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.
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.
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).
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).
static getKmPerLonAtLat ($dLatitude)
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.".
static GetRadiusSQL ($in_search_rect_array)
 Return SQL for the given coordinates.
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.
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.
static GetUserServiceBodies ($in_user_id=null)
 Return all the Service Bodies this user is authorized with.

Static Public Attributes

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

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.
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.

Private Attributes

 $_format_table_name = null
 This is the name of the Formats table in the database.
 $_meeting_table_name = null
 This is the name of the Meetings table in the database.
 $_changes_table_name = null
 This is the name of the Changes table in the database.
 $_user_table_name = null
 This is the name of the user table in the database.
 $_service_bodies_table_name = null
 This is the name of the Service Bodies table in the database.
 $_formats_obj = null
 This is the container for the loaded formats.
 $_users_obj = null
 This is the container for the loaded users.
 $_service_ids = null
 This has the IDs of all the Service entities that "own" meetings on the server.
 $_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.
 $_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.
 $_service_obj_array = null
 This contains the actual Service Body objects as a simple array.

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.


Constructor & Destructor Documentation

c_comdef_server::__construct ( )

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.


Member Function Documentation

static c_comdef_server::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_change_typeEnum. The type of change. Can be:
  • 'comdef_change_type_new' - New object
  • 'comdef_change_type_delete' - Deleted the object
  • 'comdef_change_type_change' - Changed existing object
  • 'comdef_change_type_rollback' - Rolled existing object back to a previous version
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)

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

static c_comdef_server::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.
static c_comdef_server::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_typeAn enum string, containing the Service Body type. It can be one of the following:
  • 'GR' Individual NA Group
  • 'AS' Area Service Committee
  • 'RS' Regional Service Committee
  • 'MA' Metro Area
  • 'ZF' Zonal Forum
  • 'WS' World Service Committee
in_sb_ownerAn integer. The ID of the Service Body that "owns" this Service Body.
static c_comdef_server::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 
) [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)
static c_comdef_server::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)

Referenced by DisplayChangedMeetingReports(), DisplayDeletedMeetingReports(), and GetChangedMeetings().

static c_comdef_server::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.
static c_comdef_server::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.
& c_comdef_server::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).
static c_comdef_server::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_typeThe class type for the changes One of these values:
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.

Referenced by GetChanges().

static c_comdef_server::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.
Parameters:
in_o_typeThe class type for the changes One of these values:
in_change_typeThe change type. Can be:
  • 'comdef_change_type_new' - New object
  • 'comdef_change_type_delete' - Deleted the object
  • 'comdef_change_type_change' - Changed existing object
  • 'comdef_change_type_rollback' - Rolled existing object back to a previous version

Referenced by GetDeletedMeetings().

c_comdef_server::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.
static c_comdef_server::GetChangesTableName_obj ( ) [static]

Simply returns the name of the changes table.

Returns:
A string, containing the name of the changes table.
static& c_comdef_server::GetCurrentUserObj ( in_is_ajax = false) [static]
static c_comdef_server::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.
c_comdef_server::GetFormatsObj ( )

Simply returns a reference to the formats container.

Returns:
A reference to the formats container object.
static c_comdef_server::GetFormatTableName_obj ( ) [static]

Simply returns the name of the format table.

Returns:
A string, containing the name of the format table.
static c_comdef_server::getKmPerLonAtLat ( dLatitude) [static]
c_comdef_server::GetLocalLang ( )

Returns the Server Local Language.

Returns:
a string, with the language enum.
static c_comdef_server::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_results_strings' An associative array, with all the various strings used in most displays.
  • '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.

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

Referenced by BuildTime(), c_comdef_admin_bar(), c_comdef_htmlspecialchars(), c_comdef_LoginForm(), c_comdef_change::DescribeChange(), c_comdef_change::DetailedChangeDescription(), DisplayAdvancedSearchDiv(), DisplayChangedMeetingReports(), DisplayDeletedMeetingReports(), DisplayFormatsForEdit(), DisplayMeeting(), DisplayMeetingForEdit(), DisplayMeetingForm(), DisplayMeetingReports(), DisplayMeetingSearchForm(), DisplayNewMeetingForm(), DisplayOneMeeting(), DisplayOneServiceBodyEditor(), DisplayOneUserForEditing(), DisplayPageData(), DisplayReportsDiv(), DisplayResultNav(), DisplaySearchResultsCSV(), DisplaySearchResultsList(), DisplaySearchResultsMap(), DisplayServiceBodyEditor(), DisplaySingleMeeting(), DisplayUserEditor(), c_comdef_meeting::GetAddressDataItemBuilder(), c_comdef_meeting::GetAddressDataItemKeys(), GetChanges(), GetControlPanelHTML(), GetGeocodeFromString(), GetHeaderXHTML(), ReturnAServiceBodyDL(), and SetUpSearch().

static c_comdef_server::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_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_service_body_id_bigint_arrayAn array of integers. Unlike the formats criteria, these do an OR function, as each record only has one Service Body ID field, so each selection broadens the search. If there are no IDs selected, or only NOT IDs have been selected, then all the Service bodies will be searched, with the exception of any that are selected as NOT (Negative value).
in_lang_filter_arrayIf an element of this array is set to a language enum ("en", "es", etc.), it will only return meetings whose 'lang_enum' field is of that value. If the array is null, all languages are searched. If the enum is preceded by a minus sign (-), then the language is filtered against in the search.
in_weekday_tinyint_arrayThe weekday (An array of integer 1-Sunday, 7-Saturday). Optional. If null, all days will be returned. Each day chosen widens the search. If the weekday is negative, then that is specifically filtered against in the search.
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. If a format is given as a negative number, it is a NOT. Make sure that you don't have two versions of the same format code, as nothing will be returned.
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_min_durationThe number of seconds a meeting should last as a minimum.
in_max_durationThe number of seconds a meeting can last, at most.
in_search_rect_arrayAn array of floating-point numbers, representing longitude and latitude for a rectangle. This is used to restrict the search to a certain geographic area. It is an associative array:
  • ['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
in_firstA positive integer. This is for paged results. This is the index (0-based) of the first result to be returned. If $in_num is specified, and this is null, then it is assumed to be 0. If $in_num is null, then this is ignored.
in_numA reference to a positive integer. This is the maximum number of results to return. If null, then there will be limits placed on the query. If less than the maximum are returned, this is adjusted to reflect how many were returned.

NOTE: For non-MySQL and non-Oracle DBs, this may not equal the number of meetings returned in the function result! This is because, for those databases, filtering by format code needs to be done after the actual database query.

This will have the actual value of the number of results in the database query, so you can use this to walk through the database. If you need the actual number of meetings returned, the best way to do this is to do a c_comdef_meetings::GetNumMeetings() function on the returned object.

Parameters:
in_publishedIndicates whether or not to search for published meetings. This only counts if the user is logged in.
  • -1 Search for ONLY unpublished meetings
  • 0 Search for published and unpublished meetings.
  • 1 Search for ONLY published meetings.

Referenced by c_comdef_meeting_search_manager::GetSearchResults_Obj().

static c_comdef_server::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)

Referenced by c_comdef_meeting_search_manager::GetSearchResults_Obj().

static c_comdef_server::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.
static c_comdef_server::GetMeetingsFromSQL ( in_sql,
in_value_array = null 
) [static, private]

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.
static c_comdef_server::GetMeetingTableName_obj ( ) [static]

Simply returns the name of the meetings table.

Returns:
A string, containing the name of the meetings table.
static c_comdef_server::GetNamespace ( ) [static]

Simply returns the namespace of this server.

Returns:
A string, with the namespace. The default is the server URI, with "/CoMDEF" appended.
c_comdef_server::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.
static c_comdef_server::GetNewMeetingID ( ) [static]

Gets an unused ID from the end of the table and returns it. It also sets that ID into the table AUTO_INCREMENT, so it can't get re-used.

Returns:
an integer, containing that ID.

Referenced by c_comdef_meeting::ReduceToArrays().

static c_comdef_server::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)
static c_comdef_server::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.

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

static c_comdef_server::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)

Referenced by c_comdef_change::GetBeforeObject(), GetChanges(), GetDeletedMeetings(), c_comdef_meeting_search_manager::GetSingleMeetingByID(), and c_comdef_change::Rollback().

static c_comdef_server::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)

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

static c_comdef_server::GetRadiusSQL ( in_search_rect_array) [static]

Return SQL for the given coordinates.

Returns:
a string, containing the SQL clause.
Exceptions:
anexception if the SQL query fails.
Parameters:
in_search_rect_arrayAn array of floating-point values.
  • ['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
static c_comdef_server::GetServer ( ) [static]
static& c_comdef_server::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.

Referenced by DisplayFormatsForEdit(), DisplayMeetingForEdit(), DisplayNewMeetingForm(), DisplayOneMeeting(), and DisplayOneServiceBodyEditor().

static& c_comdef_server::GetServerUsersObj ( ) [static]

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

Returns:
a reference to the internal c_comdef_users object.

Referenced by DisplayUserEditor().

static c_comdef_server::GetServiceBodiesTableName_obj ( ) [static]

Simply returns the name of the service bodies table.

Returns:
A string, containing the name of the table.
& c_comdef_server::GetServiceBodyArray ( )

Simply returns a reference to the contained Service Body array.

Returns:
A reference to an array of c_comdef_service_body objects.
c_comdef_server::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.
static& c_comdef_server::GetServiceBodyByIDObj ( in_service_body_id_bigint) [static]
& c_comdef_server::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.
static c_comdef_server::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.

Referenced by c_comdef_meeting_search_manager::GetSquareForRadius().

static& c_comdef_server::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.

Referenced by DisplayChangedMeetingReports(), DisplayDeletedMeetingReports(), DisplayMeetingForEdit(), GetChanges(), c_comdef_service_body::GetEditorsAsObjects(), and c_comdef_service_body::GetPrincipalUserObj().

static& c_comdef_server::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.
static& c_comdef_server::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.

Referenced by DisplayOneServiceBodyEditor().

static c_comdef_server::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.

Referenced by DisplayMeetingForm().

static c_comdef_server::GetUserTableName_obj ( ) [static]

Simply returns the name of the user table.

Returns:
A string, containing the name of the table.
static c_comdef_server::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.

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

c_comdef_server::Initialize ( )

This reads the Formats, Meeting and Service Entity IDs.

static c_comdef_server::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.
static c_comdef_server::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.

Referenced by DeleteMeetings(), DisplayDeletedMeetingReports(), DisplayFormatsForEdit(), DisplayMeeting(), DisplayMeetingForEdit(), DisplayMeetingForm(), DisplayNewMeetingForm(), DisplayOneServiceBodyEditor(), DisplayOneUserForEditing(), DisplayPageData(), DisplayServiceBodyEditor(), DisplayUserEditor(), c_comdef_user::UserCanEdit(), c_comdef_service_body::UserCanEdit(), c_comdef_meeting::UserCanEdit(), and c_comdef_format::UserCanEdit().

static c_comdef_server::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.

Referenced by listprint_napdf::__construct(), booklet_napdf::__construct(), c_comdef_meeting_search_manager::__construct(), c_comdef_admin_bar(), DisplayAdvancedSearchDiv(), DisplayFormatsForEdit(), DisplayMeetingForm(), DisplayServiceBodyEditor(), DisplaySingleMeeting(), DisplayUserEditor(), and GetControlPanelHTML().

static c_comdef_server::ParseMeetingsByFormats ( in_meetings,
in_formats 
) [static, private]

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.
c_comdef_server::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.

c_comdef_server::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.

c_comdef_server::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.

c_comdef_server::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.

static c_comdef_server::SetServer ( in_server_instance) [static]

Sets the server instance.

static c_comdef_server::TrimChanges ( in_type,
in_id 
) [static]

trims the changes for the given item.

Parameters:
in_typeThis is a string that contains the class of the change record.

Member Data Documentation

c_comdef_server::$_changes_table_name = null [private]

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

c_comdef_server::$_format_table_name = null [private]

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

c_comdef_server::$_formats_obj = null [private]

This is the container for the loaded formats.

c_comdef_server::$_meeting_table_name = null [private]

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

c_comdef_server::$_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.

c_comdef_server::$_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.

c_comdef_server::$_service_bodies_table_name = null [private]

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

c_comdef_server::$_service_ids = null [private]

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

c_comdef_server::$_service_obj_array = null [private]

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

c_comdef_server::$_user_table_name = null [private]

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

c_comdef_server::$_users_obj = null [private]

This is the container for the loaded users.

c_comdef_server::$server_instance = null [static]

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

c_comdef_server::$server_local_strings = null [static]

This contains a cache of the local strings.

Referenced by GetLocalStrings().


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Enumerations