Example #1
0
 public function changeProfile($data)
 {
     $user = Login::getCurrentUser();
     if ($user['id'] != $this->id) {
         throw new Exception\UnauthorizedException('ERR_USER_NO_ALLOW_TO_ACCESS_OTHER_USER');
     }
     $profileData = empty($data['profile']) ? array() : $data['profile'];
     $profile = new Profile();
     $profile->assign($profileData);
     $this->profile = $profile;
     $this->assign($data);
     if (!$this->save()) {
         throw new Exception\RuntimeException('Create user failed');
     }
     return $this;
 }
Example #2
0
 public function updateUser($data)
 {
     $profileData = empty($data['profile']) ? array() : $data['profile'];
     $profile = new Profile();
     $profile->assign($profileData);
     $this->profile = $profile;
     $this->assign($data);
     if (!$this->save()) {
         throw new Exception\RuntimeException('Create user failed');
     }
     return $this;
 }