add new feature to substitute user while being admin

This commit is contained in:
Uwe Steinmann 2013-04-19 09:00:34 +02:00
parent cb44d57f2d
commit d63ec26d8e
5 changed files with 251 additions and 49 deletions

31
op/op.ResetSu.php Normal file
View File

@ -0,0 +1,31 @@
<?php
// MyDMS. Document Management System
// Copyright (C) 2013 Uwe Steinmann
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
include("../inc/inc.Settings.php");
include("../inc/inc.LogInit.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
$session->resetSu();
add_log_line("");
header("Location: ../".(isset($settings->_siteDefaultPage) && strlen($settings->_siteDefaultPage)>0 ? $settings->_siteDefaultPage : "out/out.ViewFolder.php?folderid=".$settings->_rootFolderID));
?>

39
op/op.SubstituteUser.php Normal file
View File

@ -0,0 +1,39 @@
<?php
// MyDMS. Document Management System
// Copyright (C) 2013 Uwe Steinmann
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
include("../inc/inc.Settings.php");
include("../inc/inc.LogInit.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
if (!$user->isAdmin()) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
}
if (!isset($_GET["userid"])) {
UI::exitError(getMLText("admin_tools"),getMLText("unknown_id"));
}
$session->setSu($_GET['userid']);
add_log_line("?userid=".$_GET["userid"]);
header("Location: ../".(isset($settings->_siteDefaultPage) && strlen($settings->_siteDefaultPage)>0 ? $settings->_siteDefaultPage : "out/out.ViewFolder.php?folderid=".$settings->_rootFolderID));
?>

View File

@ -0,0 +1,43 @@
<?php
// MyDMS. Document Management System
// Copyright (C) 2013 Uwe Steinmann
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
include("../inc/inc.Settings.php");
include("../inc/inc.Utils.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.ClassAccessOperation.php");
include("../inc/inc.Authentication.php");
if (!$user->isAdmin()) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
}
$allUsers = $dms->getAllUsers($settings->_sortUsersInList);
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1]);
if($view) {
$view->setParam('dms', $dms);
$view->setParam('user', $user);
$view->setParam('allusers', $allUsers);
$view->show();
exit;
}
?>

View File

@ -119,7 +119,7 @@ class SeedDMS_Bootstrap_Style extends SeedDMS_View_Common {
echo " <div class=\"nav-collapse nav-col1\">\n"; echo " <div class=\"nav-collapse nav-col1\">\n";
echo " <ul class=\"nav pull-right\">\n"; echo " <ul class=\"nav pull-right\">\n";
echo " <li class=\"dropdown\">\n"; echo " <li class=\"dropdown\">\n";
echo " <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">".getMLText("signed_in_as")." ".htmlspecialchars($this->params['user']->getFullName())."<b class=\"caret\"></b></a>\n"; echo " <a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">".($this->params['session']->getSu() ? getMLText("switched_to") : getMLText("signed_in_as"))." '".htmlspecialchars($this->params['user']->getFullName())."' <b class=\"caret\"></b></a>\n";
echo " <ul class=\"dropdown-menu\" role=\"menu\">\n"; echo " <ul class=\"dropdown-menu\" role=\"menu\">\n";
if (!$this->params['user']->isGuest()) { if (!$this->params['user']->isGuest()) {
echo " <li><a href=\"../out/out.MyDocuments.php?inProcess=1\">".getMLText("my_documents")."</a></li>\n"; echo " <li><a href=\"../out/out.MyDocuments.php?inProcess=1\">".getMLText("my_documents")."</a></li>\n";
@ -141,9 +141,15 @@ class SeedDMS_Bootstrap_Style extends SeedDMS_View_Common {
} }
echo " </ul>\n"; echo " </ul>\n";
echo " </li>\n"; echo " </li>\n";
if($this->params['user']->isAdmin())
echo " <li><a href=\"../out/out.SubstituteUser.php\">".getMLText("substitute_user")."</a></li>\n";
echo " <li class=\"divider\"></li>\n"; echo " <li class=\"divider\"></li>\n";
} }
if($this->params['session']->getSu()) {
echo " <li><a href=\"../op/op.ResetSu.php\">".getMLText("sign_out_user")."</a></li>\n";
} else {
echo " <li><a href=\"../op/op.Logout.php\">".getMLText("sign_out")."</a></li>\n"; echo " <li><a href=\"../op/op.Logout.php\">".getMLText("sign_out")."</a></li>\n";
}
echo " </ul>\n"; echo " </ul>\n";
echo " </li>\n"; echo " </li>\n";
echo " </ul>\n"; echo " </ul>\n";

View File

@ -0,0 +1,83 @@
<?php
/**
* Implementation of SubstituteUser view
*
* @category DMS
* @package SeedDMS
* @license GPL 2
* @version @version@
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2002-2005 Markus Westphal,
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
* 2010-2012 Uwe Steinmann
* @version Release: @package_version@
*/
/**
* Include parent class
*/
require_once("class.Bootstrap.php");
/**
* Class which outputs the html page for SubstituteUser view
*
* @category DMS
* @package SeedDMS
* @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 2002-2005 Markus Westphal,
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
* 2010-2012 Uwe Steinmann
* @version Release: @package_version@
*/
class SeedDMS_View_SubstituteUser extends SeedDMS_Bootstrap_Style {
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$allUsers = $this->params['allusers'];
$this->htmlStartPage(getMLText("substitute_user"));
$this->globalNavigation();
$this->contentStart();
$this->pageNavigation(getMLText("admin_tools"), "admin_tools");
$this->contentHeading(getMLText("substitute_user"));
$this->contentContainerStart();
?>
<table class="table table-condensed">
<tr><th><?php printMLText('name'); ?></th><th><?php printMLText('email');?></th><th><?php printMLText('groups'); ?></th><th></th></tr>
<?php
foreach ($allUsers as $currUser) {
echo "<tr>";
echo "<td>";
echo $currUser->getFullName()." (".$currUser->getLogin().")<br />";
echo "<small>".$currUser->getComment()."</small>";
echo "</td>";
echo "<td>";
echo "<a href=\"mailto:".$currUser->getEmail()."\">".$currUser->getEmail()."</a><br />";
echo "</td>";
echo "<td>";
$groups = $currUser->getGroups();
if (count($groups) != 0) {
for ($j = 0; $j < count($groups); $j++) {
print $groups[$j]->getName();
if ($j +1 < count($groups))
print ", ";
}
}
echo "</td>";
echo "<td>";
if($currUser->getID() != $user->getID()) {
echo "<a class=\"btn\" href=\"../op/op.SubstituteUser.php?userid=".$currUser->getID()."\"><i class=\"icon-random\"></i> ".getMLText('substitute_user')."</a> ";
}
echo "</td>";
echo "</tr>";
}
echo "</table>";
$this->contentContainerEnd();
$this->htmlEndPage();
} /* }}} */
}
?>