diff --git a/classes/class.ilUserTakeOverUIHookGUI.php b/classes/class.ilUserTakeOverUIHookGUI.php index a0b38a3..717bd17 100644 --- a/classes/class.ilUserTakeOverUIHookGUI.php +++ b/classes/class.ilUserTakeOverUIHookGUI.php @@ -61,9 +61,9 @@ public function getHTML($a_comp, $a_part, $a_par = array()) { */ if ($a_comp == 'Services/MainMenu') { - if ($_SESSION['usrtoOriginalAccountId']) { + if ($_SESSION[usrtoHelper::USR_ID_BACKUP]) { $ilToolbar = new ilToolbarGUI(); - if (! self::isLoaded('user_take_back')) { + if (!self::isLoaded('user_take_back')) { if ($ilToolbar instanceof ilToolbarGUI) { $ilUserTakeOverPlugin = ilUserTakeOverPlugin::getInstance(); $link = 'goto.php?target=usr_takeback'; @@ -77,13 +77,12 @@ public function getHTML($a_comp, $a_part, $a_par = array()) { } } - if (! self::isLoaded('user_take_over')) { + if (!self::isLoaded('user_take_over')) { if ($_GET['cmdClass'] == 'ilobjusergui' AND ($_GET['cmd'] == 'view' OR $_GET['cmd'] == 'edit')) { global $rbacreview, $ilUser; // Only Administrators - if (! in_array(2, $rbacreview->assignedGlobalRoles($ilUser->getId()))) { + if (!in_array(2, $rbacreview->assignedGlobalRoles($ilUser->getId()))) { self::setLoaded('user_take_over'); - return false; } @@ -102,12 +101,10 @@ public function getHTML($a_comp, $a_part, $a_par = array()) { public function gotoHook() { if (preg_match("/usr_takeover_(.*)/uim", $_GET['target'], $matches)) { - usrtoHelper::getInstance()->takeOver($matches[1]); + usrtoHelper::getInstance()->takeOver((int)$matches[1]); } if (preg_match("/usr_takeback/uim", $_GET['target'], $matches)) { usrtoHelper::getInstance()->switchBack(); } } -} - -?> \ No newline at end of file +} \ No newline at end of file diff --git a/classes/class.usrtoHelper.php b/classes/class.usrtoHelper.php index 6d735fc..1dfc0b6 100644 --- a/classes/class.usrtoHelper.php +++ b/classes/class.usrtoHelper.php @@ -22,7 +22,7 @@ class usrtoHelper { * @return usrtoHelper */ public static function getInstance() { - if (! isset(self::$instance)) { + if (!isset(self::$instance)) { self::$instance = new self(); } @@ -72,14 +72,23 @@ public function setTemporaryUsrId($temporary_usr_id) { } + /** + * @return bool + */ + public function isTakenOver() + { + return (isset($_SESSION[self::USR_ID_BACKUP])); + } + + /** * @param $usr_id */ public function takeOver($usr_id) { + global $ilUser, $ilLog; $this->checkAccess(); $this->setTemporaryUsrId($usr_id); - - global $ilUser, $ilLog; + $this->setOriginalUsrId($ilUser->getId()); $pl = ilUserTakeOverPlugin::getInstance(); $_SESSION[self::USR_ID_GLOBAL] = $this->getTemporaryUsrId(); $_SESSION[self::USR_ID_BACKUP] = $this->getOriginalUsrId(); @@ -113,7 +122,7 @@ public function switchBack() { protected function checkAccess() { global $rbacreview; $pl = ilUserTakeOverPlugin::getInstance(); - if (! in_array(2, $rbacreview->assignedGlobalRoles($this->getOriginalUsrId()))) { + if (!in_array(2, $rbacreview->assignedGlobalRoles($this->getOriginalUsrId()))) { ilUtil::sendFailure($pl->txt('no_permission'), true); ilUtil::redirect('login.php'); @@ -121,5 +130,3 @@ protected function checkAccess() { } } } - -?> diff --git a/doc/Documentation.docx b/doc/Documentation.docx index 9fcfb00..66a8b62 100644 Binary files a/doc/Documentation.docx and b/doc/Documentation.docx differ diff --git a/doc/Documentation.pdf b/doc/Documentation.pdf index d43cc3b..70a87c3 100644 Binary files a/doc/Documentation.pdf and b/doc/Documentation.pdf differ diff --git a/plugin.php b/plugin.php index 0f7762f..e3a4c8f 100755 --- a/plugin.php +++ b/plugin.php @@ -1,8 +1,7 @@ +$responsible_mail = 'info@studer-raimann.ch'; \ No newline at end of file