예제 #1
0
 private function setup_object($user, $newuser = false)
 {
     if (!$user || !is_object($user)) {
         return null;
     }
     if ($this->group_id && MValidate::id($this->group_id)) {
         $user->group_id = $this->group_id;
     } else {
         return mapi_report_message('Not a valid group.');
     }
     if ($this->username && MValidate::username($this->username)) {
         $user->username = $this->username;
     } else {
         return mapi_report_message('Not a valid username.');
     }
     if (!$newuser) {
         if (!mapi_check_double('users', 'username', $this->username)) {
             return mapi_report_message('Username not available.');
         }
     }
     if ($this->email && MValidate::email($this->email)) {
         $user->email = $this->email;
     } else {
         return mapi_report_message('Not a valid email address.');
     }
     if ($this->name && MValidate::title($this->name)) {
         $user->name = $this->name;
     } else {
         return mapi_report_message('Not a valid name.');
     }
     if ($this->enabled && 1 == $this->enabled) {
         $user->enabled = 1;
     } else {
         $user->enabled = 0;
     }
     return true;
 }