/**
  *
  * @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));
 }
Example #2
0
    /**
     *
     * @param MapOf $roleMap
     * @param Website $website
     * @return array
     */
    public static function getRightsArray($roleMap, $website)
    {
        if ($roleMap->offsetExists($website->domain)) {
            return self::_getRightsArray(self::$_rights, $roleMap[$website->domain]);
        }
        return array();
    }
    /**
     *
     * @param  MapOf      $roleMap
     * @param  int        $right
     * @throws \Exception
     * @return bool
     */
    public static function hasRight($roleMap, $right)
    {
        global $WEBSITE;
        if ($roleMap->offsetExists($WEBSITE->domain)) {
            return self::_hasRight(self::$_rights, $roleMap[$WEBSITE->domain], $right);
        }
        return false;
    }
}
SiteRoles::init();
 private static function _hasSiteRight($userId, $right)
 {
     $userModel = new UserModel($userId);
     return SiteRoles::hasRight($userModel->siteRole, $right) || SystemRoles::hasRight($userModel->role, $right);
 }
 /**
  *
  * @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();
 }