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

This class handles BMLT users. One instance is created for each user on the server. More...

Public Member Functions

 UpdateToDB ($is_rollback=false, $new_login=null, $new_pass=null)
 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...
 
 ResetChildUsers ()
 
 RestoreFromDB ()
 Updates this instance to the current values in the DB (replacing current values of the instance). More...
 
 __construct ($in_parent_obj, $in_id_bigint, $in_user_level_tinyint, $in_email_address_string, $in_login_string, $in_password_string, $in_lang_enum, $in_name_string, $in_description_string, $in_owner_id_bigint=-1, $in_last_access=null)
 The initial setup call for the class. If you send in values, the object will set itself up to use them. More...
 
 IsEnabled ()
 Returns true if the user is enabled (levels 1-3) More...
 
 GetID ()
 Accessor - Returns the user ID as an integer. More...
 
 SetID ($in_user_id_bigint)
 Accessor - Sets the user ID as an integer. More...
 
 GetOwnerID ()
 Accessor - Gets the owner ID as an integer. More...
 
 SetOwnerID ($in_owner_id_bigint)
 Accessor - Sets the owner ID as an integer. More...
 
 GetUserLevel ()
 Accessor - Returns the user level as an integer. More...
 
 SetUserLevel ($in_user_level_tinyint)
 Accessor - Sets the user level. Attempts to set the user level to 1 for users other than User 1 will fail. More...
 
 GetEmailAddress ()
 Accessor - Returns the user email address. More...
 
 SetEmailAddress ($in_email_address_string)
 Accessor - Sets the user email address. More...
 
 GetLogin ()
 Accessor - Returns the user login. More...
 
 SetLogin ($in_login_string)
 Accessor - Sets the userlogin. More...
 
 IsUser ($in_login_string, $in_password_string, $in_pw_raw=false)
 See if this is the given user by login and password. More...
 
 GetPassword ()
 Accessor - Returns the user password, in encrypted form. More...
 
 SetPassword ($in_password_string)
 Accessor - Sets the password, as an encrypted string. More...
 
 SetNewPassword ($in_password_unencrypted_string)
 Accessor - Sets the password, encrypting it. More...
 
 GetLastAccess ()
 Accessor - Gets the last access time. More...
 
 SetLastAccess ($in_time=null)
 Simply sets the last access time to now. More...
 
 SerializeObject ()
 Returns a storable serialization of the object, as a string. More...
 
 UserCanEdit ($in_user_object=null)
 Test to see if a user is allowed to edit an instance (change the data). 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 user. More...
 
 $_user_level_tinyint = null
 An integer, containing the user level. More...
 
 $_email_address_string = null
 A string, containing the user's email address. More...
 
 $_login_string = null
 A string, containing the user's login ID. More...
 
 $_password_string = null
 A string, containing the user's encrypted password. More...
 
 $_last_access = null
 A time date, indicating the last time the user was active. This will be useful for administration. More...
 
 $_owner_id_bigint = -1
 An integer containing the id of the user that owns this user. More...
 

Detailed Description

This class handles BMLT users. One instance is created for each user on the server.

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

Constructor & Destructor Documentation

__construct (   $in_parent_obj,
  $in_id_bigint,
  $in_user_level_tinyint,
  $in_email_address_string,
  $in_login_string,
  $in_password_string,
  $in_lang_enum,
  $in_name_string,
  $in_description_string,
  $in_owner_id_bigint = -1,
  $in_last_access = null 
)

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

Parameters
$in_parent_objA reference to the parent object for this object
$in_id_bigintInteger. The ID of the user
$in_email_address_stringA string, containing the user's email address.
$in_login_stringA string, containing the user's login.
$in_password_stringA string, containing the user's password, in encrypted form.
$in_lang_enumAn enum/string, with the user's language.
$in_name_stringA string, containing the readble name for the user.
$in_description_stringA string, containing a description of the user.
$in_owner_id_bigintAn integer containing the id of the user that owns this user.
$in_last_accessAn epoch time, indicating the last access of this user (Optional).

Definition at line 336 of file c_comdef_user.class.php.

373  {
374  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
375  // Set the four inherited values.
376  $this->SetParentObj($in_parent_obj);
377  $this->SetLocalLang($in_lang_enum);
378  $this->SetLocalName($in_name_string);
379  $this->SetLocalDescription($in_description_string);
380 
381  // Set the local values.
382  $this->_id_bigint = $in_id_bigint;
383  $this->_user_level_tinyint = $in_user_level_tinyint;
384  $this->_email_address_string = $in_email_address_string;
385  $this->_login_string = $in_login_string;
386  $this->_password_string = $in_password_string;
387  $this->_owner_id_bigint = $in_owner_id_bigint;
388  $this->_last_access = $in_last_access;
389  }
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.
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, 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 236 of file c_comdef_user.class.php.

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

237  {
238  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
239  $ret = false;
240 
242 
243  if ($this->UserCanEdit($user)) {
244  // We take a snapshot of the user as it currently sits in the database as a "before" image.
245  $before = null;
246  $before_id = null;
247  $before_lang = null;
248  $before_obj = c_comdef_server::GetOneUser($this->GetID());
249 
250  if ($before_obj instanceof c_comdef_user) {
251  $before = $before_obj->SerializeObject();
252  $before_id = $before_obj->GetID();
253  $before_lang = $before_obj->GetLocalLang();
254  $before_obj = null;
255  }
256 
257  $ret = $this->DeleteFromDB_NoRecord();
258 
259  if ($ret) {
260  c_comdef_server::AddNewChange($user->GetID(), 'comdef_change_type_delete', $this->GetID(), $before, null, 'c_comdef_user', $before_id, null, $before_lang, null);
261  }
262  }
263 
264  return $ret;
265  }
static AddNewChange($in_user_id_bigint, $in_change_type, $in_service_body_id_bigint, $in_before_string, $in_after_string, $in_object_class_string, $in_before_obj_id_bigint, $in_after_obj_id_bigint, $in_before_obj_lang_enum=null, $in_after_obj_lang_enum=null, $in_name_string=null, $in_description_string=null, $in_lang_enum=null)
Creates a new change record in the Database.
static 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.
$ret
Definition: contact.php:226
GetID()
Accessor - Returns the user ID as an integer.
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.
UserCanEdit($in_user_object=null)
Test to see if a user is allowed to edit an instance (change the data).
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 204 of file c_comdef_user.class.php.

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

205  {
206  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
207  $ret = false;
208 
209  if ($this->UserCanEdit()) {
210  try {
211  $sql = "DELETE FROM `".c_comdef_server::GetUserTableName_obj()."` WHERE id_bigint=?";
212  c_comdef_dbsingleton::preparedExec($sql, array ( $this->GetID() ));
213  $ret = true;
214  } catch (Exception $ex) {
215  global $_COMDEF_DEBUG;
216 
217  if ($_COMDEF_DEBUG) {
218  echo "Exception Thrown in c_comdef_user::DeleteFromDB()!<br />";
219  var_dump($ex);
220  }
221  throw ( $ex );
222  }
223  }
224 
225  return $ret;
226  }
static preparedExec($sql, $params=array())
Wrapper for preparing and executing a PDOStatement that does not return a resultset e...
$ret
Definition: contact.php:226
GetID()
Accessor - Returns the user ID as an integer.
global $_COMDEF_DEBUG
This flag, when set to true, will cause extra debug information to be output.
UserCanEdit($in_user_object=null)
Test to see if a user is allowed to edit an instance (change the data).
GetEmailAddress ( )

Accessor - Returns the user email address.

Returns
a string, containing the user email address.

Definition at line 531 of file c_comdef_user.class.php.

532  {
533  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
535  }
$_email_address_string
A string, containing the user&#39;s email address.
GetID ( )

Accessor - Returns the user ID as an integer.

Returns
an integer, containing the user ID.

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

410  {
411  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
412  return $this->_id_bigint;
413  }
$_id_bigint
An integer, containing the unique ID of this user.
GetLastAccess ( )

Accessor - Gets the last access time.

Returns
an epoch time that contains the last access time.

Definition at line 689 of file c_comdef_user.class.php.

690  {
691  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
692  return $this->_last_access;
693  }
$_last_access
A time date, indicating the last time the user was active. This will be useful for administration...
GetLogin ( )

Accessor - Returns the user login.

Returns
a string, containing the user login.

Definition at line 554 of file c_comdef_user.class.php.

555  {
556  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
557  return $this->_login_string;
558  }
$_login_string
A string, containing the user&#39;s login ID.
GetOwnerID ( )

Accessor - Gets the owner ID as an integer.

Definition at line 430 of file c_comdef_user.class.php.

431  {
432  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
434  }
$_owner_id_bigint
An integer containing the id of the user that owns this user.
GetPassword ( )

Accessor - Returns the user password, in encrypted form.

Returns
a string, containing the user password, as an encrypted hash.

Definition at line 636 of file c_comdef_user.class.php.

637  {
638  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
640  }
$_password_string
A string, containing the user&#39;s encrypted password.
GetUserLevel ( )

Accessor - Returns the user level as an integer.

Returns
an integer, containing the user level. Values:
  • (1) Server Administrator -There can only be one. The user ID is always 1. This administrator can edit all aspects of the server.
  • (2) Service Body Administrator -There can only be one per Service Body A Service Body Administrator can edit all meetings from the Service Body that assigns the user as its administrator. This user can also assign other Service Body Administrators or Editors as users able to edit meetings belonging to the Service Body. A Service Body Administrator can also edit Service Body information. NOTE: A Service Body Administrator only has extra rights when assigned to a specific Service Body. If assigned as an Editor on another Service Body, they do not have rights beyond those of an Editor.
  • (3) Editor -There can be many. An Editor is assigned by a Service Body Administrator to edit meetings for that Service Body. They can only edit meetings; not users or Service Bodies. Making a user an editor (or a Service Body Administrator) doesn't automatically give them any rights. They must first be assigned to a Service Body, either by the Server Administrator (Service Body Administrators), or by a Service Body Administrator (Editors).
  • (4) User Disabled.
  • (5) Observer -User can see private data in meetings for which it is authorized.

Definition at line 475 of file c_comdef_user.class.php.

476  {
477  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
478  // We reload ourselves from the database first, just to avoid shenanigans...
479  $this->RestoreFromDB();
481  }
$_user_level_tinyint
An integer, containing the user level.
RestoreFromDB()
Updates this instance to the current values in the DB (replacing current values of the instance)...
IsEnabled ( )

Returns true if the user is enabled (levels 1-3)

Returns
a Boolean. true if enabled, false if not.

Definition at line 397 of file c_comdef_user.class.php.

References _USER_LEVEL_DISABLED.

398  {
399  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
400  return ($this->_user_level_tinyint > 0) && ($this->_user_level_tinyint != _USER_LEVEL_DISABLED);
401  }
const _USER_LEVEL_DISABLED
IsUser (   $in_login_string,
  $in_password_string,
  $in_pw_raw = false 
)

See if this is the given user by login and password.

The login is case-insensitive, but the password is not.

Returns
true, if so, false if not.
Parameters
$in_login_stringA string, containing the user's login.
$in_password_stringA string, containing the user's password, in encrypted form, or unencrypted, if $in_pw_raw is true.
$in_pw_rawA Boolean, true if the password has not been encrypted.

Definition at line 612 of file c_comdef_user.class.php.

616  {
617  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
618  $login_match = (strcasecmp($in_login_string, $this->GetLogin()) == 0);
619 
620  // See if we need to encrypt the password.
621  if ($in_pw_raw) {
622  $password_match = password_verify($in_password_string, $this->GetPassword());
623  } else {
624  $password_match = hash_equals($this->GetPassword(), $in_password_string);
625  }
626 
627  return $login_match && $password_match;
628  }
GetLogin()
Accessor - Returns the user login.
GetPassword()
Accessor - Returns the user password, in encrypted form.
ResetChildUsers ( )

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

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

269  {
270  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
271  $ret = false;
272 
273  try {
274  $sql = "UPDATE `".c_comdef_server::GetUserTableName_obj()."` SET owner_id_bigint=-1 WHERE owner_id_bigint=?";
275  c_comdef_dbsingleton::preparedExec($sql, array ( $this->GetID() ));
276  $ret = true;
277  } catch (Exception $ex) {
278  global $_COMDEF_DEBUG;
279 
280  if ($_COMDEF_DEBUG) {
281  echo "Exception Thrown in c_comdef_user::ResetChildUsers()!<br />";
282  var_dump($ex);
283  }
284  throw ( $ex );
285  }
286 
287  return $ret;
288  }
static preparedExec($sql, $params=array())
Wrapper for preparing and executing a PDOStatement that does not return a resultset e...
$ret
Definition: contact.php:226
GetID()
Accessor - Returns the user ID as an integer.
global $_COMDEF_DEBUG
This flag, when set to true, will cause extra debug information to be output.
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 297 of file c_comdef_user.class.php.

References $_COMDEF_DEBUG, and c_comdef_dbsingleton\preparedQuery().

298  {
299  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
300  try {
301  if ($this->GetID()) {
302  $sql = "SELECT * FROM `".c_comdef_server::GetUserTableName_obj()."` WHERE id_bigint=? LIMIT 1";
303  $rows = c_comdef_dbsingleton::preparedQuery($sql, array ( $this->GetID() ));
304  if (is_array($rows) && count($rows)) {
305  $this->_user_level_tinyint = $rows[0]['user_level_tinyint'];
306  $this->_email_address_string = $rows[0]['email_address_string'];
307  $this->_login_string = $rows[0]['login_string'];
308  $this->_password_string = $rows[0]['password_string'];
309  $this->_owner_id_bigint = $rows[0]['owner_id_bigint'];
310  $time = explode(" ", $rows[0]['last_access_datetime']);
311  $t0 = explode("-", $time[0]);
312  $t1 = explode(":", $time[1]);
313  $this->_last_access = mktime($t1[0], $t1[1], $t1[2], $t0[1], $t0[2], $t0[0]);
314  $this->SetLocalName($rows[0]['name_string']);
315  $this->SetLocalDescription($rows[0]['description_string']);
316  $this->SetLocalLang($rows[0]['lang_enum']);
317  }
318  }
319  } catch (Exception $ex) {
320  global $_COMDEF_DEBUG;
321 
322  if ($_COMDEF_DEBUG) {
323  echo "Exception Thrown in c_comdef_user::RestoreFromDB()!<br />";
324  var_dump($ex);
325  }
326  throw ( $ex );
327  }
328  }
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.
GetID()
Accessor - Returns the user ID as an integer.
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 715 of file c_comdef_user.class.php.

716  {
717  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
718  $serialize_array = array(
719  $this->_id_bigint,
720  $this->_user_level_tinyint,
721  $this->_email_address_string,
722  $this->_login_string,
723  $this->_password_string,
724  $this->_last_access,
725  $this->GetLocalName(),
726  $this->GetLocalDescription(),
727  $this->_owner_id_bigint,
728  $this->GetLocalLang()
729  );
730 
731  return serialize($serialize_array);
732  }
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.
SetEmailAddress (   $in_email_address_string)

Accessor - Sets the user email address.

Parameters
$in_email_address_stringA string, containing the user's email address.

Definition at line 541 of file c_comdef_user.class.php.

543  {
544  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
545  $this->_email_address_string = $in_email_address_string;
546  }
SetID (   $in_user_id_bigint)

Accessor - Sets the user ID as an integer.

Parameters
$in_user_id_bigintAn integer, with the user ID.

Definition at line 419 of file c_comdef_user.class.php.

421  {
422  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
423  $this->_id_bigint = $in_user_id_bigint;
424  }
SetLastAccess (   $in_time = null)

Simply sets the last access time to now.

Parameters
$in_timeAn epoch time. If not provided, now is used.

Definition at line 699 of file c_comdef_user.class.php.

701  {
702  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
703  $this->_last_access = (null != $in_time) ? $in_time : time();
704  }
SetLogin (   $in_login_string)

Accessor - Sets the userlogin.

Returns
true if successful, and false if not.
Parameters
$in_login_stringA string, containing the user's login.

Definition at line 566 of file c_comdef_user.class.php.

References $ret, and c_comdef_server\GetServer().

568  {
569  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
570  $ret = false;
571 
572  if ($in_login_string) {
573  $users_obj = c_comdef_server::GetServer()->GetServerUsersObj();
574 
575  // We are not allowed to select a login that is already in use. The comparison
576  // is case-insensitive.
577  if ($users_obj instanceof c_comdef_users) {
578  $obj_array = $users_obj->GetUsersArray();
579 
580  if (is_array($obj_array)) {
581  $ret = true;
582 
583  foreach ($obj_array as $one_user) {
584  // We don't worry if this is our own object.
585  if ($one_user->GetID() != $this->GetID()) {
586  if (strtolower($one_user->GetLogin()) == strtolower($in_login_string)) {
587  $ret = false;
588  break;
589  }
590  }
591  }
592 
593  // If we went through without a match, we change the login.
594  if ($ret) {
595  $this->_login_string = $in_login_string;
596  }
597  }
598  }
599  }
600 
601  return $ret;
602  }
$ret
Definition: contact.php:226
GetID()
Accessor - Returns the user ID as an integer.
A class to hold a collection of c_comdef_users objects.
SetNewPassword (   $in_password_unencrypted_string)

Accessor - Sets the password, encrypting it.

Returns
a string, containing the encrypted password. Returns null if none was provided.
Parameters
$in_password_unencrypted_stringA string, containing the user's password, in unencrypted form.

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

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

Referenced by c_comdef_admin_ajax_handler\HandleUserCreate().

665  {
666  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
667  if (trim($in_password_unencrypted_string)) {
669  $strings = $server->GetLocalStrings();
670  $min_pw_len = $strings['min_pw_len'];
671  if ($min_pw_len <= strlen(trim($in_password_unencrypted_string))) {
672  $this->SetPassword(FullCrypt(trim($in_password_unencrypted_string)), $this->GetPassword());
673 
674  return $this->GetPassword();
675  } else {
676  return null;
677  }
678  } else {
679  return null;
680  }
681  }
SetPassword($in_password_string)
Accessor - Sets the password, as an encrypted string.
FullCrypt($in_string, $in_salt=null, &$crypt_method=null)
Encrypts a string, using the most effective encryption.
GetPassword()
Accessor - Returns the user password, in encrypted form.
$server
Definition: GetLangs.php:25
SetOwnerID (   $in_owner_id_bigint)

Accessor - Sets the owner ID as an integer.

Definition at line 440 of file c_comdef_user.class.php.

442  {
443  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
444  $this->_owner_id_bigint = $in_owner_id_bigint;
445  }
SetPassword (   $in_password_string)

Accessor - Sets the password, as an encrypted string.

Parameters
$in_password_stringA string, containing the user's password, in encrypted form.

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

Referenced by NAWSImport\createServiceBodiesAndUsers().

648  {
649  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
650  if (trim($in_password_string)) {
651  $this->_password_string = trim($in_password_string);
652  } else {
653  return null;
654  }
655  }
SetUserLevel (   $in_user_level_tinyint)

Accessor - Sets the user level. Attempts to set the user level to 1 for users other than User 1 will fail.

Returns
true if successful, false otherwise.

Definition at line 490 of file c_comdef_user.class.php.

515  {
516  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
517  if (($this->_user_level_tinyint == 1) && ($this->_id_bigint > 1)) {
518  return false;
519  } else {
520  $this->_user_level_tinyint = $in_user_level_tinyint;
521  return true;
522  }
523  }
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_user, 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 742 of file c_comdef_user.class.php.

Referenced by c_comdef_change\GetAfterObject(), and c_comdef_change\GetBeforeObject().

745  {
746  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
747  list ( $_id_bigint,
753  $_local_name,
754  $_local_description,
756  $_local_lang ) = unserialize($serialized_string);
757 
758  return new c_comdef_user($in_parent, $_id_bigint, $_user_level_tinyint, $_email_address_string, $_login_string, $_password_string, $_local_lang, $_local_name, $_local_description, $_owner_id_bigint, $_last_access);
759  }
$_password_string
A string, containing the user&#39;s encrypted password.
$_login_string
A string, containing the user&#39;s login ID.
This class handles BMLT users. One instance is created for each user on the server.
$_id_bigint
An integer, containing the unique ID of this user.
$_last_access
A time date, indicating the last time the user was active. This will be useful for administration...
$_user_level_tinyint
An integer, containing the user level.
$_email_address_string
A string, containing the user&#39;s email address.
$_owner_id_bigint
An integer containing the id of the user that owns this user.
UpdateToDB (   $is_rollback = false,
  $new_login = null,
  $new_pass = null 
)

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.
$new_loginThis is a new login (Due to the self-checking, we can't set our own login before this). If it is null, no new password will be set.
$new_passThis is a new password (Due to the self-checking, we can't set our own pass before this). If it is null, no new password will be set.

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

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

103  {
104  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
105  $ret = false;
106 
108 
109  if ($cur_user instanceof c_comdef_user) {
110  $cur_user_clone = clone ( $cur_user ); // This little dance is to make sure that the live object wasn't changed.
111  $cur_user_clone->RestoreFromDB();
112 
113  if ($cur_user_clone->UserCanEdit($cur_user)) {
114  // We take a snapshot of the user as it currently sits in the database as a "before" image.
115  $before = null;
116  $before_id = null;
117  $before_lang = null;
118  $before_obj = c_comdef_server::GetOneUser($this->GetID());
119 
120  if ($before_obj instanceof c_comdef_user) {
121  $before_obj_clone = clone $before_obj;
122  $before_obj_clone->RestoreFromDB();
123  $before = $before_obj_clone->SerializeObject();
124  $before_id = $before_obj_clone->GetID();
125  $before_lang = $before_obj_clone->GetLocalLang();
126  $before_obj_clone = null;
127  }
128 
129  $this->DeleteFromDB_NoRecord();
130 
131  try {
132  $update = array();
133  if ($this->_id_bigint) {
134  array_push($update, $this->_id_bigint);
135  }
136  array_push($update, $this->_user_level_tinyint);
137  array_push($update, $this->_email_address_string);
138 
139  if (null != $new_login) {
140  $this->SetLogin($new_login);
141  }
142 
143  array_push($update, $this->_login_string);
144 
145  if (null != $new_pass) {
146  $this->SetNewPassword($new_pass);
147  }
148 
149  array_push($update, $this->GetPassword());
150  array_push($update, date("Y-m-d H:i:s", $this->_last_access));
151  array_push($update, $this->GetLocalName());
152  array_push($update, $this->GetLocalDescription());
153  array_push($update, $this->GetLocalLang());
154  array_push($update, $this->GetOwnerID());
155 
156  $sql = "INSERT INTO `".c_comdef_server::GetUserTableName_obj()."` (";
157  if ($this->_id_bigint) {
158  $sql .= "`id_bigint`,";
159  }
160  $sql .= "`user_level_tinyint`,`email_address_string`,`login_string`,`password_string`,`last_access_datetime`,`name_string`,`description_string`,`lang_enum`, `owner_id_bigint`) VALUES (";
161  if ($this->_id_bigint) {
162  $sql .= "?,";
163  }
164  $sql .= "?,?,?,?,?,?,?,?,?)";
165  c_comdef_dbsingleton::preparedExec($sql, $update);
166  // If this is a new user, then we'll need to fetch the ID.
167  if (!$this->_id_bigint) {
168  $sql = "SELECT LAST_INSERT_ID()";
170  if (is_array($rows) && count($rows)) {
171  $this->_id_bigint = intval($rows[0]['last_insert_id()']);
172  }
173  }
174 
175  $after = $this->SerializeObject();
176  $after_id = $this->GetID();
177  $after_lang = $this->GetLocalLang();
178  $cType = (true == $is_rollback) ? 'comdef_change_type_rollback' : ((null != $before) ? 'comdef_change_type_change' : 'comdef_change_type_new');
179  c_comdef_server::AddNewChange($cur_user->GetID(), $cType, null, $before, $after, 'c_comdef_user', $before_id, $after_id, $before_lang, $after_lang);
180  $ret = true;
181  } catch (Exception $ex) {
182  global $_COMDEF_DEBUG;
183 
184  if ($_COMDEF_DEBUG) {
185  echo "Exception Thrown in c_comdef_user::UpdateToDB()!<br />";
186  var_dump($ex);
187  }
188  throw ( $ex );
189  }
190  }
191  }
192 
193  return $ret;
194  }
GetLocalDescription()
Accessor -Returns a reference to the _local_type_desc_string data member.
static AddNewChange($in_user_id_bigint, $in_change_type, $in_service_body_id_bigint, $in_before_string, $in_after_string, $in_object_class_string, $in_before_obj_id_bigint, $in_after_obj_id_bigint, $in_before_obj_lang_enum=null, $in_after_obj_lang_enum=null, $in_name_string=null, $in_description_string=null, $in_lang_enum=null)
Creates a new change record in the Database.
static GetOneUser($in_id_bigint)
Given an ID for a user, it returns one instance.
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.
This class handles BMLT users. One instance is created for each user on the server.
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...
GetID()
Accessor - Returns the user ID as an integer.
SerializeObject()
Returns a storable serialization of the object, as a string.
GetOwnerID()
Accessor - Gets the owner ID as an integer.
GetPassword()
Accessor - Returns the user password, in encrypted form.
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.
SetNewPassword($in_password_unencrypted_string)
Accessor - Sets the password, encrypting it.
SetLogin($in_login_string)
Accessor - Sets the userlogin.
UserCanEdit (   $in_user_object = null)

Test to see if a user is allowed to edit an instance (change the data).

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 767 of file c_comdef_user.class.php.

References $ret, _USER_LEVEL_DISABLED, _USER_LEVEL_OBSERVER, c_comdef_server\GetCurrentUserObj(), c_comdef_server\IsUserServerAdmin(), and c_comdef_server\IsUserServiceBodyAdmin().

769  {
770  // phpcs:enable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
771  $ret = false;
772 
773  // We load the server user if one wasn't supplied.
774  if (null == $in_user_object) {
775  $in_user_object = c_comdef_server::GetCurrentUserObj();
776  }
777 
778  // We clone, in case changes have been made, and we don't want to screw them up.
779  $in_user_clone = clone $in_user_object;
780 
781  // If it isn't a user object, we fail right there.
782  if ($in_user_clone instanceof c_comdef_user) {
783  $in_user_clone->RestoreFromDB(); // The reason you do this, is to ensure that the user wasn't modified "live." It's a security precaution.
784  // Server admins can edit users. Service body administrators can edit users they own. Any user can edit itself.
785  if ($in_user_clone->GetUserLevel() == _USER_LEVEL_DISABLED) {
786  return false;
787  }
788 
789  if ($in_user_clone->GetUserLevel() == _USER_LEVEL_OBSERVER) {
790  return false;
791  }
792 
793  if ($in_user_clone->GetID() == $this->GetID()) {
794  return true;
795  }
796 
798  return true;
799  }
800 
802  return true;
803  }
804 
805  $in_user_clone = null;
806  }
807 
808  return $ret;
809  }
This class handles BMLT users. One instance is created for each user on the server.
$ret
Definition: contact.php:226
const _USER_LEVEL_OBSERVER
const _USER_LEVEL_DISABLED
GetID()
Accessor - Returns the user ID as an integer.
static IsUserServiceBodyAdmin($in_user_obj=null, $in_is_ajax=false)
Find out if the user is a service body admin.
GetOwnerID()
Accessor - Gets the owner ID as an integer.
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.

Member Data Documentation

$_email_address_string = null
private

A string, containing the user's email address.

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

$_id_bigint = null
private

An integer, containing the unique ID of this user.

Definition at line 45 of file c_comdef_user.class.php.

$_last_access = null
private

A time date, indicating the last time the user was active. This will be useful for administration.

Definition at line 86 of file c_comdef_user.class.php.

$_login_string = null
private

A string, containing the user's login ID.

Definition at line 80 of file c_comdef_user.class.php.

$_owner_id_bigint = -1
private

An integer containing the id of the user that owns this user.

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

$_password_string = null
private

A string, containing the user's encrypted password.

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

$_user_level_tinyint = null
private

An integer, containing the user level.

Values:

  • (1) Server Administrator -There can only be one. The user ID is always 1. This administrator can edit all aspects of the server.
  • (2) Service Body Administrator -There can only be one per Service Body A Service Body Administrator can edit all meetings from the Service Body that assigns the user as its administrator. This user can also assign other Service Body Administrators or Editors as users able to edit meetings belonging to the Service Body. A Service Body Administrator can also edit Service Body information. NOTE: A Service Body Administrator only has extra rights when assigned to a specific Service Body. If assigned as an Editor on another Service Body, they do not have rights beyond those of an Editor.
  • (3) Editor -There can be many. An Editor is assigned by a Service Body Administrator to edit meetings for that Service Body. They can only edit meetings; not users or Service Bodies. Making a user an editor (or a Service Body Administrator) doesn't automatically give them any rights. They must first be assigned to a Service Body, either by the Server Administrator (Service Body Administrators), or by a Service Body Administrator (Editors).
  • (4) User Disabled.
  • (5) Observer -There can be many. This user cannot make changes, but can see visibility 0 data items in meetings for the Service bodies to which it has been attached..

Definition at line 74 of file c_comdef_user.class.php.


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