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

A class to hold a collection of c_comdef_meeting objects. More...

Public Member Functions

 __construct ($in_parent_obj, $in_meetings_data)
 Constructor. More...
 
 RemoveInvalidMeetings ()
 Run through the list, and remove meetings that do not show up as "valid.". More...
 
 SetParentObj ($in_parent_obj)
 Set the parent object of this instance. More...
 
 GetParentObj ()
 Return a reference to the parent object of this instance. More...
 
 GetNumMeetings ()
 Get the number of meetings. More...
 
GetMeetingObjects ()
 Accessor -Get the meetings array. More...
 
GetFormatsUsed ()
 Accessor -Get the formats array. More...
 
GetServiceBodiesUsed ()
 Accessor -Get the service bodies array. More...
 
 GetMeetingTableName ()
 
 RemoveMeeting ($in_id)
 Removes a meeting by a given ID from the set. More...
 
 GetMeetingsByDistance ($in_longitude, $in_latitude, $in_radius, $in_radius_is_km=true, $in_sort_by_distance=false)
 Return all the meetings that are within a certain radius of the given location. More...
 
 GetMeetingsByKeyValue ($in_key_string_array, $in_value, $in_contains=false, $in_match_case=false)
 Return all the meetings that have a given key value. More...
 
 GetMeetingsByString ($in_string, $in_lang_enum=null, $in_all_words_bool=false, $in_literal=false)
 Return all the meetings that contain the given string. More...
 
 GetMeetingKeys ()
 Returns an array of all the field keys used by the meetings in this search set. More...
 
 SortMeetingObjects ($in_sort_fields_array, $in_desc=false, $in_by_distance=false)
 Sorts the meetings. This will apply a sort, dependent upon the given fields. The given array contains the field names (SQL columns and keys) for the data to be sorted. More...
 
 GetSortKey ()
 
 GetSortDir ()
 

Static Public Member Functions

static IsInDistance ($lat1, $lon1, $lat2, $lon2, $in_distance_in_KM, &$out_dist_in_KM)
 Uses the Vincenty calculation to estimate a distance between the two given lat/long pairs, then returns true or false as to whether or not the distance between them falls within the given distance (in KM). More...
 
static GetDistance ($lat1, $lon1, $lat2, $lon2)
 Uses the Vincenty calculation to estimate a distance between the two given lat/long pairs, then returns true or false as to whether or not the distance between them falls within the given distance (in KM). More...
 
static SortDistanceKernel ($object_a, $object_b)
 This is the standard PHP sort callback used in the sort loops for distance. This will not be effective if the meetings don't both have _distance_in_km fields. More...
 
static SortKernel ($object_a, $object_b)
 This is the standard PHP sort callback used in the sort loops. More...
 

Private Member Functions

 CreateMeetingObjects ($in_meetings_data)
 Create a bunch of meeting objects from the given data. More...
 

Private Attributes

 $_local_id_parent_obj = null
 A reference to the "parent" object for this instance. More...
 
 $_meetings_objects = null
 An array of new c_comdef_meeting objects that comprises the content. More...
 
 $_formats_used = null
 An array of references to the c_comdef_format objects that are used in this dataset. More...
 
 $_service_bodies_used = null
 An array of references to the c_comdef_service_body objects that are used in this dataset. More...
 
 $_sort_key = null
 An array of string. This is used during sorting, to indicate which key is being sorted. More...
 
 $_sort_dir = null
 
 $_sort_search_by_distance = false
 This is true if the meetings have a distance by which they can be sorted, and the sort should be done with it. More...
 

Detailed Description

A class to hold a collection of c_comdef_meeting objects.

Definition at line 32 of file c_comdef_meetings.class.php.

Constructor & Destructor Documentation

__construct (   $in_parent_obj,
  $in_meetings_data 
)

Constructor.

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

68  {
69  $this->SetParentObj($in_parent_obj);
70  $this->CreateMeetingObjects($in_meetings_data);
71  }
SetParentObj($in_parent_obj)
Set the parent object of this instance.
CreateMeetingObjects($in_meetings_data)
Create a bunch of meeting objects from the given data.

Member Function Documentation

CreateMeetingObjects (   $in_meetings_data)
private

Create a bunch of meeting objects from the given data.

Parameters
$in_meetings_dataAn array of data for one meeting.

Definition at line 221 of file c_comdef_meetings.class.php.

References c_comdef_server\GetServiceBodyByIDObj().

223  {
224  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
225  $this->_meetings_objects = null;
226  $this->_formats_used = null;
227  $this->_service_bodies_used = null;
228 
229  foreach ($in_meetings_data as $one_meeting) {
230  if ($one_meeting instanceof c_comdef_meeting) {
231  $id = $one_meeting->GetID();
232  $meeting = $one_meeting;
233  } else {
234  $id = $one_meeting['id_bigint'];
235  $formats = $one_meeting['formats'];
236  $lang = $one_meeting['lang_enum'];
237  // We make a list of references to the objects of the formats used, and index by the shared ID.
238  // This makes it convenient for the user.
239  foreach ($formats as $format_obj) {
240  if ($format_obj instanceof c_comdef_format) {
241  $format_id = $format_obj->GetSharedID();
242  $this->_formats_used[$format_id] = $format_obj;
243  }
244  }
245  $key = $one_meeting['service_body_bigint'];
246 
248 
249  if ($value instanceof c_comdef_service_body) {
250  $this->_service_bodies_used[$key] = $value;
251  }
252 
253  $meeting = new c_comdef_meeting($this, $one_meeting);
254  }
255  $this->_meetings_objects[$id] = $meeting;
256  }
257  }
A Class for Service Body Objects.
A class to hold a single meeting object.
A Class for Format Codes.
static GetServiceBodyByIDObj($in_service_body_id_bigint)
Get the object for a single service body, given an ID.
static GetDistance (   $lat1,
  $lon1,
  $lat2,
  $lon2 
)
static

Uses the Vincenty calculation to estimate a distance between the two given lat/long pairs, then returns true or false as to whether or not the distance between them falls within the given distance (in KM).

Returns
a Float with the distance, in kilometers.
Parameters
$lat1These four parameters are the given two points long/lat, in degrees.

Definition at line 139 of file c_comdef_meetings.class.php.

References e.

Referenced by c_comdef_server\GetMeetings().

144  {
145  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
146  $a = 6378137;
147  $b = 6356752.3142;
148  $f = 1/298.257223563; // WGS-84 ellipsiod
149  $L = ($lon2-$lon1)/57.2957795131;
150  $U1 = atan((1.0-$f) * tan($lat1/57.2957795131));
151  $U2 = atan((1.0-$f) * tan($lat2/57.2957795131));
152  $sinU1 = sin($U1);
153  $cosU1 = cos($U1);
154  $sinU2 = sin($U2);
155  $cosU2 = cos($U2);
156 
157  $lambda = $L;
158  $lambdaP = $L;
159  $iterLimit = 100;
160 
161  do {
162  $sinLambda = sin($lambda);
163  $cosLambda = cos($lambda);
164  $sinSigma = sqrt(($cosU2*$sinLambda) * ($cosU2*$sinLambda) + ($cosU1*$sinU2-$sinU1*$cosU2*$cosLambda) * ($cosU1*$sinU2-$sinU1*$cosU2*$cosLambda));
165  if ($sinSigma==0) {
166  return true; // co-incident points
167  }
168  $cosSigma = $sinU1*$sinU2 + ($cosU1*$cosU2*$cosLambda);
169  $sigma = atan2($sinSigma, $cosSigma);
170  $sinAlpha = ($cosU1 * $cosU2 * $sinLambda) / $sinSigma;
171  $cosSqAlpha = 1.0 - $sinAlpha*$sinAlpha;
172  $cos2SigmaM = $cosSigma - 2.0*$sinU1*$sinU2/$cosSqAlpha;
173 // if (isNaN(cos2SigmaM))
174 // {
175 // cos2SigmaM = 0; // equatorial line: cosSqAlpha=0 (ยง6)
176 // }
177  $C = $f/(16.0*$cosSqAlpha*(4.0+$f*(4.0-3.0*$cosSqAlpha)));
178  $lambdaP = $lambda;
179  $lambda = $L + (1.0-$C) * $f * $sinAlpha * ($sigma + $C*$sinSigma*($cos2SigmaM+$C*$cosSigma*(-1.0+2.0*$cos2SigmaM*$cos2SigmaM)));
180  } while (abs($lambda-$lambdaP) > 1e-12 && --$iterLimit>0);
181 
182 // if ($iterLimit==0) return NaN // formula failed to converge
183 
184  $uSq = $cosSqAlpha * ($a*$a - $b*$b) / ($b*$b);
185  $A = 1.0 + $uSq/16384.0*(4096.0+$uSq*(-768.0+$uSq*(320.0-175.0*$uSq)));
186  $B = $uSq/1024.0 * (256.0+$uSq*(-128.0+$uSq*(74.0-47.0*$uSq)));
187  $deltaSigma = $B*$sinSigma*($cos2SigmaM+$B/4.0*($cosSigma*(-1.0+2.0*$cos2SigmaM*$cos2SigmaM)-$B/6.0*$cos2SigmaM*(-3.0+4.0*$sinSigma*$sinSigma)*(-3.0+4.0*$cos2SigmaM*$cos2SigmaM)));
188  $s = $b*$A*($sigma-$deltaSigma);
189 
190  return ( abs(round($s) / 1000.0) );
191  }
function e
& GetFormatsUsed ( )

Accessor -Get the formats array.

Returns
a reference to the array that references the c_comdef_format objects used within this dataset.

Definition at line 299 of file c_comdef_meetings.class.php.

300  {
301  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
302  return $this->_formats_used;
303  }
$_formats_used
An array of references to the c_comdef_format objects that are used in this dataset.
GetMeetingKeys ( )

Returns an array of all the field keys used by the meetings in this search set.

Returns
an array of strings, with the key being the same as the value. This reflects

Definition at line 698 of file c_comdef_meetings.class.php.

References $ret.

699  {
700  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
701  $ret = null;
702 
703  $iterating_target = $this->GetMeetingObjects();
704  foreach ($iterating_target as &$meeting) {
705  // Get a reference to the meeting data.
706  $meeting_data = $meeting->GetMeetingData();
707 
708  foreach ($meeting_data as $key => $value) {
709  $ret[$key] = $key;
710  }
711  }
712 
713  return $ret;
714  }
& GetMeetingObjects()
Accessor -Get the meetings array.
$ret
Definition: contact.php:226
& GetMeetingObjects ( )

Accessor -Get the meetings array.

Returns
a reference to the internal meetings object array.

Definition at line 283 of file c_comdef_meetings.class.php.

284  {
285  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
286  if ($this->GetNumMeetings()) {
288  }
289 
290  return null;
291  }
$_meetings_objects
An array of new c_comdef_meeting objects that comprises the content.
GetNumMeetings()
Get the number of meetings.
GetMeetingsByDistance (   $in_longitude,
  $in_latitude,
  $in_radius,
  $in_radius_is_km = true,
  $in_sort_by_distance = false 
)

Return all the meetings that are within a certain radius of the given location.

Returns
a new c_comdef_meetings object, containing the subset of meetings that are within the radius. Null if nothing found.
Parameters
$in_longitudeFloating-point. The longitude value of the center point.
$in_latitudeFloating-point. The latitude value of the center point.
$in_radiusFloating-point. The radius from the center
$in_radius_is_kmBoolean. Set this to false if the radius is in miles (default is true).
$in_sort_by_distanceBoolean. Set this to true to sort the results by distance.

Definition at line 352 of file c_comdef_meetings.class.php.

References $ret.

358  {
359  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
360  $ret = null;
361 
362  if (!$in_radius_is_km) {
363  $in_radius *= 1.609344;
364  }
365 
366  $iterating_target = $this->GetMeetingObjects();
367  foreach ($iterating_target as &$meeting) {
368  if ($meeting instanceof c_comdef_meeting) {
369  // Get a reference to the meeting data.
370  $meeting_data = $meeting->GetMeetingData();
371  $lat = $meeting->GetMeetingDataValue('latitude');
372  $long = $meeting->GetMeetingDataValue('longitude');
373 
374  $dist = 0;
375 
376  if (self::IsInDistance($in_latitude, $in_longitude, $lat, $long, $in_radius, $dist)) {
377  $ret[$meeting->GetID()] = $meeting;
378  }
379  }
380  }
381 
382  if (is_array($ret) && count($ret)) {
383  $reto = new c_comdef_meetings($this->GetParentObj(), $ret);
384 
385  if ($reto instanceof c_comdef_meetings) {
386  $reto->SortMeetingObjects($this->_sort_key, $this->_sort_dir, $in_sort_by_distance);
387  }
388 
389  return $reto;
390  } else {
391  return null;
392  }
393  }
A class to hold a single meeting object.
& GetMeetingObjects()
Accessor -Get the meetings array.
$ret
Definition: contact.php:226
GetParentObj()
Return a reference to the parent object of this instance.
A class to hold a collection of c_comdef_meeting objects.
GetMeetingsByKeyValue (   $in_key_string_array,
  $in_value,
  $in_contains = false,
  $in_match_case = false 
)

Return all the meetings that have a given key value.

Use this to filter for meetings within a single key/value.

Returns
a new c_comdef_meetings object, containing the subset of meetings that contain the search query. Null if nothing found.
Parameters
$in_key_string_arrayThis is data item keys (an array of string). These must match exactly.
$in_valueThis is a string with a literal value to find.
$in_containsIf this is false, then the entire value must match (Defalt is false).

Definition at line 404 of file c_comdef_meetings.class.php.

References $ret, c_comdef_server\GetServer(), and SplitIntoMetaphone().

414  {
415  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
416  $ret = null;
417  $reto = array();
418 
419  if (is_array($in_key_string_array) && count($in_key_string_array)) {
420  if (!$in_match_case) {
421  $in_value = mb_strtolower($in_value, 'UTF-8');
422  }
423  $iterating_target = $this->GetMeetingObjects();
424 
425  foreach ($iterating_target as &$meeting) {
426  // Get a reference to the meeting data.
427  $meeting_data = $meeting->GetMeetingData();
428 
429  // We won't mess with data values that are objects or arrays.
430  if (is_array($meeting_data) && count($meeting_data)) {
431  reset($in_key_string_array);
432  foreach ($in_key_string_array as $key_string) {
433  if (isset($meeting_data[$key_string])) {
434  if (is_array($meeting_data[$key_string]) && isset($meeting_data[$key_string]['value'])) {
435  $value = strval($meeting_data[$key_string]['value']); // Make sure it's a string. We've had problems with non-string fields.
436  } else {
437  $value = strval($meeting_data[$key_string]); // Make sure it's a string. We've had problems with non-string fields.
438  }
439 
440  if (isset($value)) {
441  if (!$in_match_case) {
442  $value = mb_strtolower($value, 'UTF-8');
443  }
444 
445  if ($in_contains) {
446  $preg = preg_quote($in_value);
447  $preg = '|.*'.$preg.'.*|';
448  $match = (1 == preg_match($preg, $value));
449  } else {
450  $match = (0 == strcmp(trim($in_value), trim($value)));
451  }
452 
453  if ($match) {
454  $reto[] = $meeting;
455  } elseif (!$in_match_case) {
456  /*
457  This is all new, as of Version 1.5.
458  If the "match_case" parameter is off, then we do a metaphone search in the local language of the server.
459  */
460  $in_string_comp = SplitIntoMetaphone($in_value, c_comdef_server::GetServer()->GetLocalLang());
461  $comp = SplitIntoMetaphone($value, c_comdef_server::GetServer()->GetLocalLang());
462 
463  $found = false;
464 
465  foreach ($in_string_comp as $test) {
466  if (array_search($test, $comp)) {
467  $found = true;
468  if ($in_contains) {
469  break;
470  }
471  } else {
472  $found = false;
473  if (!$in_contains) {
474  break;
475  }
476  }
477  }
478 
479  if ($found === true) {
480  $reto[] = $meeting;
481  }
482  }
483  }
484  }
485  }
486  }
487  }
488  }
489 
490  if (is_array($reto) && count($reto)) {
491  $ret = new c_comdef_meetings($this->GetParentObj(), $reto);
492 
493  if ($ret instanceof c_comdef_meetings) {
494  $ret->SortMeetingObjects($this->_sort_key, $this->_sort_dir);
495  }
496  }
497 
498  return $ret;
499  }
& GetMeetingObjects()
Accessor -Get the meetings array.
$ret
Definition: contact.php:226
SplitIntoMetaphone($in_string, $in_lang_enum=null, $in_literal=false)
Converts a string into an array of metaphone entities.
GetParentObj()
Return a reference to the parent object of this instance.
A class to hold a collection of c_comdef_meeting objects.
GetMeetingsByString (   $in_string,
  $in_lang_enum = null,
  $in_all_words_bool = false,
  $in_literal = false 
)

Return all the meetings that contain the given string.

If the language is English or Spanish, this does a metaphone search of all all the strings in the "en" or "es" formats and weekdays. If it is any other language, then a simple string search is performed.

Returns
a new c_comdef_meetings object, containing the subset of meetings that contain the search query. Null if nothing found.

If no language is given, we use the server's native language.

We force the search to happen in lowercase. This is a very basic search.

Parameters
$in_stringThis is the string to search for.
$in_lang_enumThis is the code for the desired language. If not given, the server localization will be used.
$in_all_words_boolIf true, then all the words in the given search term need to be found (They could be distributed all around the various components of the meeting record).
$in_literalIf this is set to true, then metaphone-capable languages will not use metaphone, and will literally test the strings. Default is false.

Definition at line 512 of file c_comdef_meetings.class.php.

References $ret, _VISIBILITY_NONE_, c_comdef_server\GetLocalStrings(), c_comdef_server\GetServer(), and SplitIntoMetaphone().

517  {
518  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
519  $ret = null;
520  /// If no language is given, we use the server's native language.
521  if (null == $in_lang_enum) {
522  $in_lang_enum = c_comdef_server::GetServer()->GetLocalLang();
523  }
524 
525  $in_all_words_bool = (isset($in_all_words_bool) && $in_all_words_bool) ? true : false; // Just make sure that there is a value in here.
526  $in_literal = (isset($in_literal) && $in_literal) ? true : false; // Just make sure that there is a value in here.
527 
528  $localized_strings = c_comdef_server::GetLocalStrings();
529 
530  $local_weekdays = $localized_strings['comdef_server_admin_strings']['user_editor_account_type_1'];
531 
532  /// We force the search to happen in lowercase. This is a very basic search.
533  $iterating_target = $this->GetMeetingObjects();
534 
535  if (is_array($iterating_target) && count($iterating_target)) {
536  $count = 0;
537  foreach ($iterating_target as &$meeting) {
538  $count++;
539  if ($meeting instanceof c_comdef_meeting) {
540  // Get a reference to the meeting data.
541  $meeting_data = $meeting->GetMeetingData();
542 
543  /*
544  What we do here, is build up a list of every text field in the meeting record.
545  We resolve the weekday into a localized name, and we grab the localized format
546  text as well.
547 
548  We will then search through all this text for our string[s].
549  */
550  $text_fields = array();
551  foreach ($meeting_data as $key => $value) {
552  // We ignore the values in the main table.
553  switch ($key) {
554  case 'id_bigint':
555  case 'worldid_mixed':
556  case 'start_time':
557  case 'duration_time':
558  case 'time_zone':
559  case 'longitude':
560  case 'latitude':
561  case 'published':
562  case 'email_contact':
563  break;
564 
565  case 'service_body_bigint':
566  $text_fields[$key] = $meeting->GetServiceBodyName();
567  break;
568 
569  case 'lang_enum':
570  $lang_path = dirname(__FILE__)."/../../local_server/server_admin/lang/".$meeting_data['lang_enum']."/name.txt";
571  if (file_exists($lang_path)) {
572  $text_fields[$key] = file_get_contents($lang_path);
573  }
574  break;
575 
576  case 'weekday_tinyint':
577  if (isset($meeting_data['weekday_tinyint'])) {
578  $text_fields[$key] = $local_weekdays[$meeting_data['weekday_tinyint']];
579  }
580  break;
581 
582  case 'formats':
583  $formats_list = c_comdef_server::GetServer()->GetFormatsObj();
584 
585  foreach ($meeting_data[$key] as $key2 => $value) {
586  $the_format_object = $formats_list->GetFormatBySharedIDCodeAndLanguage($key2, $in_lang_enum);
587 
588  if ($the_format_object) {
589  $text_fields["format_$key2"] = $the_format_object->GetLocalName()." ".$the_format_object->GetLocalDescription();
590  }
591  }
592  break;
593 
594  default:
595  if (isset($meeting_data[$key]['value']) && ( null != $meeting_data[$key]['value'] )) {
596  $val = null;
597  $val_key = null;
598  if (!is_float($meeting_data[$key]['value']) && !is_int($meeting_data[$key]['value'])) {
599  if (($meeting_data[$key]['visibility'] != _VISIBILITY_NONE_) || $meeting->UserCanObserve()) {
600  $text_fields[$key] = $meeting_data[$key]['value'];
601  }
602  }
603  }
604  break;
605  }
606  }
607 
608  $found_string = false;
609 
610  if (is_array($text_fields) && count($text_fields)) {
611  $in_string = mb_strtolower(trim($in_string), 'UTF-8');
612  $in_string = preg_replace('|\s+|', ' ', $in_string);
613 
614  if (!$in_literal) {
615  $string_metaphone = SplitIntoMetaphone($in_string, $in_lang_enum);
616  $string_metaphone = implode(' ', $string_metaphone);
617  }
618 
619  foreach ($text_fields as $test_text) {
620  // We will be checking the field text.
621  $test_text = mb_strtolower(trim($test_text), 'UTF-8');
622  $test_text = preg_replace('|\s+|', ' ', $test_text);
623 
624  if ($test_text) {
625  if (isset($string_metaphone)) {
626  $test_metaphone = SplitIntoMetaphone($test_text, $in_lang_enum);
627  $test_metaphone = implode(' ', $test_metaphone);
628  if (mb_strpos($test_metaphone, $string_metaphone, 0, 'UTF-8') !== false) {
629  if (!$ret) {
630  $ret = array ( $meeting );
631  } else {
632  $ret[] = $meeting;
633  }
634 
635  break;
636  }
637  } else {
638  $string_test = preg_split('|\s+|', $in_string);
639 
640  if ($in_all_words_bool) {
641  $test_string = mb_strtolower(trim($test_string), 'UTF-8');
642 
643  if (isset($string_test) && is_array($string_test) && count($string_test)) {
644  $found_string = true;
645 
646  foreach ($string_test as $str) {
647  $str = mb_strtolower(trim($str), 'UTF-8');
648  $found_string = preg_match('|'.preg_quote($str).'|', $test_text);
649 
650  if ($found_string != $in_all_words_bool) {
651  break;
652  }
653  }
654  } else {
655  $test_string = preg_replace('|^[\'\"]*?(.*?)[\'\"]*?$|', '', $in_string);
656  $found_string = preg_match('|'.preg_quote($test_string).'|', $test_text);
657  }
658  }
659 
660  if ($found_string) {
661  if (!$ret) {
662  $ret = array ( $meeting );
663  } else {
664  $ret[] = $meeting;
665  }
666 
667  break;
668  }
669  }
670  }
671  }
672  }
673  }
674  }
675  }
676 
677  $reto = null;
678 
679  if (is_array($ret) && count($ret)) {
680  $reto = new c_comdef_meetings($this->GetParentObj(), $ret);
681 
682  if ($reto instanceof c_comdef_meetings) {
683  $reto->SortMeetingObjects($this->_sort_key, $this->_sort_dir);
684  }
685  }
686 
687  return $reto;
688  }
static GetLocalStrings($in_lang_enum=null)
This gets the appropriate language files, and puts all the the strings into an associative array...
A class to hold a single meeting object.
& GetMeetingObjects()
Accessor -Get the meetings array.
$ret
Definition: contact.php:226
SplitIntoMetaphone($in_string, $in_lang_enum=null, $in_literal=false)
Converts a string into an array of metaphone entities.
GetParentObj()
Return a reference to the parent object of this instance.
const _VISIBILITY_NONE_
A class to hold a collection of c_comdef_meeting objects.
GetMeetingTableName ( )

Returns the name of the Meeting Table.

Returns
the name of the meetings table.

Definition at line 323 of file c_comdef_meetings.class.php.

324  {
325  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
326  $parent_obj = $this->GetParentObj();
327 
328  $name = $parent_obj->GetMeetingTableName();
329 
330  return $name;
331  }
GetParentObj()
Return a reference to the parent object of this instance.
GetNumMeetings ( )

Get the number of meetings.

Returns
an integer, containing the number of meeting objects in the internal meetings object array.

Definition at line 265 of file c_comdef_meetings.class.php.

References $ret.

266  {
267  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
268  $ret = 0;
269 
270  if (isset($this->_meetings_objects) && is_array($this->_meetings_objects) && count($this->_meetings_objects)) {
271  $ret = count($this->_meetings_objects);
272  }
273 
274  return $ret;
275  }
$ret
Definition: contact.php:226
GetParentObj ( )

Return a reference to the parent object of this instance.

Returns
a reference to the parent instance of the object.

Implements i_comdef_has_parent.

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

212  {
213  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
215  }
$_local_id_parent_obj
A reference to the "parent" object for this instance.
& GetServiceBodiesUsed ( )

Accessor -Get the service bodies array.

Returns
a reference to the array that references the c_comdef_service_body objects used within this dataset.

Definition at line 311 of file c_comdef_meetings.class.php.

312  {
313  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
315  }
$_service_bodies_used
An array of references to the c_comdef_service_body objects that are used in this dataset...
GetSortDir ( )

Definition at line 767 of file c_comdef_meetings.class.php.

768  {
769  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
770  return $this->_sort_dir;
771  }
GetSortKey ( )

Definition at line 752 of file c_comdef_meetings.class.php.

753  {
754  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
755  return $this->_sort_key;
756  }
$_sort_key
An array of string. This is used during sorting, to indicate which key is being sorted.
static IsInDistance (   $lat1,
  $lon1,
  $lat2,
  $lon2,
  $in_distance_in_KM,
$out_dist_in_KM 
)
static

Uses the Vincenty calculation to estimate a distance between the two given lat/long pairs, then returns true or false as to whether or not the distance between them falls within the given distance (in KM).

Returns
a Boolean. true, if the points are within the distance given.
Parameters
$lat1These four parameters are the given two points long/lat, in degrees.
$in_distance_in_KMThe distance they must be within to return true (in Kilometers).
$out_dist_in_KMThis is an optional field that allows the calculated distance to be returned (in KM).

Definition at line 112 of file c_comdef_meetings.class.php.

119  {
120  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
121  $dist = self::GetDistance($lat1, $lon1, $lat2, $lon2);
122 
123  if (isset($out_dist_in_KM)) {
124  $out_dist_in_KM = $dist;
125  }
126 
127  return ( floatval($dist) <= floatval($in_distance_in_KM) );
128  }
RemoveInvalidMeetings ( )

Run through the list, and remove meetings that do not show up as "valid.".

If a user is logged in, they see dead meetings.

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

References c_comdef_server\GetCurrentUserObj().

80  {
81  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
83 
84  // Logged-in user sees dead meetings.
85  if (!($cur_user instanceof c_comdef_user)) {
86  $cull_list = array();
87 
88  foreach ($this->_meetings_objects as &$one_meeting) {
89  if ($one_meeting instanceof c_comdef_meeting) {
90  if (!$one_meeting->IsValidMeeting()) {
91  array_push($cull_list, $one_meeting->GetID());
92  }
93  }
94  }
95 
96  foreach ($cull_list as $id) {
97  $this->_meetings_objects[$id] = null;
98  unset($this->_meetings_objects[$id]);
99  }
100  }
101  }
A class to hold a single meeting object.
This class handles BMLT users. One instance is created for each user on the server.
static GetCurrentUserObj($in_is_ajax=false)
Get the current logged-in user, as a c_comdef_user instance.
RemoveMeeting (   $in_id)

Removes a meeting by a given ID from the set.

Parameters
$in_idInteger: the id_bigint for the meeting to be removed.

Definition at line 337 of file c_comdef_meetings.class.php.

339  {
340  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
341  $this->_meetings_objects[$in_id] = null;
342  unset($this->_meetings_objects[$in_id]);
343  }
SetParentObj (   $in_parent_obj)

Set the parent object of this instance.

Parameters
$in_parent_objA reference to the parent object.

Implements i_comdef_has_parent.

Definition at line 197 of file c_comdef_meetings.class.php.

199  {
200  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
201  $this->_local_id_parent_obj = null;
202  $this->_local_id_parent_obj = $in_parent_obj;
203  }
static SortDistanceKernel (   $object_a,
  $object_b 
)
static

This is the standard PHP sort callback used in the sort loops for distance. This will not be effective if the meetings don't both have _distance_in_km fields.

Definition at line 779 of file c_comdef_meetings.class.php.

780  {
781  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
782  $ret = 0;
783 
784  if (($object_a instanceof c_comdef_meeting) && ($object_b instanceof c_comdef_meeting) && isset($object_a->_distance_in_km) && isset($object_b->_distance_in_km)) {
785  $ret = ($object_a->_distance_in_km < $object_b->_distance_in_km) ? -1 : 1;
786 
787  if (0 == $ret) {
788  $ret = $this::SortKernel($object_a, $object_b);
789  }
790  }
791 
792  return $ret;
793  }
A class to hold a single meeting object.
$ret
Definition: contact.php:226
static SortKernel (   $object_a,
  $object_b 
)
static

This is the standard PHP sort callback used in the sort loops.

Definition at line 800 of file c_comdef_meetings.class.php.

801  {
802  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
803  $ret = 0;
804 
805  if (($object_a instanceof c_comdef_meeting) && ($object_b instanceof c_comdef_meeting)) {
806  $parent = $object_a->GetParentObj(); // This is how we get the sort key.
807  if ($parent instanceof c_comdef_meetings) {
808  $sort_key = $parent->GetSortKey();
809  $sort_dir = $parent->GetSortDir();
810 
811  if (is_array($sort_key) && count($sort_key)) {
812  $meeting_data_a = $object_a->GetMeetingData();
813  $meeting_data_b = $object_b->GetMeetingData();
814 
815  if (is_array($meeting_data_a) && count($meeting_data_a) && is_array($meeting_data_b) && count($meeting_data_b)) {
816  foreach ($sort_key as $s_key) {
817  if ($s_key == 'start_time') {
818  $value_a_arr = explode(":", $meeting_data_a[$s_key]);
819  $value_b_arr = explode(":", $meeting_data_b[$s_key]);
820 
821  $value_a = (intval($value_a_arr[0]) * 100) + intval($value_a_arr[1]);
822  $value_b = (intval($value_b_arr[0]) * 100) + intval($value_b_arr[1]);
823 
824  // Kludge to make midnight higher.
825  if ($value_a == 0) {
826  $value_a = 10000;
827  }
828 
829  if ($value_b == 0) {
830  $value_b = 10000;
831  }
832 
833  if ($value_a == $value_b) {
834  $ret = 0;
835  } elseif ($value_a < $value_b) {
836  $ret = -1;
837  } elseif ($value_a > $value_b) {
838  $ret = 1;
839  }
840  } elseif ($s_key == 'weekday_tinyint') {
842 
843  $value_a = intval($meeting_data_a[$s_key]) - ($local_strings['week_starts_on'] - 1);
844  $value_b = intval($meeting_data_b[$s_key]) - ($local_strings['week_starts_on'] - 1);
845 
846  if (1 > $value_a) {
847  $value_a += 7;
848  }
849 
850  if (1 > $value_b) {
851  $value_b += 7;
852  }
853 
854  if ($value_a == $value_b) {
855  $ret = 0;
856  } elseif ($value_a < $value_b) {
857  $ret = -1;
858  } elseif ($value_a > $value_b) {
859  $ret = 1;
860  }
861  } elseif ((($s_key == 'location_municipality') || ($s_key == 'location_city_subsection')) && in_array('location_municipality', $sort_key) && in_array('location_city_subsection', $sort_key)) {
862  if (isset($meeting_data_a['location_city_subsection']) && !isset($meeting_data_b['location_city_subsection'])) {
863  if (isset($meeting_data_b['location_municipality'])) {
864  $value_a = $meeting_data_a['location_city_subsection']['value'];
865  $value_b = $meeting_data_b['location_municipality']['value'];
866  $cmp = strcmp($value_a, $value_b);
867  if (0 > $cmp) {
868  $ret = -1;
869  } elseif (0 < $cmp) {
870  $ret = 1;
871  }
872  } else {
873  $ret = -1;
874  }
875  } elseif (isset($meeting_data_b['location_city_subsection']) && !isset($meeting_data_a['location_city_subsection'])) {
876  if (isset($meeting_data_a['location_municipality'])) {
877  $value_a = $meeting_data_b['location_city_subsection']['value'];
878  $value_b = $meeting_data_a['location_municipality']['value'];
879  $cmp = strcmp($value_a, $value_b);
880  if (0 > $cmp) {
881  $ret = 1;
882  } elseif (0 < $cmp) {
883  $ret = -1;
884  }
885  } else {
886  $ret = 1;
887  }
888  } elseif (isset($meeting_data_a[$s_key]) && is_array($meeting_data_a[$s_key]) && isset($meeting_data_a[$s_key]['value']) && isset($meeting_data_b[$s_key]) && is_array($meeting_data_b[$s_key]) && isset($meeting_data_b[$s_key]['value'])) {
889  $value_a = $meeting_data_a[$s_key]['value'];
890  $value_b = $meeting_data_b[$s_key]['value'];
891  $cmp = strcmp($value_a, $value_b);
892  if (0 > $cmp) {
893  $ret = -1;
894  } elseif (0 < $cmp) {
895  $ret = 1;
896  }
897  } else {
898  $ret = ( isset($meeting_data_a[$s_key]) && !isset($meeting_data_b[$s_key]) ) ? -1 : (( !isset($meeting_data_a[$s_key]) && isset($meeting_data_b[$s_key]) ) ? 1 : 0);
899  }
900  } elseif (isset($meeting_data_a[$s_key]) && isset($meeting_data_b[$s_key])) {
901  // This is if we have an optional field, with a "value" sub array element.
902  if (is_array($meeting_data_a[$s_key]) && isset($meeting_data_a[$s_key]['value'])) {
903  $value_a = $meeting_data_a[$s_key]['value'];
904  } else // If not, we use the actual value of the parameter itself.
905  {
906  $value_a = $meeting_data_a[$s_key];
907  }
908 
909  // We do the same for the next element.
910  if (is_array($meeting_data_b[$s_key]) && isset($meeting_data_b[$s_key]['value'])) {
911  $value_b = $meeting_data_b[$s_key]['value'];
912  } else {
913  $value_b = $meeting_data_b[$s_key];
914  }
915 
916  // If they are strings, we do a binary-safe comparison.
917  if (is_string($value_a)) {
918  if (($value_a && !$value_b) || (isset($value_a) && !isset($value_b))) {
919  $ret = 1;
920  } elseif (($value_b && !$value_a) || (isset($value_b) && !isset($value_a))) {
921  $ret = -1;
922  } else {
923  $cmp = strcmp($value_a, $value_b);
924  if (0 > $cmp) {
925  $ret = -1;
926  } elseif (0 < $cmp) {
927  $ret = 1;
928  }
929  }
930  } else // Otherwise, we do a simple comparison.
931  {
932  if ($value_a < $value_b) {
933  $ret = -1;
934  } elseif ($value_a > $value_b) {
935  $ret = 1;
936  }
937  }
938  } else {
939  $ret = ( isset($meeting_data_a[$s_key]) && !isset($meeting_data_b[$s_key]) ) ? -1 : (( !isset($meeting_data_a[$s_key]) && isset($meeting_data_b[$s_key]) ) ? 1 : 0);
940  }
941 
942  if ($ret != 0) {
943  if ($sort_dir == "desc") {
944  $ret = -$ret;
945  }
946  break;
947  }
948  }
949  }
950  }
951  }
952  }
953 
954  return $ret;
955  }
static GetLocalStrings($in_lang_enum=null)
This gets the appropriate language files, and puts all the the strings into an associative array...
A class to hold a single meeting object.
$local_strings
Definition: index.php:6
$ret
Definition: contact.php:226
A class to hold a collection of c_comdef_meeting objects.
SortMeetingObjects (   $in_sort_fields_array,
  $in_desc = false,
  $in_by_distance = false 
)

Sorts the meetings. This will apply a sort, dependent upon the given fields. The given array contains the field names (SQL columns and keys) for the data to be sorted.

Parameters
$in_descIf this is set to true, the sort will be highest to lowest. Default is false.
$in_by_distanceIf true, then, after the regular sort, we sort by distance (May be ignored if the meetings don't have a

Definition at line 723 of file c_comdef_meetings.class.php.

729  {
730  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
731  $this->_sort_key = null;
732  $my_meeting_data =& $this->GetMeetingObjects();
733 
734  if (is_array($my_meeting_data) && count($my_meeting_data) && is_array($in_sort_fields_array) && count($in_sort_fields_array)) {
735  $this->_sort_key = $in_sort_fields_array;
736  $this->_sort_dir = $in_desc ? "desc" : "asc";
737  usort($my_meeting_data, array ( 'c_comdef_meetings', 'SortKernel' ));
738  }
739 
740  if ($this->_sort_search_by_distance || $in_by_distance) {
741  $this->_sort_search_by_distance = true;
742  usort($my_meeting_data, array ( 'c_comdef_meetings', 'SortDistanceKernel' ));
743  }
744  }
& GetMeetingObjects()
Accessor -Get the meetings array.

Member Data Documentation

$_formats_used = null
private

An array of references to the c_comdef_format objects that are used in this dataset.

Definition at line 43 of file c_comdef_meetings.class.php.

$_local_id_parent_obj = null
private

A reference to the "parent" object for this instance.

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

$_meetings_objects = null
private

An array of new c_comdef_meeting objects that comprises the content.

Definition at line 40 of file c_comdef_meetings.class.php.

$_service_bodies_used = null
private

An array of references to the c_comdef_service_body objects that are used in this dataset.

Definition at line 46 of file c_comdef_meetings.class.php.

$_sort_dir = null
private

A string. This is used during sorting, to indicate which direction to take for the sort. It is either:

  • "asc" -Ascending
  • "desc" -Descending

Definition at line 56 of file c_comdef_meetings.class.php.

$_sort_key = null
private

An array of string. This is used during sorting, to indicate which key is being sorted.

Definition at line 49 of file c_comdef_meetings.class.php.

$_sort_search_by_distance = false
private

This is true if the meetings have a distance by which they can be sorted, and the sort should be done with it.

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


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