/**
  *
  * @param Website $website
  * @return array:
  */
 public function getRightsArray($website)
 {
     $siteRightsArray = SiteRoles::getRightsArray($this->siteRole, $website);
     $systemRightsArray = SystemRoles::getRightsArray($this->role);
     $mergeArray = array_merge($siteRightsArray, $systemRightsArray);
     return array_values(array_unique($mergeArray));
 }
 public function testHasRight_SfchecksProject_Ok()
 {
     // User Roles
     $result = SfchecksRoles::hasRight(ProjectRoles::CONTRIBUTOR, Domain::ANSWERS + Operation::CREATE);
     $this->assertTrue($result);
     $result = SfchecksRoles::hasRight(ProjectRoles::CONTRIBUTOR, Domain::USERS + Operation::CREATE);
     $this->assertFalse($result);
     // Project Admin Roles
     $result = SfchecksRoles::hasRight(ProjectRoles::MANAGER, Domain::QUESTIONS + Operation::CREATE);
     $this->assertTrue($result);
     $result = SfchecksRoles::hasRight(ProjectRoles::MANAGER, Domain::PROJECTS + Operation::CREATE);
     $this->assertFalse($result);
     // System Admin Roles
     $result = SystemRoles::hasRight(SystemRoles::SYSTEM_ADMIN, Domain::USERS + Operation::CREATE);
     $this->assertTrue($result);
 }
 /**
  *
  * @param int $right
  * @return bool
  */
 public function userHasSystemRight($right)
 {
     $userModel = new UserModel($this->_userId);
     return SystemRoles::hasRight($userModel->role, $right);
 }
 protected function populateHeaderMenuViewdata()
 {
     $this->data['isAdmin'] = false;
     // setup specific variables for header
     $this->data['isLoggedIn'] = $this->_isLoggedIn;
     $this->data['showHelpButton'] = $this->_showHelp;
     $featuredProjectList = new FeaturedProjectListModel();
     $featuredProjectList->read();
     $this->data['featuredProjects'] = $featuredProjectList->entries;
     if ($this->_isLoggedIn) {
         if ($this->_user->role) {
             $this->data['isAdmin'] = SystemRoles::hasRight($this->_user->role, Domain::USERS + Operation::CREATE);
         }
         $this->data['userName'] = $this->_user->username;
         $this->data['smallAvatarUrl'] = '/Site/views/shared/image/avatar/' . $this->_user->avatar_ref;
         $projects = $this->_user->listProjects($this->website->domain);
         $this->data['projects_count'] = $projects->count;
         $this->data['projects'] = $projects->entries;
     }
 }
 /**
  *
  * @param string $userId
  * @param string $newPassword
  * @param string $currentUserId
  * @throws \Exception
  */
 public static function changePassword($userId, $newPassword, $currentUserId)
 {
     if ($userId != $currentUserId) {
         $currentUserModel = new UserModel($currentUserId);
         if (!SiteRoles::hasRight($currentUserModel->siteRole, Domain::USERS + Operation::EDIT) && !SystemRoles::hasRight($currentUserModel->role, Domain::USERS + Operation::EDIT)) {
             throw new UserUnauthorizedException();
         }
     }
     $user = new PasswordModel($userId);
     $user->changePassword($newPassword);
     $user->write();
 }