Skip to content

Commit

Permalink
Update plugin for ILIAS 5.1 including docs; https://jira.studer-raima…
Browse files Browse the repository at this point in the history
…nn.ch/browse/PLUSERTAKEOVER-1

Fix bug that the plugin was switching back to the root user instead of the user taking over the view; https://jira.studer-raimann.ch/browse/PLUSERTAKEOVER-2
  • Loading branch information
wanze committed Aug 17, 2015
1 parent 9518af1 commit ccb4ad2
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
15 changes: 6 additions & 9 deletions classes/class.ilUserTakeOverUIHookGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
}

Expand All @@ -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();
}
}
}

?>
}
19 changes: 13 additions & 6 deletions classes/class.usrtoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class usrtoHelper {
* @return usrtoHelper
*/
public static function getInstance() {
if (! isset(self::$instance)) {
if (!isset(self::$instance)) {
self::$instance = new self();
}

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -113,13 +122,11 @@ 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');

return false;
}
}
}

?>
Binary file modified doc/Documentation.docx
Binary file not shown.
Binary file modified doc/Documentation.pdf
Binary file not shown.
7 changes: 3 additions & 4 deletions plugin.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php
$id = 'usrto';
$version = '1.1.2';
$version = '1.1.3';
$ilias_min_version = '4.3.0';
$ilias_max_version = '5.0.999';
$ilias_max_version = '5.1.999';
$responsible = 'Martin Studer, Fabian Schmid';
$responsible_mail = '[email protected]';
?>
$responsible_mail = '[email protected]';

0 comments on commit ccb4ad2

Please sign in to comment.