private static function _hasSiteRight($userId, $right) { $userModel = new UserModel($userId); return SiteRoles::hasRight($userModel->siteRole, $right) || SystemRoles::hasRight($userModel->role, $right); }
/** * 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; }
/** * * @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(); }