示例#1
0
 /**
  * Sets the variable to the given value and updates the database, if allowed. If the property is unknown, the call is passed to parent class.
  * @access public
  * @param string $property The property to edit
  * @param mixed $value The value to set the property with
  */
 function __set($property, $value)
 {
     global $DB, $USER;
     $ipn = '_' . $property;
     switch ($property) {
         case 'password':
             if ($this->password == 'LDAP') {
                 break;
             }
             if (empty($value)) {
                 return false;
             }
             $value = pwdEncode($value);
             //NOTE: No break here
         //NOTE: No break here
         case 'username':
             if (empty($value)) {
                 return false;
             }
             Base::__set('Name', $value);
         case 'passwordhash':
             // passwordhash bypasses pwdEncode and sets the raw password hash.
             if (empty($value)) {
                 return false;
             }
             if ($property == 'passwordhash') {
                 $ipn = '_password';
                 $property = 'password';
             }
             if ($this->{$ipn} === $value) {
                 break;
             }
             $this->{$ipn} = $value;
             $DB->users->{$this->ID} = array($property => $value);
             break;
         case 'userinfo':
             if (!is_array($value)) {
                 return false;
             }
             foreach ($value as $prop => $val) {
                 $DB->userinfo->update(array('val' => $val), array('prop' => $prop, 'id' => $this->ID), true);
             }
             $this->_userinfo = array_merge($this->_userinfo, $value);
             break;
         default:
             parent::__set($property, $value);
     }
 }