Ejemplo n.º 1
0
 /**
  * Constructor
  * @param mixed $parameters If null, an empty Principal is created.  If it
  *              is an integer then that ID is read (if possible).  If it is
  *              an array then the Principal matching the supplied elements
  *              is read.  If it is an object then it is expected to be a 'usr'
  *              record that was read elsewhere.
  *
  * @return boolean Whether we actually read data from the DB to initialise the record.
  */
 function __construct($parameters = null)
 {
     global $session, $c;
     $this->exists = null;
     if ($parameters == null) {
         return;
     }
     if (is_object($parameters)) {
         dbg_error_log('principal', 'Principal: record for %s', $parameters->username);
         parent::__construct('username', $parameters->username);
     } else {
         if (is_int($parameters)) {
             dbg_error_log('principal', 'Principal: %d', $parameters);
             parent::__construct('principal_id', $parameters);
         } else {
             if (is_array($parameters)) {
                 if (!isset($parameters['options']['allow_by_email'])) {
                     $parameters['options']['allow_by_email'] = false;
                 }
                 if (isset($parameters['username'])) {
                     parent::__construct('username', $parameters['username']);
                 } else {
                     if (isset($parameters['user_no'])) {
                         parent::__construct('user_no', $parameters['user_no']);
                     } else {
                         if (isset($parameters['principal_id'])) {
                             parent::__construct('principal_id', $parameters['principal_id']);
                         } else {
                             if (isset($parameters['email'])) {
                                 parent::__construct('email', $parameters['email']);
                             } else {
                                 if (isset($parameters['path'])) {
                                     parent::__construct('path', $parameters['path']);
                                 } else {
                                     if (isset($parameters['principal-property-search'])) {
                                         $username = $this->PropertySearch($parameters['principal-property-search']);
                                         parent::__construct('username', $username);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (!$this->exists) {
         return;
     }
     $this->InitialiseRecord();
 }
Ejemplo n.º 2
0
 public function __construct($identity, $password, $name, array $aggregatedPrincipals = [], $privileged = false)
 {
     parent::__construct($identity, $name, $aggregatedPrincipals, $privileged);
     $this->password = (string) $password;
 }