From 6f335e8a2d82a512e4be16edfe54aa9a2b2bb3eb Mon Sep 17 00:00:00 2001 From: Fabian Schmid Date: Fri, 26 Feb 2016 15:14:08 +0100 Subject: [PATCH] fixed bug in user-assignement --- classes/class.usrtoHelper.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/classes/class.usrtoHelper.php b/classes/class.usrtoHelper.php index 1dfc0b6..bb8871d 100644 --- a/classes/class.usrtoHelper.php +++ b/classes/class.usrtoHelper.php @@ -75,8 +75,7 @@ public function setTemporaryUsrId($temporary_usr_id) { /** * @return bool */ - public function isTakenOver() - { + public function isTakenOver() { return (isset($_SESSION[self::USR_ID_BACKUP])); } @@ -86,7 +85,7 @@ public function isTakenOver() */ public function takeOver($usr_id) { global $ilUser, $ilLog; - $this->checkAccess(); + $this->checkAccess($ilUser->getId()); $this->setTemporaryUsrId($usr_id); $this->setOriginalUsrId($ilUser->getId()); $pl = ilUserTakeOverPlugin::getInstance(); @@ -119,14 +118,18 @@ public function switchBack() { } - protected function checkAccess() { + /** + * @param $usr_id + * @return bool + */ + protected function checkAccess($usr_id) { global $rbacreview; $pl = ilUserTakeOverPlugin::getInstance(); - if (!in_array(2, $rbacreview->assignedGlobalRoles($this->getOriginalUsrId()))) { + if (!isset($usr_id) || !in_array(2, $rbacreview->assignedGlobalRoles($usr_id))) { ilUtil::sendFailure($pl->txt('no_permission'), true); ilUtil::redirect('login.php'); return false; } } -} +} \ No newline at end of file