예제 #1
0
 private static function _hasSiteRight($userId, $right)
 {
     $userModel = new UserModel($userId);
     return SiteRoles::hasRight($userModel->siteRole, $right) || SystemRoles::hasRight($userModel->role, $right);
 }
예제 #2
0
 /**
  * Returns true if the current user has $right to $website.
  * @param int $right
  * @param Website $website
  * @return bool
  */
 public function hasRight($right, $website)
 {
     $result = SiteRoles::hasRight($this->siteRole, $right) || SystemRoles::hasRight($this->role, $right);
     return $result;
 }
예제 #3
0
 /**
  *
  * @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();
 }