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

A Class for Change Record Objects. More...

Public Member Functions

 UpdateToDB ()
 Updates or adds this instance to the database. More...
 
 DeleteFromDB ()
 Deletes this instance from the database. More...
 
 RestoreFromDB ()
 Updates this instance to the current values in the DB (replacing current values of the instance). More...
 
 __construct ($in_parent_obj, $in_change_type_enum, $in_user_id_int, $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_change_id_int=null, $in_change_name_string=null, $in_change_description_string=null, $in_lang_enum=null, $in_datetime_int=null)
 The initial setup call for the class. If you send in values, the object will set itself up to use them. More...
 
 GetObjectClass ()
 Accessor. Get the Object Class of this change record. More...
 
 GetID ()
 Accessor. Get the ID of this change record. More...
 
 GetChangeType ()
 Accessor. Get the type of this change record. More...
 
 GetUserID ()
 Accessor. Get the ID of the user that created this change record. More...
 
 GetServiceBodyID ()
 Accessor. Get the ID of the Service Body that was represented by the user that created this change record. More...
 
 GetBeforeObjectID ()
 Accessor. Return the ID of the "before" object. More...
 
 GetAfterObjectID ()
 Accessor. Return the ID of the "after" object. More...
 
 GetChangeDate ()
 Accessor. Return the date/time the change was made. More...
 
 GetBeforeSerialized ()
 Accessor. Return the before object in serialized form. More...
 
 GetAfterSerialized ()
 Accessor. Return the after object in serialized form. More...
 
 GetBeforeObject ($in_parent_object=null)
 Return the before object in object form. More...
 
 GetAfterObject ($in_parent_object=null)
 Return the after object in object form. More...
 
 Rollback ()
 Rolls the subject of this change to the "before" version. More...
 
 DescribeChange ()
 Return a string that describes the change. More...
 
 DetailedChangeDescription ()
 Return an array of strings that describes the change in a fairly detailed manner. More...
 
- Public Member Functions inherited from t_comdef_local_type
 SetLocalLang ($in_lang_enum=null)
 Sets the language. More...
 
 GetLocalLang ()
 Returns a reference to the local language setting. More...
 
 SetLocalName ($in_name_string)
 Accessor -Sets the _local_type_name_string data member. More...
 
 GetLocalName ()
 Accessor -Returns a reference to the _local_type_name_string data member. More...
 
 SetLocalDescription ($in_description_string)
 Accessor -Sets the _local_type_desc_string data member. More...
 
 GetLocalDescription ()
 Accessor -Returns a reference to the _local_type_desc_string data member. More...
 
- Public Member Functions inherited from t_local_id_class
 SetParentObj ($in_parent_obj)
 Sets the object's "parent" (Container) object, as a reference. More...
 
 GetParentObj ()
 Returns a reference to the object's container. More...
 

Private Attributes

 $change_id_bigint = null
 An integer, containing the unique ID of this change record. More...
 
 $before_object_string = null
 A serialized object (either c_comdef_format or c_comdef_meeting) before the change. More...
 
 $after_object_string = null
 The same object, serialized after the change. More...
 
 $before_object_id_bigint = null
 The ID of the Before Object. More...
 
 $after_object_id_bigint = null
 The ID of the After Object. More...
 
 $before_object_lang_enum = null
 The Language of the Before Object. More...
 
 $after_object_lang_enum = null
 The Language of the After Object. More...
 
 $change_user_int = null
 The ID of the user making the change. More...
 
 $change_service_body_int = null
 The ID of the Service Body on behalf of which the user is acting. More...
 
 $change_datetime_int = null
 The date and time (as a time() seconds value) when the change was made. More...
 
 $object_class_string = null
 The name of the object class that has been serialized. More...
 
 $change_type_enum = null
 

Detailed Description

A Class for Change Record Objects.

This class handles the Model for the way we record changes in the CoMDEF architecture. A change record has a record of who made the change, when it was made, notes on the change, and a "before" and "after" snapshot of the changed entity. Meetings, Users, Service bodies or formats can have changes recorded. If a new entity is created, the "before" is null. If an entity is deleted, then the "after" snapshot is null. Snapshots are serialized objects.

Definition at line 44 of file c_comdef_change.class.php.

Constructor & Destructor Documentation

__construct (   $in_parent_obj,
  $in_change_type_enum,
  $in_user_id_int,
  $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_change_id_int = null,
  $in_change_name_string = null,
  $in_change_description_string = null,
  $in_lang_enum = null,
  $in_datetime_int = null 
)

The initial setup call for the class. If you send in values, the object will set itself up to use them.

This is the server language.

This is the global language.

Should never be necessary.

If no languages are given for the input objects, we use the main language.

Parameters
$in_parent_objA reference to the parent object for this change object (usually an instance of c_comdef_changes)
$in_user_id_intInteger. The ID of the user that made this change.
$in_service_body_id_bigintInteger. The Service Body the user was acting for.
$in_before_stringString (serialized object of either c_comdef_format or c_comdef_meeting). The object as it was immediately BEFORE the change.
$in_after_stringString (serialized object of either c_comdef_format or c_comdef_meeting). The object as it was immediately AFTER the change.
$in_object_class_stringA string, containing the class of the object[s] being passed in as serialized.
$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_change_id_intInteger. The unique ID of this change record. If left null, the DB interaction will assign one.
$in_change_name_stringString. A brief header (1-line description) of the change (optional).
$in_change_description_stringString. A more detailed description of the change (optional).
$in_lang_enumEnum. The language to record the change as. If null, the server or global language will be used.
$in_datetime_intInteger containing the UNIX epoch (time() value) of the datetime the change was made. If null, the current time will be used.

Definition at line 207 of file c_comdef_change.class.php.

References $comdef_global_language, and c_comdef_server\GetServer().

230  {
231  /// This is the server language.
232  if (null == $in_lang_enum) {
233  $in_lang_enum = c_comdef_server::GetServer()->GetLocalLang();
234  }
235 
236  /// This is the global language.
237  if (null == $in_lang_enum) {
239 
240  $in_lang_enum = $comdef_global_language;
241  }
242 
243  /// Should never be necessary.
244  if (null == $in_lang_enum) {
245  $in_lang_enum = "en";
246  }
247 
248  if (null == $in_datetime_int) {
249  $in_datetime_int = time();
250  }
251 
252  /// If no languages are given for the input objects, we use the main language.
253  if (null == $in_before_obj_lang_enum) {
254  $in_before_obj_lang_enum = $in_lang_enum;
255  }
256 
257  if (null == $in_after_obj_lang_enum) {
258  $in_after_obj_lang_enum = $in_before_obj_lang_enum;
259  }
260 
261  $this->change_id_bigint = $in_change_id_int;
262  $this->change_user_int = $in_user_id_int;
263  $this->change_service_body_int = $in_service_body_id_bigint;
264  $this->change_datetime_int = $in_datetime_int;
265  $this->object_class_string = $in_object_class_string;
266  $this->before_object_string = $in_before_string;
267  $this->after_object_string = $in_after_string;
268  $this->SetLocalName($in_change_name_string);
269  $this->SetLocalDescription($in_change_description_string);
270  $this->SetLocalLang($in_lang_enum);
271  $this->before_object_id_bigint = $in_before_obj_id_bigint;
272  $this->before_object_lang_enum = $in_before_obj_lang_enum;
273  $this->after_object_id_bigint = $in_after_obj_id_bigint;
274  $this->after_object_lang_enum = $in_after_obj_lang_enum;
275  $this->change_type_enum = $in_change_type_enum;
276  }
SetLocalName($in_name_string)
Accessor -Sets the _local_type_name_string data member.
global $comdef_global_language
The local server language enum (Will default to English)
SetLocalDescription($in_description_string)
Accessor -Sets the _local_type_desc_string data member.
SetLocalLang($in_lang_enum=null)
Sets the language.

Member Function Documentation

DeleteFromDB ( )

Deletes this instance from the database.

Exceptions
aPDOException if there is a problem.

Implements i_comdef_db_stored.

Definition at line 143 of file c_comdef_change.class.php.

References $_COMDEF_DEBUG, and c_comdef_dbsingleton\preparedExec().

144  {
145  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
146  try {
147  $sql = "DELETE FROM `".c_comdef_server::GetChangesTableName_obj()."` WHERE id_bigint=?";
148  c_comdef_dbsingleton::preparedExec($sql, array ( $this->GetID() ));
149  } catch (Exception $ex) {
150  global $_COMDEF_DEBUG;
151 
152  if ($_COMDEF_DEBUG) {
153  echo "Exception Thrown in c_comdef_change::DeleteFromDB()!<br />";
154  var_dump($ex);
155  }
156  throw ( $ex );
157  }
158  }
static preparedExec($sql, $params=array())
Wrapper for preparing and executing a PDOStatement that does not return a resultset e...
global $_COMDEF_DEBUG
This flag, when set to true, will cause extra debug information to be output.
GetID()
Accessor. Get the ID of this change record.
DescribeChange ( )

Return a string that describes the change.

Returns
a string array, describing the change, in fairly natural language.

Definition at line 547 of file c_comdef_change.class.php.

References $ret, and c_comdef_server\GetLocalStrings().

548  {
549  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
550  $ret = "";
551 
552  // We build a macro, based upon the various parameters.
553  $macro = "__THE_";
554  switch ($this->object_class_string) {
555  case 'c_comdef_meeting':
556  $macro .= "MEETING_";
557  break;
558 
559  case 'c_comdef_format':
560  $macro .= "FORMAT_";
561  break;
562 
563  case 'c_comdef_user':
564  $macro .= "USER_";
565  break;
566 
567  case 'c_comdef_service_body':
568  $macro .= "SERVICE_BODY_";
569  break;
570  }
571 
572  switch ($this->change_type_enum) {
573  case 'comdef_change_type_new':
574  $macro .= "WAS_CREATED__";
575  break;
576 
577  case 'comdef_change_type_delete':
578  $macro .= "WAS_DELETED__";
579  break;
580 
581  case 'comdef_change_type_change':
582  $macro .= "WAS_CHANGED__";
583  break;
584 
585  case 'comdef_change_type_rollback':
586  $macro .= "WAS_ROLLED_BACK__";
587  break;
588  }
589 
590  if ($macro != "__THE_") {
591  $localized_strings = c_comdef_server::GetLocalStrings();
592 
593  // This is a rather general description of the change.
594  $ret = array('change_desc' => $localized_strings['change_type_strings'][$macro]);
595  if ($this->GetLocalDescription()) {
596  $ret['description'] = $this->GetLocalDescription();
597  }
598  if ($this->GetLocalName()) {
599  $ret['name'] = $this->GetLocalName();
600  }
601  }
602 
603  return $ret;
604  }
static GetLocalStrings($in_lang_enum=null)
This gets the appropriate language files, and puts all the the strings into an associative array...
GetLocalDescription()
Accessor -Returns a reference to the _local_type_desc_string data member.
GetLocalName()
Accessor -Returns a reference to the _local_type_name_string data member.
$ret
Definition: contact.php:226
DetailedChangeDescription ( )

Return an array of strings that describes the change in a fairly detailed manner.

Returns
an associative array, containing an item-by-item change description. Null if no description.
  • 'overall' (required) Contains the same description as returned in DescribeChange()
  • 'details' (optional) Contains an array of individual change items.

Definition at line 615 of file c_comdef_change.class.php.

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

616  {
617  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
618  // We load the defines with the change phrases.
619 
620  $ret = null;
621 
622  $localized_strings = c_comdef_server::GetLocalStrings();
623 
624  switch ($this->object_class_string) {
625  // So far, the only type we are supporting is a meeting. The other types get generic answers.
626  case 'c_comdef_meeting':
627  switch ($this->change_type_enum) {
628  case 'comdef_change_type_new':
629  case 'comdef_change_type_delete':
630  case 'comdef_change_type_rollback':
631  $ret['overall'] = $this->DescribeChange();
632  $ret['details'] = $ret['overall'];
633  break;
634 
635  // We only detail a change. The others get the generic ones.
636  case 'comdef_change_type_change':
637  $ret['overall'] = $this->DescribeChange();
638  // The first thing that we do, is we get an instance of the before, and an instance of the after.
639  $before = $this->GetBeforeObject();
640  $after = $this->GetAfterObject();
641  // We then get pointers to the meeting data for each.
642  if (($before instanceof c_comdef_meeting) && ($after instanceof c_comdef_meeting)) {
643  $before_data = $before->GetMeetingData();
644  $after_data = $after->GetMeetingData();
645 
646  // Make sure we're kosher.
647  if (is_array($before_data) && is_array($after_data)) {
648  // Get all the keys, for both arrays. This way, we sort through even deleted and added items.
649  $key_array = null;
650 
651  // We do it this way, because we don't want repeats. array_merge is a bit of a "blunt instrument."
652  foreach ($before_data as $key => $value) {
653  $key_array[$key] = 1;
654  }
655 
656  foreach ($after_data as $key => $value) {
657  $key_array[$key] = 1;
658  }
659 
660  if (is_array($key_array)) {
661  $key_array = array_keys($key_array);
662 
663  // Okay, now we have an array of every key used in both objects. Time to look for changes.
664  foreach ($key_array as $array_key) {
665  $before_value = null;
666  $after_value = null;
667  $before_value = isset($before_data[$array_key]) ? $before_data[$array_key] : null;
668  // This is a security measure. If the reader can't see BOTH the before and after, we show them neither.
669  if (isset($before_value['visibility']) && ($before_value['visibility'] == _VISIBILITY_NONE_) && (!$after->UserCanObserve() || !$before->UserCanObserve())) {
670  $before_value['value'] == $localized_strings['comdef_server_admin_strings']['hidden_value'];
671  }
672 
673  $after_value = isset($after_data[$array_key]) ? $after_data[$array_key] : null;
674  if (isset($after_value['visibility']) && ($after_value['visibility'] == _VISIBILITY_NONE_) && (!$after->UserCanObserve() || !$before->UserCanObserve())) {
675  $after_value['value'] == $localized_strings['comdef_server_admin_strings']['hidden_value'];
676  }
677  $prompt = $array_key;
678  $change_string = null;
679 
680  if (is_array($before_value)) {
681  if (isset($before_value['prompt'])) {
682  $prompt = $before_value['prompt'];
683  }
684  if (isset($before_value['value'])) {
685  $before_value = $before_value['value'];
686  }
687  }
688 
689  if (is_array($after_value)) {
690  if (isset($after_value['prompt'])) {
691  $prompt = $after_value['prompt'];
692  }
693  if (isset($after_value['value'])) {
694  $after_value = $after_value['value'];
695  }
696  }
697 
698  if ($prompt && (isset($before_value) || isset($after_value))) {
699  if (isset($before_value) && !isset($after_value)) { // Just deleted.
700  switch ($array_key) {
701  case 'published':
702  $change_string = c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['was_unpublished']).$localized_strings['end_change_report'];
703  break;
704  case 'root_server_uri':
705  break; // Hide from change history
706  default:
707  $change_string = c_comdef_htmlspecialchars($prompt).' '.c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['was_deleted']).$localized_strings['end_change_report'];
708  break;
709  }
710  } elseif (!isset($before_value) && isset($after_value)) { // Just added.
711  switch ($array_key) {
712  case 'root_server_uri':
713  break; // Hide from change history
714  case 'email_contact': // For security reasons, we don't display email conact changes as anything but "changed."
715  $change_string = c_comdef_htmlspecialchars($prompt).' '.c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['was_changed']).$localized_strings['end_change_report'];
716  break;
717 
718  case 'published':
719  if (intval($after_value) != 0) {
720  $change_string = c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['was_published']).$localized_strings['end_change_report'];
721  }
722  break;
723 
724  // With these two values, we turn them into military time values and compare from there.
725  case 'start_time':
726  case 'duration_time':
727  $prompt = $localized_strings['detailed_change_strings'][$array_key];
728  $after_value_ar = explode(':', $after_value);
729  $after_value = (intval($after_value_ar[0]) * 100) + intval($after_value_ar[1]);
730  // Not breaking on purpose?
731  default:
732  $change_string = c_comdef_htmlspecialchars($prompt).' '.c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['was_added_as']).' &quot;'.c_comdef_htmlspecialchars($after_value).'&quot; '.$localized_strings['end_change_report'];
733  break;
734  }
735  } else // If it wasn't deleted or added, we need to dig a bit deeper to find the changes.
736  {
737  // Array values require even more digging.
738  if (is_array($before_value) && is_array($after_value)) {
739  switch ($array_key) {
740  case 'formats':
741  $before_keys = array();
742  $after_keys = array();
743 
744  foreach ($before_value as &$a_format_obj) {
745  if ($a_format_obj instanceof c_comdef_format) {
746  array_push($before_keys, $a_format_obj->GetKey());
747  }
748  }
749 
750  foreach ($after_value as &$a_format_obj) {
751  if ($a_format_obj instanceof c_comdef_format) {
752  array_push($after_keys, $a_format_obj->GetKey());
753  }
754  }
755 
756  asort($before_keys);
757  asort($after_keys);
758 
759  $before_value = join(', ', $before_keys);
760  $after_value = join(', ', $after_keys);
761 
762  if ($before_value != $after_value) {
763  $change_string = c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['formats_prompt']).' '.c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['was_changed_from']).' &quot;'.c_comdef_htmlspecialchars($before_value).'&quot; '.c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['to']).' &quot;'.c_comdef_htmlspecialchars($after_value).'&quot;'.$localized_strings['end_change_report'];
764  }
765  break;
766 
767  default:
768  $change_string = c_comdef_htmlspecialchars($prompt).' '.c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['was_changed']).$localized_strings['end_change_report'];
769  break;
770  }
771  } else // Otherwise, we simply compare the values to see if they are different.
772  {
773  // If the value changed, we create a record of the change.
774  if ($before_value != $after_value) {
775  switch ($array_key) {
776  case 'root_server_uri':
777  break; // Hide from change history
778  case 'email_contact': // For security reasons, we don't display email conact changes as anything but "changed."
779  $change_string = c_comdef_htmlspecialchars($prompt).' '.c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['was_changed']).$localized_strings['end_change_report'];
780  break;
781 
782  case 'published':
783  if (intval($before_value) != intval($after_value)) {
784  $change_string = c_comdef_htmlspecialchars($localized_strings['detailed_change_strings'][((intval($after_value) != 0) ? 'was_published' : 'was_unpublished')]).$localized_strings['end_change_report'];
785  }
786  break;
787 
788  case 'weekday_tinyint':
789  $prompt = $localized_strings['detailed_change_strings'][$array_key];
790  $before_value = $localized_strings['weekdays'][max(0, min(6, intval($before_value)))];
791  $after_value = $localized_strings['weekdays'][max(0, min(6, intval($after_value)))];
792  $change_string = c_comdef_htmlspecialchars($prompt).' '.c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['was_changed_from']).' '.c_comdef_htmlspecialchars($before_value).' '.c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['to']).' '.c_comdef_htmlspecialchars($after_value).$localized_strings['end_change_report'];
793  break;
794 
795  case 'service_body_bigint':
796  $from_sb = c_comdef_server::GetServer()->GetServiceBodyByIDObj(intval($before_value));
797  $to_sb = c_comdef_server::GetServer()->GetServiceBodyByIDObj(intval($after_value));
798  if ($from_sb instanceof c_comdef_service_body) {
799  $before_value = $from_sb->GetLocalName();
800  } else {
801  $before_value = $localized_strings['detailed_change_strings']['non_existent_service_body'];
802  }
803 
804  if ($to_sb instanceof c_comdef_service_body) {
805  $after_value = $to_sb->GetLocalName();
806  } else {
807  $before_value = $localized_strings['detailed_change_strings']['non_existent_service_body'];
808  }
809 
810  $prompt = $localized_strings['detailed_change_strings']['sb_prompt'];
811  $change_string = c_comdef_htmlspecialchars($prompt).' '.c_comdef_htmlspecialchars($before_value).' '.c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['to']).' '.c_comdef_htmlspecialchars($after_value).$localized_strings['end_change_report'];
812  break;
813 
814  case 'lang_enum':
815  $prompt = $localized_strings['detailed_change_strings'][$array_key];
816  $file_path = dirname(__FILE__)."/../../local_server/server_admin/lang/$before_value/name.txt";
817 
818  if (file_exists($file_path)) {
819  $before_value = trim(file_get_contents($file_path));
820  }
821 
822  $file_path = dirname(__FILE__)."/../../local_server/server_admin/lang/$after_value/name.txt";
823 
824  if (file_exists($file_path)) {
825  $before_value = trim(file_get_contents($file_path));
826  }
827  $change_string = c_comdef_htmlspecialchars($prompt).' '.c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['was_changed_from']).' &quot;'.c_comdef_htmlspecialchars($before_value).'&quot; '.c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['to']).' &quot;'.c_comdef_htmlspecialchars($after_value).'&quot;'.$localized_strings['end_change_report'];
828  break;
829 
830  case 'longitude':
831  case 'latitude':
832  $before_value = floatval($before_value);
833  $after_value = floatval($after_value);
834  // Not breaking on purpose?
835  case 'worldid_mixed':
836  case 'shared_group_id_bigint':
837  $prompt = $localized_strings['detailed_change_strings'][$array_key];
838  $change_string = c_comdef_htmlspecialchars($prompt).' '.c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['was_changed_from']).' &quot;'.c_comdef_htmlspecialchars($before_value).'&quot; '.c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['to']).' &quot;'.c_comdef_htmlspecialchars($after_value).'&quot;'.$localized_strings['end_change_report'];
839  break;
840 
841  // With these two values, we turn them into military time values and compare from there.
842  case 'start_time':
843  case 'duration_time':
844  $before_value = explode(':', $before_value);
845  $after_value = explode(':', $after_value);
846  $before_value = strval(intval($before_value[0])).':'.(intval($before_value[1]) < 10 ? '0' : '').strval(intval($before_value[1]));
847  $after_value = strval(intval($after_value[0])).':'.(intval($after_value[1]) < 10 ? '0' : '').strval(intval($after_value[1]));
848 
849  if ($before_value == $after_value) {
850  break;
851  }
852  // Not breaking on purpose?
853  case 'id_bigint':
854  $prompt = $localized_strings['detailed_change_strings'][$array_key];
855  // Not breaking on purpose?
856  default:
857  $change_string = c_comdef_htmlspecialchars($prompt).' '.c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['was_changed_from']).' &quot;'.c_comdef_htmlspecialchars($before_value).'&quot; '.c_comdef_htmlspecialchars($localized_strings['detailed_change_strings']['to']).' &quot;'.c_comdef_htmlspecialchars($after_value).'&quot;'.$localized_strings['end_change_report'];
858  break;
859  }
860  }
861  }
862  }
863 
864  if ($change_string) {
865  if (!isset($ret['details']) || !is_array($ret['details'])) {
866  $ret['details'] = array();
867  }
868 
869  array_push($ret['details'], $change_string);
870  }
871  }
872  }
873  }
874  }
875  }
876  break;
877  }
878  break;
879 
880  case 'c_comdef_format':
881  case 'c_comdef_user':
882  case 'c_comdef_service_body':
883  $ret['overall'] = $this->DescribeChange();
884  $ret['details'] = $ret['overall'];
885  break;
886  }
887 
888  return $ret;
889  }
static GetLocalStrings($in_lang_enum=null)
This gets the appropriate language files, and puts all the the strings into an associative array...
A Class for Service Body Objects.
A class to hold a single meeting object.
GetBeforeObject($in_parent_object=null)
Return the before object in object form.
$ret
Definition: contact.php:226
A Class for Format Codes.
c_comdef_htmlspecialchars($in_string)
This function creates a displayable string.
GetAfterObject($in_parent_object=null)
Return the after object in object form.
const _VISIBILITY_NONE_
DescribeChange()
Return a string that describes the change.
GetAfterObject (   $in_parent_object = null)

Return the after object in object form.

Returns
a new c_comdef_meeting, c_comdef_user, c_comdef_service_body or c_comdef_format object. Null if failed or there is no object.
Parameters
$in_parent_objectA reference to the parent object for the new object. If null, the server will be used.

Definition at line 454 of file c_comdef_change.class.php.

References $ret, c_comdef_server\GetServer(), c_comdef_format\UnserializeObject(), c_comdef_user\UnserializeObject(), and c_comdef_meeting\UnserializeObject().

456  {
457  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
458  $ret = null;
459 
460  if (null == $in_parent_object) {
461  $in_parent_object = c_comdef_server::GetServer();
462  }
463 
464  if (null != $this->after_object_string) {
465  switch ($this->object_class_string) {
466  case 'c_comdef_meeting':
467  $ret = c_comdef_meeting::UnserializeObject($in_parent_object, $this->after_object_string);
468  break;
469 
470  case 'c_comdef_format':
471  $ret = c_comdef_format::UnserializeObject($in_parent_object, $this->after_object_string);
472  break;
473 
474  case 'c_comdef_user':
475  $ret = c_comdef_user::UnserializeObject($in_parent_object, $this->after_object_string);
476  break;
477 
478  case 'c_comdef_service_body':
479  $ret = c_comdef_user::UnserializeObject($in_parent_object, $this->after_object_string);
480  break;
481  }
482  }
483 
484  return $ret;
485  }
static UnserializeObject($in_parent, $serialized_string)
This takes the serialized table, and instantiates a new object from it.
$ret
Definition: contact.php:226
static UnserializeObject($in_parent, $serialized_array)
This takes a serialized object, and instantiates a new object from it.
static UnserializeObject($in_parent, $serialized_array)
This takes the serialized data, and instantiates a new object from it.
GetAfterObjectID ( )

Accessor. Return the ID of the "after" object.

Returns
an integer.

Definition at line 362 of file c_comdef_change.class.php.

363  {
364  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
366  }
$after_object_id_bigint
The ID of the After Object.
GetAfterSerialized ( )

Accessor. Return the after object in serialized form.

Returns
a binary string, containing the serialized data.

Definition at line 398 of file c_comdef_change.class.php.

399  {
400  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
402  }
$after_object_string
The same object, serialized after the change.
GetBeforeObject (   $in_parent_object = null)

Return the before object in object form.

Returns
a new c_comdef_meeting, c_comdef_user, c_comdef_service_body or c_comdef_format object. Null if failed or there is no object.
Parameters
$in_parent_objectA reference to the parent object for the new object. If null, the server will be used.

Definition at line 410 of file c_comdef_change.class.php.

References $ret, c_comdef_server\GetOneMeeting(), c_comdef_server\GetServer(), c_comdef_format\UnserializeObject(), c_comdef_user\UnserializeObject(), and c_comdef_meeting\UnserializeObject().

412  {
413  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
414  $ret = null;
415 
416  if (null == $in_parent_object) {
417  $in_parent_object = c_comdef_server::GetServer();
418  }
419 
420  if (null != $this->before_object_string) {
421  switch ($this->object_class_string) {
422  case 'c_comdef_meeting':
423  $ret = c_comdef_meeting::UnserializeObject($in_parent_object, $this->before_object_string);
424  $current = c_comdef_server::GetOneMeeting($ret->GetID());
425  if (null == $current) {
426  // Restoring deleted meetings always unpublishes them before restoring them.
427  $ret->SetPublished(0);
428  }
429  break;
430 
431  case 'c_comdef_format':
432  $ret = c_comdef_format::UnserializeObject($in_parent_object, $this->before_object_string);
433  break;
434 
435  case 'c_comdef_user':
436  $ret = c_comdef_user::UnserializeObject($in_parent_object, $this->before_object_string);
437  break;
438 
439  case 'c_comdef_service_body':
440  $ret = c_comdef_user::UnserializeObject($in_parent_object, $this->before_object_string);
441  break;
442  }
443  }
444 
445  return $ret;
446  }
static UnserializeObject($in_parent, $serialized_string)
This takes the serialized table, and instantiates a new object from it.
$ret
Definition: contact.php:226
static UnserializeObject($in_parent, $serialized_array)
This takes a serialized object, and instantiates a new object from it.
static UnserializeObject($in_parent, $serialized_array)
This takes the serialized data, and instantiates a new object from it.
static GetOneMeeting($in_id_bigint, $test_only=false)
Given an ID for a meeting, it returns one instance.
GetBeforeObjectID ( )

Accessor. Return the ID of the "before" object.

Returns
an integer.

Definition at line 350 of file c_comdef_change.class.php.

351  {
352  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
354  }
$before_object_id_bigint
The ID of the Before Object.
GetBeforeSerialized ( )

Accessor. Return the before object in serialized form.

Returns
a binary string, containing the serialized data.

Definition at line 386 of file c_comdef_change.class.php.

387  {
388  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
390  }
$before_object_string
A serialized object (either c_comdef_format or c_comdef_meeting) before the change.
GetChangeDate ( )

Accessor. Return the date/time the change was made.

Returns
an integer. The UNIX epoch time (time() return) of the change.

Definition at line 374 of file c_comdef_change.class.php.

375  {
376  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
378  }
$change_datetime_int
The date and time (as a time() seconds value) when the change was made.
GetChangeType ( )

Accessor. Get the type of this change record.

Returns
an enum. 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

Definition at line 313 of file c_comdef_change.class.php.

314  {
315  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
317  }
GetID ( )

Accessor. Get the ID of this change record.

Returns
an integer. The ID of the change record.

Definition at line 296 of file c_comdef_change.class.php.

297  {
298  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
300  }
$change_id_bigint
An integer, containing the unique ID of this change record.
GetObjectClass ( )

Accessor. Get the Object Class of this change record.

Returns
a string. The object classname.

Definition at line 284 of file c_comdef_change.class.php.

285  {
286  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
288  }
$object_class_string
The name of the object class that has been serialized.
GetServiceBodyID ( )

Accessor. Get the ID of the Service Body that was represented by the user that created this change record.

Returns
an integer. The ID of the Service Body.

Definition at line 338 of file c_comdef_change.class.php.

339  {
340  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
342  }
$change_service_body_int
The ID of the Service Body on behalf of which the user is acting.
GetUserID ( )

Accessor. Get the ID of the user that created this change record.

Returns
an integer. The ID of the user.

Definition at line 325 of file c_comdef_change.class.php.

326  {
327  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
328  return $this->change_user_int;
329  }
$change_user_int
The ID of the user making the change.
RestoreFromDB ( )

Updates this instance to the current values in the DB (replacing current values of the instance).

Exceptions
aPDOException if there is a problem.

Implements i_comdef_db_stored.

Definition at line 167 of file c_comdef_change.class.php.

References $_COMDEF_DEBUG, and c_comdef_dbsingleton\preparedQuery().

168  {
169  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
170  try {
171  $sql = "SELECT * FROM `".c_comdef_server::GetChangesTableName_obj()."` WHERE id_bigint=? LIMIT 1";
172 
173  $rows = c_comdef_dbsingleton::preparedQuery($sql, array ( $this->change_id_bigint ));
174 
175  if (is_array($rows) && count($rows)) {
176  $this->change_user_int = $rows[0]['user_id_bigint'];
177  $this->change_service_body_int = $rows[0]['service_body_id_bigint'];
178  $this->change_datetime_int = $rows[0]['change_date'];
179  $this->object_class_string = $rows[0]['object_class_string'];
180  $this->before_object_string = $rows[0]['before_object'];
181  $this->after_object_string = $rows[0]['after_object'];
182  $this->SetLocalName($rows[0]['change_name_string']);
183  $this->SetLocalDescription($rows[0]['change_description_text']);
184  $this->SetLocalLang($rows[0]['lang_enum']);
185  $this->before_object_id_bigint = $rows[0]['before_id_bigint'];
186  $this->before_object_lang_enum = $rows[0]['before_lang_enum'];
187  $this->after_object_id_bigint = $rows[0]['after_id_bigint'];
188  $this->after_object_lang_enum = $rows[0]['after_lang_enum'];
189  $this->change_type_enum = $rows[0]['change_type_enum'];
190  }
191  } catch (Exception $ex) {
192  global $_COMDEF_DEBUG;
193 
194  if ($_COMDEF_DEBUG) {
195  echo "Exception Thrown in c_comdef_change::RestoreFromDB()!<br />";
196  var_dump($ex);
197  }
198  throw ( $ex );
199  }
200  }
SetLocalName($in_name_string)
Accessor -Sets the _local_type_name_string data member.
static preparedQuery($sql, $params=array(), $fetchKeyPair=false)
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statement...
SetLocalDescription($in_description_string)
Accessor -Sets the _local_type_desc_string data member.
global $_COMDEF_DEBUG
This flag, when set to true, will cause extra debug information to be output.
SetLocalLang($in_lang_enum=null)
Sets the language.
Rollback ( )

Rolls the subject of this change to the "before" version.

This will only work if there is a "before," and if the current user is cleared to edit both the before and current versions of the item.

Returns
true, if successful. False, otherwise.

Definition at line 497 of file c_comdef_change.class.php.

References $ret, c_comdef_server\GetOneMeeting(), and c_comdef_server\GetOneUser().

498  {
499  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
500  $ret = false;
501 
502  // Start off by getting the prior version of the object.
503  $before = $this->GetBeforeObject();
504 
505  $current = false;
506 
507  switch ($this->object_class_string) {
508  case 'c_comdef_meeting':
509  $id = $before->GetID();
510  $current = c_comdef_server::GetOneMeeting($id);
511  break;
512 
513  case 'c_comdef_format':
514  $id = $before->GetSharedID();
515  $lang = $before->GetLocalLang();
516  $current = c_comdef_server::GetOneMeeting($id, $lang);
517  break;
518 
519  case 'c_comdef_user':
520  $id = $before->GetID();
521  $current = c_comdef_server::GetOneUser($id);
522  break;
523 
524  case 'c_comdef_service_body':
525  $id = $before->GetID();
526  $current = c_comdef_server::GetOneServiceBody($id);
527  break;
528  }
529 
530  // We can't do a rollback unless we pass both these bars.
531  if ((null != $before) && ($before->UserCanEdit())) {
532  // Either there is no current (the object was deleted), or the user is allowed to mess with the current version.
533  if ((null == $current) || ((null != $current) && ($current->UserCanEdit()))) {
534  $ret = $before->UpdateToDB(true);
535  }
536  }
537 
538  return $ret;
539  }
static GetOneUser($in_id_bigint)
Given an ID for a user, it returns one instance.
GetBeforeObject($in_parent_object=null)
Return the before object in object form.
$ret
Definition: contact.php:226
static GetOneMeeting($in_id_bigint, $test_only=false)
Given an ID for a meeting, it returns one instance.
UpdateToDB ( )

Updates or adds this instance to the database.

Exceptions
aPDOException if there is a problem.

Implements i_comdef_db_stored.

Definition at line 85 of file c_comdef_change.class.php.

References $_COMDEF_DEBUG, c_comdef_dbsingleton\preparedExec(), and c_comdef_dbsingleton\preparedQuery().

86  {
87  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
88  $ar = array();
89  try {
90  // We will delete any previous entries.
91  $this->DeleteFromDB();
92 
93  $sql = "INSERT INTO `".c_comdef_server::GetChangesTableName_obj()."` (";
94  if ($this->change_id_bigint) {
95  $sql .= "`id_bigint`,";
96  }
97  $sql .= "`user_id_bigint`,`service_body_id_bigint`,`lang_enum`,`object_class_string`,`change_name_string`,`change_description_text`,`before_object`,`after_object`, `before_id_bigint`, `before_lang_enum`, `after_id_bigint`, `after_lang_enum`, `change_type_enum`) VALUES (";
98  if ($this->change_id_bigint) {
99  $sql .= "?,";
100  array_push($ar, $this->change_id_bigint);
101  }
102  $sql .= "?,?,?,?,?,?,?,?,?,?,?,?,?)";
103  array_push($ar, $this->change_user_int);
104  array_push($ar, $this->change_service_body_int);
105  array_push($ar, $this->GetLocalLang());
106  array_push($ar, $this->object_class_string);
107  array_push($ar, $this->GetLocalName());
108  array_push($ar, $this->GetLocalDescription());
109  array_push($ar, $this->before_object_string);
110  array_push($ar, $this->after_object_string);
111  array_push($ar, $this->before_object_id_bigint);
112  array_push($ar, $this->before_object_lang_enum);
113  array_push($ar, $this->after_object_id_bigint);
114  array_push($ar, $this->after_object_lang_enum);
115  array_push($ar, $this->change_type_enum);
116 
118  // If this is a new user, then we'll need to fetch the ID.
119  if (!$this->change_id_bigint) {
120  $sql = "SELECT LAST_INSERT_ID()";
122  if (is_array($rows) && count($rows)) {
123  $this->change_id_bigint = intval($rows[0]['last_insert_id()']);
124  }
125  }
126  } catch (Exception $ex) {
127  global $_COMDEF_DEBUG;
128 
129  if ($_COMDEF_DEBUG) {
130  echo "Exception Thrown in c_comdef_change::UpdateToDB()!<br />";
131  var_dump($ex);
132  }
133  throw ( $ex );
134  }
135  }
GetLocalDescription()
Accessor -Returns a reference to the _local_type_desc_string data member.
static preparedExec($sql, $params=array())
Wrapper for preparing and executing a PDOStatement that does not return a resultset e...
GetLocalLang()
Returns a reference to the local language setting.
GetLocalName()
Accessor -Returns a reference to the _local_type_name_string data member.
static preparedQuery($sql, $params=array(), $fetchKeyPair=false)
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statement...
global $_COMDEF_DEBUG
This flag, when set to true, will cause extra debug information to be output.
DeleteFromDB()
Deletes this instance from the database.

Member Data Documentation

$after_object_id_bigint = null
private

The ID of the After Object.

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

$after_object_lang_enum = null
private

The Language of the After Object.

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

$after_object_string = null
private

The same object, serialized after the change.

Definition at line 53 of file c_comdef_change.class.php.

$before_object_id_bigint = null
private

The ID of the Before Object.

Definition at line 55 of file c_comdef_change.class.php.

$before_object_lang_enum = null
private

The Language of the Before Object.

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

$before_object_string = null
private

A serialized object (either c_comdef_format or c_comdef_meeting) before the change.

Definition at line 51 of file c_comdef_change.class.php.

$change_datetime_int = null
private

The date and time (as a time() seconds value) when the change was made.

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

$change_id_bigint = null
private

An integer, containing the unique ID of this change record.

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

$change_service_body_int = null
private

The ID of the Service Body on behalf of which the user is acting.

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

$change_type_enum = null
private

The type of change this was 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

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

$change_user_int = null
private

The ID of the user making the change.

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

$object_class_string = null
private

The name of the object class that has been serialized.

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


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