Пример #1
0
 /**
  * Checks to make sure all the required fields are valid.
  *
  * Checks to make sure the username is unique in the system and that the password matches the confirmed password.
  * @global array
  */
 public function validate()
 {
     parent::validate();
     if ($this->id == '0') {
         if (I2CE_User::userExists($this->username, false)) {
             $this->setInvalidMessage('username', 'unique');
         }
     }
     if (strlen($this->password) > 0 && $this->password != $this->confirm) {
         $this->setInvalidMessage('password', 'mismatch');
     }
     if ($this->id == '0' && $this->password == "" && !$this->generate_password) {
         $this->setInvalidMessage('password', 'required');
     }
     $saving_user = new I2CE_User('0', true, true, false);
     if ($saving_user->role != 'admin') {
         // Allow anyone to set the self service role
         $role_field = $this->getField('role');
         $role_val = $role_field->getDBValue();
         $role_val = str_replace('role|', '', $role_val);
         if ($saving_user->role != $role_val) {
             $default_ss = '';
             I2CE::getConfig()->setIfIsSet($default_ss, "/modules/SelfService/default_user_role");
             if ($role_val != $default_ss) {
                 $where = array('operator' => 'AND', 'operand' => array(array('operator' => 'FIELD_LIMIT', 'field' => 'assignable', 'style' => 'yes'), array('operator' => 'FIELD_LIMIT', 'field' => 'trickle_up', 'style' => 'equals', 'data' => array('value' => $saving_user->role)), array('operator' => 'FIELD_LIMIT', 'field' => 'id', 'style' => 'equals', 'data' => array('value' => $role_val))));
                 $results = I2CE_FormStorage::search('role', false, $where);
                 if (count($results) == 0) {
                     $this->setInvalidMessage('role', 'notallowed');
                 }
             }
         }
     }
 }
Пример #2
0
 /**
  * Checks to make sure all the required fields are valid.
  *
  * Checks to make sure the username is unique in the system and that the password matches the confirmed password.
  * @global array
  */
 public function validate()
 {
     parent::validate();
     if ($this->id == '0') {
         if (I2CE_User::userExists($this->username, false)) {
             $this->setInvalidMessage('username', 'unique');
         }
     }
     if (strlen($this->password) > 0 && $this->password != $this->confirm) {
         $this->setInvalidMessage('password', 'mismatch');
     }
     if ($this->id == '0' && $this->password == "" && !$this->generate_password) {
         $this->setInvalidMessage('password', 'required');
     }
 }