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

A Class for Service Body Objects. More...

Public Member Functions

 UpdateToDB ($is_rollback=false)
 Updates or adds this instance to the database. More...
 
 DeleteFromDB_NoRecord ()
 Deletes this instance from the database without creating a change record. More...
 
 DeleteFromDB ()
 Deletes this instance from the database, and creates a change record. More...
 
 RestoreFromDB ()
 Updates this instance to the current values in the DB (replacing current values of the instance). More...
 
 __construct ($in_parent_obj=null, $in_id_bigint=null, $in_principal_user_bigint=null, $in_editors_string=null, $in_kml_file_uri_string=null, $in_uri_string=null, $in_name_string=null, $in_description_string=null, $in_lang_enum=null, $in_world_id_mixed=null, $in_sb_type=null, $in_sb_owner=null, $in_sb_owner_2=null, $in_sb_meeting_email=null)
 The initial setup call for the class. If you send in values, the object will set itself up to use them. More...
 
 GetID ()
 Accessor - Returns the service body ID as an integer. More...
 
 SetID ($in_service_body_id_bigint)
 Accessor - Sets the service body ID as an integer. More...
 
 GetPrincipalUserID ()
 Accessor - Returns the principal user for this service body. More...
 
GetPrincipalUserObj ()
 Accessor - Returns the principal user for this service body. More...
 
 SetPrincipalUserID ($in_principal_user_id_bigint)
 Accessor - Sets the principal user for this service body. More...
 
 GetSBType ()
 Accessor - Returns the Service Body Type. More...
 
 SetSBType ($in_sb_type)
 Accessor - Sets the URI of the KML file for the Service Boundaries. More...
 
 GetOwnerID ()
 Accessor - Returns the ID of the 'owner' of this object. More...
 
 GetOwner2ID ()
 Accessor - Returns the ID of the 'secondary owner' of this object. More...
 
GetOwnerIDObject ()
 Accessor - Returns the 'owner' of this object as a reference to an object. More...
 
GetOwner2IDObject ()
 Accessor - Returns the 'secondary owner' of this object as a reference to an object. More...
 
 SetOwnerID ($in_sb_owner)
 Accessor - Sets the ID of the 'owner' of this object. More...
 
 SetOwner2ID ($in_sb_owner)
 Accessor - Sets the ID of the 'secondary owner' of this object. More...
 
 SetOwnerObj (&$in_sb_owner_obj)
 Accessor - Sets the ID of the 'owner' of this object by sending in an object reference. More...
 
 SetOwner2Obj (&$in_sb_owner_obj)
 Accessor - Sets the ID of the 'secondary owner' of this object by sending in an object reference. More...
 
 GetHelpline ()
 Accessor - Returns the helpline, as a string. More...
 
 SetHelpline ($in_helpline_string)
 Accessor - Sets the URI of the KML file for the Service Boundaries. More...
 
 GetURI ()
 Accessor - Returns the URI of a site with more information on the Service Body. More...
 
 SetURI ($in_uri_string)
 Accessor - Sets the URI of a site with more information on the Service Body. More...
 
 SetContactEmail ($in_email)
 Accessor - set the contact email string. More...
 
 GetContactEmail ($in_recursive=false)
 Get the contact email for this Service Body. If $in_recursive is false, then it simply looks at this Service Body. This first looks at the Service Body Meeting Email. If that is not there, it gets the email for the principal admin. If that is not there, it percolates to the parent, recursively (if $in_recursive is true ). More...
 
 GetEditors ()
 Accessor - Returns IDs for all the editors. More...
 
 GetEditorsAsObjects ()
 Accessor - Returns user objects for all the editors. More...
 
 IsUserInServiceBody ($in_user_object=null)
 Accessor - Returns true if the current user is an editor for the Service Body, or if the user is an owner. More...
 
 IsUserInServiceBodyHierarchy ($in_user_object=null)
 Accessor - Returns true if the current user is an editor for the Service Body. Checks up the hierarchy recursively. More...
 
 SetEditors ($in_editor_id_array)
 Accessor - Sets the editors by ID. More...
 
 SerializeObject ()
 Returns a storable serialization of the object, as a string. More...
 
 UserCanEditMeetings ($in_user_object=null)
 Test to see if a user is allowed to edit meetings in this Service body. More...
 
 UserCanObserve ($in_user_object=null)
 Test to see if a user is allowed to observe in this Service body. More...
 
 UserCanEdit ($in_user_object=null)
 Test to see if a user is allowed to edit an instance (change the data). Service Body Administrators that are Editors in parent, or secondary parent Service bodies can edit the Service body. More...
 
 IsOwnedBy ($in_sb_id, $in_direct=false)
 Check to see if a given Service Body ID is anywhere in the "direct parent" hierarchy of this Service Body. More...
 
- Public Member Functions inherited from t_comdef_world_type
 SetWorldID ($in_worldid_mixed)
 Accessor -Sets the _world_type_worldid_mixed data member. More...
 
 GetWorldID ()
 Accessor -Returns a reference to the _world_type_worldid_mixed data member. 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...
 
- Public Member Functions inherited from i_comdef_db_stored
 UpdateToDB ()
 This causes the object to update the database to its current state. More...
 

Static Public Member Functions

static UnserializeObject ($in_parent, $serialized_string)
 This takes the serialized table, and instantiates a new object from it. More...
 

Private Attributes

 $_id_bigint = null
 An integer, containing the unique ID of this service body. More...
 
 $_principal_user_bigint = null
 An integer, with the ID of the principal administrator for this Service Body. More...
 
 $_editors_string = null
 A string, containing a CSV list of integers, each an ID for a user that has editor privileges for meetings for this Service Body. More...
 
 $_kml_file_uri_string = null
 A string, containing the helpline (re-used KML file URI). More...
 
 $_uri_string = null
 A string, containing a URI to a site that gives further information about the Service Body. More...
 
 $_sb_type = null
 
 $_sb_owner = null
 An integer. The ID of the Service Body that "owns" this one. More...
 
 $_sb_owner_2 = null
 An integer. Some Service Bodies can have "unofficial" "owners" (like Zonal Forums or Metro Areas). More...
 
 $_sb_meeting_email = null
 A string that contains the meeting contact email address. More...
 

Detailed Description

A Class for Service Body Objects.

The BMLT doesn't really care that much about the Service role of any given Service Body. Indicators of such are provided so that clients of the BMLT can keep track of them.

The BMLT is more interested in the hierarchy of a Service Body. If a Service Body has an owner or a secondary owner, then any member of the owner or secondary owner can edit any meetings in the Service Body, and and Service Body Administrators in an owner or secondary owner can administer the Service Body itself.

Definition at line 58 of file c_comdef_service_body.class.php.

Constructor & Destructor Documentation

__construct (   $in_parent_obj = null,
  $in_id_bigint = null,
  $in_principal_user_bigint = null,
  $in_editors_string = null,
  $in_kml_file_uri_string = null,
  $in_uri_string = null,
  $in_name_string = null,
  $in_description_string = null,
  $in_lang_enum = null,
  $in_world_id_mixed = null,
  $in_sb_type = null,
  $in_sb_owner = null,
  $in_sb_owner_2 = null,
  $in_sb_meeting_email = 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.

Should never be necessary.

Parameters
$in_parent_objA reference to the parent object for this Service Body Object.
$in_id_bigintAn integer, containing the ID of the object. If null or 0, then the object is new.
$in_principal_user_bigintAn integer with the ID of the principal user for this Service Body.
$in_editors_stringA string containing a CSV array of integers with editor user IDs
$in_kml_file_uri_stringA string containing a URI to the KML file that displays this Service Body's boundaries.
$in_uri_stringA string containing a URI to a site that has more information about the Service Body.
$in_name_stringThe local name of the Service Body as a string.
$in_description_stringThe local description of the Service Body as a string.
$in_lang_enumA string, with the language code for this Service Body.
$in_world_id_mixedA string, containing the World ID for this Service Body.
$in_sb_ownerAn integer. The ID of the Service Body that "owns" this Service Body.
$in_sb_owner_2An integer. The ID of the "secondary" Service Body that "owns" this Service Body.
$in_sb_meeting_emailA string, containing any email address that is to be used for meeting contacts.

Definition at line 301 of file c_comdef_service_body.class.php.

References $comdef_global_language.

326  {
328 
329  /// This is the server language.
330  if (null == $in_lang_enum) {
331  $in_lang_enum = $comdef_global_language;
332  }
333 
334  /// Should never be necessary.
335  if (null == $in_lang_enum) {
336  $in_lang_enum = "en";
337  }
338 
339  // Set the five inherited values.
340  $this->SetParentObj($in_parent_obj);
341  $this->SetLocalLang($in_lang_enum);
342  $this->SetLocalName($in_name_string);
343  $this->SetWorldID($in_world_id_mixed);
344  $this->SetLocalDescription($in_description_string);
345 
346  // Set the local values.
347  $this->_id_bigint = $in_id_bigint;
348  $this->_principal_user_bigint = $in_principal_user_bigint;
349  $this->_editors_string = $in_editors_string;
350  $this->_kml_file_uri_string = $in_kml_file_uri_string;
351  $this->_uri_string = $in_uri_string;
352  $this->_sb_type = $in_sb_type;
353  $this->SetOwnerID($in_sb_owner);
354  $this->SetOwner2ID($in_sb_owner_2);
355  $this->SetContactEmail($in_sb_meeting_email);
356  }
SetLocalName($in_name_string)
Accessor -Sets the _local_type_name_string data member.
SetParentObj($in_parent_obj)
Sets the object's "parent" (Container) object, as a reference.
global $comdef_global_language
The local server language enum (Will default to English)
SetContactEmail($in_email)
Accessor - set the contact email string.
SetOwnerID($in_sb_owner)
Accessor - Sets the ID of the 'owner' of this object.
SetLocalDescription($in_description_string)
Accessor -Sets the _local_type_desc_string data member.
SetWorldID($in_worldid_mixed)
Accessor -Sets the _world_type_worldid_mixed data member.
SetOwner2ID($in_sb_owner)
Accessor - Sets the ID of the 'secondary owner' of this object.
SetLocalLang($in_lang_enum=null)
Sets the language.

Member Function Documentation

DeleteFromDB ( )

Deletes this instance from the database, and creates a change record.

Returns
true if successful, false, otherwise.
Exceptions
aPDOException if there is a problem.

Implements i_comdef_db_stored.

Definition at line 226 of file c_comdef_service_body.class.php.

References $ret, c_comdef_server\AddNewChange(), c_comdef_server\GetCurrentUserObj(), and c_comdef_server\GetServiceBodyByIDObj().

227  {
228  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
229  $ret = false;
230 
232 
233  if ($this->UserCanEdit($user)) {
234  // We take a snapshot of the service body as it currently sits in the database as a "before" image.
235  $before = null;
236  $before_id = null;
237  $before_lang = null;
238  $before_obj = c_comdef_server::GetServiceBodyByIDObj($this->GetID());
239 
240  if ($before_obj instanceof c_comdef_service_body) {
241  $before = $before_obj->SerializeObject();
242  $before_id = $before_obj->GetID();
243  $before_lang = $before_obj->GetLocalLang();
244  $before_obj = null;
245  }
246 
247  $ret = $this->DeleteFromDB_NoRecord();
248 
249  if ($ret) {
250  c_comdef_server::AddNewChange($user->GetID(), 'comdef_change_type_delete', $this->GetID(), $before, null, 'c_comdef_service_body', $before_id, null, $before_lang, null);
251  }
252  }
253 
254  return $ret;
255  }
A Class for Service Body Objects.
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.
GetID()
Accessor - Returns the service body ID as an integer.
$ret
Definition: contact.php:226
UserCanEdit($in_user_object=null)
Test to see if a user is allowed to edit an instance (change the data). Service Body Administrators t...
static GetServiceBodyByIDObj($in_service_body_id_bigint)
Get the object for a single service body, given an ID.
DeleteFromDB_NoRecord()
Deletes this instance from the database without creating a change record.
static GetCurrentUserObj($in_is_ajax=false)
Get the current logged-in user, as a c_comdef_user instance.
DeleteFromDB_NoRecord ( )

Deletes this instance from the database without creating a change record.

Returns
true if successful, false, otherwise.
Exceptions
aPDOException if there is a problem.

Definition at line 194 of file c_comdef_service_body.class.php.

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

195  {
196  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
197  $ret = false;
198 
199  if ($this->UserCanEdit()) {
200  try {
201  $sql = "DELETE FROM `".c_comdef_server::GetServiceBodiesTableName_obj()."` WHERE id_bigint=?";
202  c_comdef_dbsingleton::preparedExec($sql, array ( $this->GetID() ));
203  $ret = true;
204  } catch (Exception $ex) {
205  global $_COMDEF_DEBUG;
206 
207  if ($_COMDEF_DEBUG) {
208  echo "Exception Thrown in c_comdef_service_body::DeleteFromDB_NoRecord()!<br />";
209  var_dump($ex);
210  }
211  throw ( $ex );
212  }
213  }
214 
215  return $ret;
216  }
GetID()
Accessor - Returns the service body ID as an integer.
static preparedExec($sql, $params=array())
Wrapper for preparing and executing a PDOStatement that does not return a resultset e...
$ret
Definition: contact.php:226
UserCanEdit($in_user_object=null)
Test to see if a user is allowed to edit an instance (change the data). Service Body Administrators t...
global $_COMDEF_DEBUG
This flag, when set to true, will cause extra debug information to be output.
GetContactEmail (   $in_recursive = false)

Get the contact email for this Service Body. If $in_recursive is false, then it simply looks at this Service Body. This first looks at the Service Body Meeting Email. If that is not there, it gets the email for the principal admin. If that is not there, it percolates to the parent, recursively (if $in_recursive is true ).

Returns
a string, which is the contact email for this Service Body
Parameters
$in_recursiveIf this is true, then the function will return a recursive result. Default is false.

Definition at line 639 of file c_comdef_service_body.class.php.

References $ret.

641  {
642  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
643  $ret = trim($this->_sb_meeting_email);
644 
645  if (!$ret && $in_recursive) {
646  $owner = $this->GetOwnerIDObject();
647 
648  if ($owner instanceof c_comdef_service_body) {
649  $ret = $owner->GetContactEmail($in_recursive);
650  }
651  }
652 
653  return $ret;
654  }
A Class for Service Body Objects.
& GetOwnerIDObject()
Accessor - Returns the &#39;owner&#39; of this object as a reference to an object.
$ret
Definition: contact.php:226
GetEditors ( )

Accessor - Returns IDs for all the editors.

Returns
an array of integers, containing the editor IDs.

Definition at line 662 of file c_comdef_service_body.class.php.

663  {
664  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
665  $ret_array = array();
666 
667  $editor_ids = explode(",", $this->_editors_string);
668 
669  foreach ($editor_ids as $id) {
670  $id = intval($id);
671  array_push($ret_array, $id);
672  }
673 
674  return $ret_array;
675  }
GetEditorsAsObjects ( )

Accessor - Returns user objects for all the editors.

Returns
an array of references to c_comdef_user objects. The associative key for each user will the ID for that user.

Definition at line 683 of file c_comdef_service_body.class.php.

References c_comdef_server\GetUserByIDObj().

684  {
685  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
686  $ret_array = array();
687 
688  $editor_ids = $this->GetEditors();
689 
690  foreach ($editor_ids as $id) {
691  $ret_array[$id] = c_comdef_server::GetUserByIDObj($id);
692  }
693 
694  return $ret_array;
695  }
static GetUserByIDObj($in_user_id_bigint)
Get the object for a single user, given an ID.
GetEditors()
Accessor - Returns IDs for all the editors.
GetHelpline ( )

Accessor - Returns the helpline, as a string.

Returns
a string, containing the URI.

Definition at line 578 of file c_comdef_service_body.class.php.

579  {
580  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
582  }
$_kml_file_uri_string
A string, containing the helpline (re-used KML file URI).
GetID ( )

Accessor - Returns the service body ID as an integer.

Returns
an integer, containing the service body ID.

Definition at line 364 of file c_comdef_service_body.class.php.

365  {
366  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
367  return $this->_id_bigint;
368  }
$_id_bigint
An integer, containing the unique ID of this service body.
GetOwner2ID ( )

Accessor - Returns the ID of the 'secondary owner' of this object.

Returns
an integer, containing the owner ID of the secondary "owner."

Definition at line 476 of file c_comdef_service_body.class.php.

477  {
478  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
479  return $this->_sb_owner_2;
480  }
$_sb_owner_2
An integer. Some Service Bodies can have "unofficial" "owners" (like Zonal Forums or Metro Areas)...
& GetOwner2IDObject ( )

Accessor - Returns the 'secondary owner' of this object as a reference to an object.

Returns
a reference to the internal c_comdef_service_body object for the service body. Null if not found.

Definition at line 502 of file c_comdef_service_body.class.php.

References c_comdef_server\GetServiceBodyByIDObj().

503  {
504  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
506  }
GetOwner2ID()
Accessor - Returns the ID of the &#39;secondary owner&#39; of this object.
static GetServiceBodyByIDObj($in_service_body_id_bigint)
Get the object for a single service body, given an ID.
GetOwnerID ( )

Accessor - Returns the ID of the 'owner' of this object.

Returns
an integer, containing the owner ID.

Definition at line 464 of file c_comdef_service_body.class.php.

465  {
466  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
467  return $this->_sb_owner;
468  }
$_sb_owner
An integer. The ID of the Service Body that "owns" this one.
& GetOwnerIDObject ( )

Accessor - Returns the 'owner' of this object as a reference to an object.

Returns
a reference to the internal c_comdef_service_body object for the service body. Null if not found.

Definition at line 488 of file c_comdef_service_body.class.php.

References $ret, and c_comdef_server\GetServiceBodyByIDObj().

489  {
490  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
491  $owner_id = $this->GetOwnerID();
493  return $ret;
494  }
$ret
Definition: contact.php:226
static GetServiceBodyByIDObj($in_service_body_id_bigint)
Get the object for a single service body, given an ID.
GetOwnerID()
Accessor - Returns the ID of the &#39;owner&#39; of this object.
GetPrincipalUserID ( )

Accessor - Returns the principal user for this service body.

Returns
an integer, containing the user ID.

Definition at line 387 of file c_comdef_service_body.class.php.

388  {
389  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
391  }
$_principal_user_bigint
An integer, with the ID of the principal administrator for this Service Body.
& GetPrincipalUserObj ( )

Accessor - Returns the principal user for this service body.

Returns
a reference to a c_comdef_user object of the principal user.

Definition at line 399 of file c_comdef_service_body.class.php.

References c_comdef_server\GetUserByIDObj().

400  {
401  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
402  return c_comdef_server::GetUserByIDObj($this->_principal_user_bigint);
403  }
static GetUserByIDObj($in_user_id_bigint)
Get the object for a single user, given an ID.
GetSBType ( )

Accessor - Returns the Service Body Type.

Returns
a string, containing the Type. It can be one of the following:
  • c_comdef_service_body__GRP__ Individual NA Group
  • c_comdef_service_body__ASC__ Area Service Committee
  • c_comdef_service_body__RSC__ Regional Service Committee
  • c_comdef_service_body__WSC__ World Service Committee
  • c_comdef_service_body__MAS__ Metro Area
  • c_comdef_service_body__ZFM__ Zonal Forum
  • c_comdef_service_body__GSU__ Group Service Unit
  • c_comdef_service_body__LSU__ Local Service Unit

Definition at line 431 of file c_comdef_service_body.class.php.

432  {
433  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
434  return $this->_sb_type;
435  }
GetURI ( )

Accessor - Returns the URI of a site with more information on the Service Body.

Returns
a string, containing the URI.

Definition at line 601 of file c_comdef_service_body.class.php.

602  {
603  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
604  return $this->_uri_string;
605  }
$_uri_string
A string, containing a URI to a site that gives further information about the Service Body...
IsOwnedBy (   $in_sb_id,
  $in_direct = false 
)

Check to see if a given Service Body ID is anywhere in the "direct parent" hierarchy of this Service Body.

Returns
a boolean. True if the given Service Body appears in the hierarchy above it.
Parameters
$in_sb_idThe ID of a potential owner.
$in_directIf this is set to true, then only the immediate parent is checked. Default is false.

Definition at line 1035 of file c_comdef_service_body.class.php.

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

1038  {
1039  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
1040  $ret = false;
1042 
1043  if ($server instanceof c_comdef_server) {
1044  $sb_to_check = $server->GetServiceBodyByIDObj($in_sb_id);
1045 
1046  $parent = $this->GetOwnerID();
1047 
1048  if ($parent == $in_sb_id) {
1049  $ret = true;
1050  } elseif (!$in_direct) {
1051  if ($parent) {
1052  $sb_to_check = $server->GetServiceBodyByIDObj($parent);
1053 
1054  if ($sb_to_check instanceof c_comdef_service_body) {
1055  $ret = IsSBRecursive($in_sb_id, $sb_to_check->GetID(), $in_direct);
1056  }
1057  }
1058  }
1059  }
1060 
1061  return $ret;
1062  }
A Class for Service Body Objects.
$ret
Definition: contact.php:226
$server
Definition: GetLangs.php:25
This class is the main server class. It instantiates a PDO database object, and is the starting point...
GetOwnerID()
Accessor - Returns the ID of the &#39;owner&#39; of this object.
IsUserInServiceBody (   $in_user_object = null)

Accessor - Returns true if the current user is an editor for the Service Body, or if the user is an owner.

Returns
a boolean. True if the user is an editor or principal user.
Parameters
$in_user_objectA reference to an instance of c_comdef_user. If null, the current user is checked.

Definition at line 704 of file c_comdef_service_body.class.php.

References $ret, and c_comdef_server\GetCurrentUserObj().

706  {
707  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
708  $ret = false;
709  // We load the server user if one wasn't supplied.
710  if (null == $in_user_object) {
711  $in_user_object = c_comdef_server::GetCurrentUserObj();
712  }
713 
714  // If it isn't a user object, we fail right there.
715  if ($in_user_object instanceof c_comdef_user) {
716  $in_user_object->RestoreFromDB(); // The reason you do this, is to ensure that the user wasn't modified "live." It's a security precaution.
717  $user_id = intval($in_user_object->GetID());
718  $in_user_object = null;
719 
720  if (intval($this->GetPrincipalUserID()) == $user_id) {
721  $ret = true;
722  } else {
723  $editors = $this->GetEditors();
724 
725  foreach ($editors as $editor) {
726  if ($user_id == intval($editor)) {
727  $ret = true;
728  break;
729  }
730  }
731  }
732  }
733  return $ret;
734  }
This class handles BMLT users. One instance is created for each user on the server.
$ret
Definition: contact.php:226
GetEditors()
Accessor - Returns IDs for all the editors.
GetPrincipalUserID()
Accessor - Returns the principal user for this service body.
static GetCurrentUserObj($in_is_ajax=false)
Get the current logged-in user, as a c_comdef_user instance.
IsUserInServiceBodyHierarchy (   $in_user_object = null)

Accessor - Returns true if the current user is an editor for the Service Body. Checks up the hierarchy recursively.

Returns
a boolean. True if the user is in the hierarchy (going up) of the Service Body.
Parameters
$in_user_objectA reference to an instance of c_comdef_user. If null, the current user is checked.

Definition at line 743 of file c_comdef_service_body.class.php.

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

745  {
746  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
747  $ret = false;
748  // We load the server user if one wasn't supplied.
749  if (null == $in_user_object) {
750  $in_user_object = c_comdef_server::GetCurrentUserObj();
751  }
752 
753  // If it isn't a user object, we fail right there.
754  if ($in_user_object instanceof c_comdef_user) {
755  $in_user_object->RestoreFromDB(); // The reason you do this, is to ensure that the user wasn't modified "live." It's a security precaution.
756  // First, see if the user is in this Service Body.
757 
758  $ret = $this->IsUserInServiceBody($in_user_object);
759 
760  if (!$ret && $this->GetOwnerID()) {
761  $parent = c_comdef_server::GetServer()->GetServiceBodyByIDObj($this->GetOwnerID());
762  // Check the primary "parent" Service Body's hierarchy.
763  if ($parent instanceof c_comdef_service_body) {
764  if ($parent->IsUserInServiceBody($in_user_object)) {
765  $ret = true;
766  } else {
767  $ret = $parent->IsUserInServiceBodyHierarchy($in_user_object);
768  }
769  }
770  }
771 
772  if (!$ret && $this->GetOwner2ID()) {
773  $parent = c_comdef_server::GetServer()->GetServiceBodyByIDObj($this->GetOwner2ID());
774 
775  // Check the secondary "parent" Service Body's hierarchy.
776  if ($parent instanceof c_comdef_service_body) {
777  if ($parent->IsUserInServiceBody($in_user_object)) {
778  $ret = true;
779  } else {
780  $ret = $parent->IsUserInServiceBodyHierarchy($in_user_object);
781  }
782  }
783  }
784  }
785 
786  return $ret;
787  }
A Class for Service Body Objects.
This class handles BMLT users. One instance is created for each user on the server.
$ret
Definition: contact.php:226
IsUserInServiceBody($in_user_object=null)
Accessor - Returns true if the current user is an editor for the Service Body, or if the user is an o...
GetOwner2ID()
Accessor - Returns the ID of the &#39;secondary owner&#39; of this object.
GetOwnerID()
Accessor - Returns the ID of the &#39;owner&#39; of this object.
static GetCurrentUserObj($in_is_ajax=false)
Get the current logged-in user, as a c_comdef_user instance.
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 264 of file c_comdef_service_body.class.php.

References $_COMDEF_DEBUG, and c_comdef_dbsingleton\preparedQuery().

265  {
266  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
267  try {
268  if ($this->GetID()) {
269  $sql = "SELECT * FROM `".c_comdef_server::GetServiceBodiesTableName_obj()."` WHERE id_bigint=? LIMIT 1";
270  $rows = c_comdef_dbsingleton::preparedQuery($sql, array ( $this->GetID() ));
271  if (is_array($rows) && count($rows)) {
272  $this->_principal_user_bigint = $rows[0]['principal_user_bigint'];
273  $this->_editors_string = $rows[0]['editors_string'];
274  $this->_kml_file_uri_string = $rows[0]['kml_file_uri_string'];
275  $this->_uri_string = $rows[0]['uri_string'];
276  $this->SetLocalName($rows[0]['name_string']);
277  $this->SetLocalDescription($rows[0]['description_string']);
278  $this->SetLocalLang($rows[0]['lang_enum']);
279  $this->_sb_type = $rows[0]['sb_type'];
280  $this->SetOwnerID($rows[0]['sb_owner']);
281  $this->SetOwner2ID($rows[0]['sb_owner_2']);
282  $this->SetContactEmail($rows[0]['sb_meeting_email']);
283  }
284  }
285  } catch (Exception $ex) {
286  global $_COMDEF_DEBUG;
287 
288  if ($_COMDEF_DEBUG) {
289  echo "Exception Thrown in c_comdef_service_body::RestoreFromDB()!<br />";
290  var_dump($ex);
291  }
292  throw ( $ex );
293  }
294  }
SetLocalName($in_name_string)
Accessor -Sets the _local_type_name_string data member.
GetID()
Accessor - Returns the service body ID as an integer.
SetContactEmail($in_email)
Accessor - set the contact email string.
SetOwnerID($in_sb_owner)
Accessor - Sets the ID of the &#39;owner&#39; of this object.
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.
SetOwner2ID($in_sb_owner)
Accessor - Sets the ID of the &#39;secondary owner&#39; of this object.
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.
SerializeObject ( )

Returns a storable serialization of the object, as a string.

This is only used for the changes, as the serialized string may not be easily searched.

Returns
a string, containing the table array, in serialized form.

Implements i_comdef_serialized.

Definition at line 827 of file c_comdef_service_body.class.php.

828  {
829  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
830  $serialize_array = array(
831  $this->_id_bigint,
832  $this->_principal_user_bigint,
833  $this->_editors_string,
834  $this->_kml_file_uri_string,
835  $this->_uri_string,
836  $this->GetWorldID(),
837  $this->GetLocalName(),
838  $this->GetLocalDescription(),
839  $this->GetLocalLang(),
840  $this->_sb_type,
841  $this->_sb_owner,
842  $this->_sb_owner_2,
843  $this->GetContactEmail()
844  );
845 
846  return serialize($serialize_array);
847  }
GetLocalDescription()
Accessor -Returns a reference to the _local_type_desc_string data member.
GetLocalLang()
Returns a reference to the local language setting.
GetLocalName()
Accessor -Returns a reference to the _local_type_name_string data member.
GetWorldID()
Accessor -Returns a reference to the _world_type_worldid_mixed data member.
GetContactEmail($in_recursive=false)
Get the contact email for this Service Body. If $in_recursive is false, then it simply looks at this ...
SetContactEmail (   $in_email)

Accessor - set the contact email string.

Parameters
$in_emailA string. The email address to be set.

Definition at line 622 of file c_comdef_service_body.class.php.

624  {
625  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
626  $this->_sb_meeting_email = $in_email;
627  }
SetEditors (   $in_editor_id_array)

Accessor - Sets the editors by ID.

Returns
the processed string.
Parameters
$in_editor_id_arrayAn array of integers, containing the user IDs.

Definition at line 795 of file c_comdef_service_body.class.php.

References _USER_LEVEL_SERVER_ADMIN, and c_comdef_server\GetOneUser().

797  {
798  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
799  foreach ($in_editor_id_array as &$id) {
800  // We need valid, non-server admin IDs.
801  if ($id == $this->GetPrincipalUserID()) {
802  unset($id);
803  } else {
804  $user = c_comdef_server::GetOneUser($id);
805  if (($user instanceof c_comdef_user) && ($user->GetUserLevel() != _USER_LEVEL_SERVER_ADMIN)) {
806  unset($id);
807  } else {
808  $id = intval($id); // Just to be tinfoil...
809  }
810  }
811  }
812 
813  $this->_editors_string = implode(",", $in_editor_id_array);
814 
815  return $this->_editors_string;
816  }
static GetOneUser($in_id_bigint)
Given an ID for a user, it returns one instance.
This class handles BMLT users. One instance is created for each user on the server.
const _USER_LEVEL_SERVER_ADMIN
$_editors_string
A string, containing a CSV list of integers, each an ID for a user that has editor privileges for mee...
GetPrincipalUserID()
Accessor - Returns the principal user for this service body.
SetHelpline (   $in_helpline_string)

Accessor - Sets the URI of the KML file for the Service Boundaries.

Parameters
$in_helpline_stringA string, containing the helpline number

Definition at line 588 of file c_comdef_service_body.class.php.

590  {
591  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
592  $this->_kml_file_uri_string = $in_helpline_string;
593  }
SetID (   $in_service_body_id_bigint)

Accessor - Sets the service body ID as an integer.

Parameters
$in_service_body_id_bigintAn integer, with the service body ID.

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

376  {
377  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
378  $this->_id_bigint = $in_service_body_id_bigint;
379  }
SetOwner2ID (   $in_sb_owner)

Accessor - Sets the ID of the 'secondary owner' of this object.

Parameters
$in_sb_ownerAn integer, containing the owner of the object.

Definition at line 523 of file c_comdef_service_body.class.php.

525  {
526  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
527  $this->_sb_owner_2 = intval($in_sb_owner);
528  }
SetOwner2Obj ( $in_sb_owner_obj)

Accessor - Sets the ID of the 'secondary owner' of this object by sending in an object reference.

This will test, to ensure that a loop will not occur. The function will return false if it determines that the hierarchy would result in this object being its own ancestor.

Returns
true, if successful, false, if the ID would cause a loop.
Parameters
$in_sb_owner_objAn integer, containing the secondary owner of the object.

Definition at line 561 of file c_comdef_service_body.class.php.

563  {
564  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
565  if ($in_sb_owner_obj instanceof c_comdef_service_body) {
566  return $this->SetOwner2ID($in_sb_owner_obj->GetID());
567  }
568 
569  return false;
570  }
A Class for Service Body Objects.
SetOwner2ID($in_sb_owner)
Accessor - Sets the ID of the &#39;secondary owner&#39; of this object.
SetOwnerID (   $in_sb_owner)

Accessor - Sets the ID of the 'owner' of this object.

Parameters
$in_sb_ownerAn integer, containing the owner of the object.

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

Referenced by c_comdef_admin_ajax_handler\HandleServiceBodyCreate().

514  {
515  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
516  $this->_sb_owner = intval($in_sb_owner);
517  }
SetOwnerObj ( $in_sb_owner_obj)

Accessor - Sets the ID of the 'owner' of this object by sending in an object reference.

This will test, to ensure that a loop will not occur. The function will return false if it determines that the hierarchy would result in this object being its own ancestor.

Returns
true, if successful, false, if the ID would cause a loop.
Parameters
$in_sb_owner_objAn integer, containing the owner of the object.

Definition at line 540 of file c_comdef_service_body.class.php.

542  {
543  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
544  if ($in_sb_owner_obj instanceof c_comdef_service_body) {
545  return $this->SetOwnerID($in_sb_owner_obj->GetID());
546  }
547 
548  return false;
549  }
A Class for Service Body Objects.
SetOwnerID($in_sb_owner)
Accessor - Sets the ID of the &#39;owner&#39; of this object.
SetPrincipalUserID (   $in_principal_user_id_bigint)

Accessor - Sets the principal user for this service body.

Parameters
$in_principal_user_id_bigintInteger, the principal user ID.

Definition at line 409 of file c_comdef_service_body.class.php.

411  {
412  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
413  return $this->_principal_user_bigint = $in_principal_user_id_bigint;
414  }
SetSBType (   $in_sb_type)

Accessor - Sets the URI of the KML file for the Service Boundaries.

Definition at line 441 of file c_comdef_service_body.class.php.

453  {
454  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
455  $this->_sb_type = $in_sb_type;
456  }
SetURI (   $in_uri_string)

Accessor - Sets the URI of a site with more information on the Service Body.

Parameters
$in_uri_stringA string, containing the URI

Definition at line 611 of file c_comdef_service_body.class.php.

613  {
614  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
615  $this->_uri_string = $in_uri_string;
616  }
static UnserializeObject (   $in_parent,
  $serialized_string 
)
static

This takes the serialized table, and instantiates a new object from it.

Returns
a new instance of c_comdef_service_body, set up according to the serialized data passed in.
Parameters
$in_parentThe parent object.
$serialized_stringA string containing the serialized data.

Implements i_comdef_serialized.

Definition at line 857 of file c_comdef_service_body.class.php.

860  {
861  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
862  list ( $_id_bigint,
866  $_uri_string,
867  $_worldid_mixed,
868  $_name_string,
869  $_description_string,
870  $_lang_enum,
871  $sb_type,
872  $sb_owner,
873  $sb_owner_2,
874  $sb_meeting_email ) = unserialize($serialized_string);
875 
876  return new c_comdef_service_body($in_parent, $_id_bigint, $_principal_user_bigint, $_editors_string, $_kml_file_uri_string, $_uri_string, $_name_string, $_description_string, $_lang_enum, $_worldid_mixed, $sb_type, $sb_owner, $sb_owner_2, $sb_meeting_email);
877  }
$_uri_string
A string, containing a URI to a site that gives further information about the Service Body...
A Class for Service Body Objects.
$_kml_file_uri_string
A string, containing the helpline (re-used KML file URI).
$_principal_user_bigint
An integer, with the ID of the principal administrator for this Service Body.
$_editors_string
A string, containing a CSV list of integers, each an ID for a user that has editor privileges for mee...
$_id_bigint
An integer, containing the unique ID of this service body.
UpdateToDB (   $is_rollback = false)

Updates or adds this instance to the database.

Returns
true if successful, false, otherwise.
Exceptions
aPDOException if there is a problem.
Parameters
$is_rollbackIf true, this is a rollback operation.

Definition at line 99 of file c_comdef_service_body.class.php.

References $_COMDEF_DEBUG, $ret, c_comdef_server\AddNewChange(), c_comdef_server\GetCurrentUserObj(), c_comdef_server\GetServiceBodyByIDObj(), c_comdef_dbsingleton\preparedExec(), and c_comdef_dbsingleton\preparedQuery().

101  {
102  $ret = false;
103 
105 
106  if ($this->UserCanEdit($user)) {
107  // We take a snapshot of the service body as it currently sits in the database as a "before" image.
108  $before = null;
109  $before_id = null;
110  $before_lang = null;
111  $before_obj = c_comdef_server::GetServiceBodyByIDObj($this->GetID());
112 
113  if ($before_obj instanceof c_comdef_service_body) {
114  $before_obj = clone $before_obj;
115  if ($before_obj instanceof c_comdef_service_body) {
116  $before_obj->RestoreFromDB();
117 
118  $before = $before_obj->SerializeObject();
119  $before_id = $before_obj->GetID();
120  $before_lang = $before_obj->GetLocalLang();
121  $before_obj = null;
122  }
123  }
124 
125  $this->DeleteFromDB_NoRecord();
126 
127  try {
128  $update = array();
129  if ($this->_id_bigint) {
130  array_push($update, $this->_id_bigint);
131  }
132 
133  array_push($update, $this->_principal_user_bigint);
134  array_push($update, $this->_editors_string);
135  array_push($update, $this->_kml_file_uri_string);
136  array_push($update, $this->_uri_string);
137  array_push($update, $this->GetLocalName());
138  array_push($update, $this->GetLocalDescription());
139  array_push($update, $this->GetLocalLang());
140  array_push($update, $this->GetWorldID());
141  array_push($update, $this->GetSBType());
142  array_push($update, $this->GeTOwnerID());
143  array_push($update, $this->GeTOwner2ID());
144  array_push($update, $this->GetContactEmail());
145 
146  $sql = "INSERT INTO `".c_comdef_server::GetServiceBodiesTableName_obj()."` (";
147  if ($this->_id_bigint) {
148  $sql .= "`id_bigint`,";
149  }
150  $sql .= "`principal_user_bigint`,`editors_string`,`kml_file_uri_string`,`uri_string`,`name_string`,`description_string`,`lang_enum`,`worldid_mixed`,`sb_type`,`sb_owner`,`sb_owner_2`,`sb_meeting_email`) VALUES (";
151  if ($this->_id_bigint) {
152  $sql .= "?,";
153  }
154  $sql .= "?,?,?,?,?,?,?,?,?,?,?,?)";
155  c_comdef_dbsingleton::preparedExec($sql, $update);
156  // If this is a new user, then we'll need to fetch the ID.
157  if (!$this->_id_bigint) {
158  $sql = "SELECT LAST_INSERT_ID()";
160  if (is_array($rows) && count($rows)) {
161  $this->_id_bigint = intval($rows[0]['last_insert_id()']);
162  }
163  }
164 
165  $after = $this->SerializeObject();
166  $after_id = $this->GetID();
167  $after_lang = $this->GetLocalLang();
168  $cType = (true == $is_rollback) ? 'comdef_change_type_rollback' : ((null != $before) ? 'comdef_change_type_change' : 'comdef_change_type_new');
169  c_comdef_server::AddNewChange($user->GetID(), $cType, $after_id, $before, $after, 'c_comdef_service_body', $before_id, $after_id, $before_lang, $after_lang);
170 
171  $ret = true;
172  } catch (Exception $ex) {
173  global $_COMDEF_DEBUG;
174 
175  if ($_COMDEF_DEBUG) {
176  echo "Exception Thrown in c_comdef_service_body::UpdateToDB()!<br />";
177  var_dump($ex);
178  }
179  throw ( $ex );
180  }
181  }
182 
183  return $ret;
184  }
GetLocalDescription()
Accessor -Returns a reference to the _local_type_desc_string data member.
A Class for Service Body Objects.
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.
GetID()
Accessor - Returns the service body ID as an integer.
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.
SerializeObject()
Returns a storable serialization of the object, as a string.
GetLocalName()
Accessor -Returns a reference to the _local_type_name_string data member.
$ret
Definition: contact.php:226
static preparedQuery($sql, $params=array(), $fetchKeyPair=false)
Wrapper for preparing and executing a PDOStatement that returns a resultset e.g. SELECT SQL statement...
UserCanEdit($in_user_object=null)
Test to see if a user is allowed to edit an instance (change the data). Service Body Administrators t...
GetSBType()
Accessor - Returns the Service Body Type.
static GetServiceBodyByIDObj($in_service_body_id_bigint)
Get the object for a single service body, given an ID.
DeleteFromDB_NoRecord()
Deletes this instance from the database without creating a change record.
global $_COMDEF_DEBUG
This flag, when set to true, will cause extra debug information to be output.
static GetCurrentUserObj($in_is_ajax=false)
Get the current logged-in user, as a c_comdef_user instance.
GetWorldID()
Accessor -Returns a reference to the _world_type_worldid_mixed data member.
GetContactEmail($in_recursive=false)
Get the contact email for this Service Body. If $in_recursive is false, then it simply looks at this ...
UserCanEdit (   $in_user_object = null)

Test to see if a user is allowed to edit an instance (change the data). Service Body Administrators that are Editors in parent, or secondary parent Service bodies can edit the Service body.

Returns
true, if the user is allowed to edit, false, otherwise.
Parameters
$in_user_objectA reference to a c_comdef_user object, for the user to be validated. If null, or not supplied, the server current user is tested.

Implements i_comdef_auth.

Definition at line 977 of file c_comdef_service_body.class.php.

References $ret, _USER_LEVEL_SERVICE_BODY_ADMIN, c_comdef_server\GetCurrentUserObj(), c_comdef_server\GetServiceBodyByIDObj(), and c_comdef_server\IsUserServerAdmin().

979  {
980  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
981  $ret = false;
982 
983  // We load the server user if one wasn't supplied.
984  if (null == $in_user_object) {
985  $in_user_object = c_comdef_server::GetCurrentUserObj();
986  }
987 
988  // If it isn't a user object, we fail right there.
989  if ($in_user_object instanceof c_comdef_user) {
990  $in_user_object->RestoreFromDB(); // The reason you do this, is to ensure that the user wasn't modified "live." It's a security precaution.
991 
992  // User must be a Service Body Admin
993  if ($in_user_object->GetUserLevel() == _USER_LEVEL_SERVICE_BODY_ADMIN) {
994  // If there is an existing object, then we can't make changes unless it's allowed in the existing object.
995  $current_obj = c_comdef_server::GetServiceBodyByIDObj($this->GetID());
996 
997  $new_obj = false;
998 
999  // If there is no current object, then we are a new service body. Otherwise, block dope fiends by reloading.
1000  if ($current_obj instanceof c_comdef_service_body) {
1001  // We clone, in case changes have been made, and we don't want to screw them up.
1002  $current_obj = clone $current_obj;
1003  $current_obj->RestoreFromDB();
1004  } else {
1005  $current_obj = $this;
1006  }
1007 
1008  if ($current_obj instanceof c_comdef_service_body) {
1009  if (intval($current_obj->GetPrincipalUserID()) == intval($in_user_object->GetID())) {
1010  $ret = true;
1011  } else if ($this->GetOwnerID()) {
1013 
1014  if ($parent instanceof c_comdef_service_body) {
1015  $ret = $parent->UserCanEdit($in_user_object);
1016  }
1017  }
1018  }
1019  } elseif (c_comdef_server::IsUserServerAdmin()) { // The server admin can edit anything.
1020  $ret = true;
1021  }
1022  }
1023 
1024  return $ret;
1025  }
A Class for Service Body Objects.
GetID()
Accessor - Returns the service body ID as an integer.
This class handles BMLT users. One instance is created for each user on the server.
$ret
Definition: contact.php:226
const _USER_LEVEL_SERVICE_BODY_ADMIN
static GetServiceBodyByIDObj($in_service_body_id_bigint)
Get the object for a single service body, given an ID.
GetOwnerID()
Accessor - Returns the ID of the &#39;owner&#39; of this 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.
UserCanEditMeetings (   $in_user_object = null)

Test to see if a user is allowed to edit meetings in this Service body.

Returns
true, if the user is allowed to edit, false, otherwise.
Parameters
$in_user_objectA reference to a c_comdef_user object, for the user to be validated. If null, or not supplied, the server current user is tested.

Definition at line 886 of file c_comdef_service_body.class.php.

References $ret, _USER_LEVEL_SERVICE_BODY_ADMIN, c_comdef_server\GetCurrentUserObj(), and c_comdef_server\GetServiceBodyByIDObj().

888  {
889  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
890  $ret = $this->UserCanEdit($in_user_object); // First, see if we are able to edit this Service body. If so, then we're golden.
891 
892  if (!$ret) { // If not, then see if we are able to edit as a "guest."
893  if (null == $in_user_object) {
894  $in_user_object = c_comdef_server::GetCurrentUserObj();
895  }
896 
897  if ($in_user_object instanceof c_comdef_user) {
898  $in_user_object->RestoreFromDB(); // The reason you do this, is to ensure that the user wasn't modified "live." It's a security precaution.
899 
900  $editors = $this->GetEditors();
901 
902  foreach ($editors as $id) {
903  if (($in_user_object->GetID() == $id) && ($in_user_object->GetUserLevel() == _USER_LEVEL_SERVICE_BODY_ADMIN)) {
904  $ret = true;
905  break;
906  }
907  }
908 
909  if (!$ret) {
910  if ($this->GetOwnerID()) {
912 
913  if ($parent instanceof c_comdef_service_body) {
914  $ret = $parent->UserCanEditMeetings($in_user_object);
915  }
916  }
917  }
918  }
919  }
920 
921  return $ret;
922  }
A Class for Service Body Objects.
This class handles BMLT users. One instance is created for each user on the server.
$ret
Definition: contact.php:226
const _USER_LEVEL_SERVICE_BODY_ADMIN
UserCanEdit($in_user_object=null)
Test to see if a user is allowed to edit an instance (change the data). Service Body Administrators t...
GetEditors()
Accessor - Returns IDs for all the editors.
static GetServiceBodyByIDObj($in_service_body_id_bigint)
Get the object for a single service body, given an ID.
GetOwnerID()
Accessor - Returns the ID of the &#39;owner&#39; of this object.
static GetCurrentUserObj($in_is_ajax=false)
Get the current logged-in user, as a c_comdef_user instance.
UserCanObserve (   $in_user_object = null)

Test to see if a user is allowed to observe in this Service body.

Returns
true, if the user is allowed to observe, false, otherwise.
Parameters
$in_user_objectA reference to a c_comdef_user object, for the user to be validated. If null, or not supplied, the server current user is tested.

Definition at line 931 of file c_comdef_service_body.class.php.

References $ret, _USER_LEVEL_OBSERVER, _USER_LEVEL_SERVICE_BODY_ADMIN, c_comdef_server\GetCurrentUserObj(), and c_comdef_server\GetServiceBodyByIDObj().

933  {
934  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
935  $ret = $this->UserCanEdit($in_user_object); // First, see if we are able to edit this Service body. If so, then we're golden.
936 
937  if (!$ret) { // If not, then see if we are able to edit as a "guest."
938  if (null == $in_user_object) {
939  $in_user_object = c_comdef_server::GetCurrentUserObj();
940  }
941 
942  if ($in_user_object instanceof c_comdef_user) {
943  $in_user_object->RestoreFromDB(); // The reason you do this, is to ensure that the user wasn't modified "live." It's a security precaution.
944 
945  $editors = $this->GetEditors();
946 
947  foreach ($editors as $id) {
948  if (($in_user_object->GetID() == $id) && (($in_user_object->GetUserLevel() == _USER_LEVEL_SERVICE_BODY_ADMIN) || ($in_user_object->GetUserLevel() == _USER_LEVEL_OBSERVER))) {
949  $ret = true;
950  break;
951  }
952  }
953 
954  if (!$ret) {
955  if ($this->GetOwnerID()) {
957 
958  if ($parent instanceof c_comdef_service_body) {
959  $ret = $parent->UserCanObserve($in_user_object);
960  }
961  }
962  }
963  }
964  }
965 
966  return $ret;
967  }
A Class for Service Body Objects.
This class handles BMLT users. One instance is created for each user on the server.
$ret
Definition: contact.php:226
const _USER_LEVEL_SERVICE_BODY_ADMIN
const _USER_LEVEL_OBSERVER
UserCanEdit($in_user_object=null)
Test to see if a user is allowed to edit an instance (change the data). Service Body Administrators t...
GetEditors()
Accessor - Returns IDs for all the editors.
static GetServiceBodyByIDObj($in_service_body_id_bigint)
Get the object for a single service body, given an ID.
GetOwnerID()
Accessor - Returns the ID of the &#39;owner&#39; of this object.
static GetCurrentUserObj($in_is_ajax=false)
Get the current logged-in user, as a c_comdef_user instance.

Member Data Documentation

$_editors_string = null
private

A string, containing a CSV list of integers, each an ID for a user that has editor privileges for meetings for this Service Body.

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

$_id_bigint = null
private

An integer, containing the unique ID of this service body.

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

$_kml_file_uri_string = null
private

A string, containing the helpline (re-used KML file URI).

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

$_principal_user_bigint = null
private

An integer, with the ID of the principal administrator for this Service Body.

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

$_sb_meeting_email = null
private

A string that contains the meeting contact email address.

Definition at line 89 of file c_comdef_service_body.class.php.

$_sb_owner = null
private

An integer. The ID of the Service Body that "owns" this one.

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

$_sb_owner_2 = null
private

An integer. Some Service Bodies can have "unofficial" "owners" (like Zonal Forums or Metro Areas).

Definition at line 87 of file c_comdef_service_body.class.php.

$_sb_type = null
private

An enum string, containing the Service Body type. It can be one of the following:

  • c_comdef_service_body__GRP__ Individual NA Group
  • c_comdef_service_body__ASC__ Area Service Committee
  • c_comdef_service_body__RSC__ Regional Service Committee
  • c_comdef_service_body__WSC__ World Service Committee
  • c_comdef_service_body__MAS__ Metro Area
  • c_comdef_service_body__ZFM__ Zonal Forum
  • c_comdef_service_body__GSU__ Group Service Unit
  • c_comdef_service_body__LSU__ Local Service Unit

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

$_uri_string = null
private

A string, containing a URI to a site that gives further information about the Service Body.

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


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