- allow managers of a group to manage their group

This commit is contained in:
steinm 2011-10-07 16:18:23 +00:00
parent de84b295a5
commit a590083015
2 changed files with 110 additions and 7 deletions

71
op/op.GroupView.php Normal file
View File

@ -0,0 +1,71 @@
<?php
// MyDMS. Document Management System
// Copyright (C) 2002-2005 Markus Westphal
// Copyright (C) 2006-2008 Malcolm Cowe
// Copyright (C) 2010 Matteo Lucarelli
//
// 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.ClassEmail.php");
include("../inc/inc.Authentication.php");
/* Get the group and check if the currently logged in user is a manager */
$ismanager = false;
if($_REQUEST['groupid']) {
$group = $dms->getGroup($_REQUEST['groupid']);
$managers = $group->getManagers();
foreach($managers as $manager) {
if($manager->getId() == $user->getId()) {
$ismanager = true;
break;
}
}
}
if($ismanager) {
$curuser = $dms->getUser($_REQUEST['userid']);
$members = $group->getUsers();
// Check if user is alread in group
$ismember = false;
foreach($members as $member) {
if($member->getId() == $curuser->getId())
$ismember = true;
}
// Add user to group
if ($_REQUEST['action'] == "add") {
if(!$ismember) {
$group->addUser($curuser);
}
}
// Delete user from group
elseif($_REQUEST['action'] == 'del') {
if($ismember) {
$group->removeUser($curuser);
}
}
} else {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
}
header("Location:../out/out.GroupView.php");
?>

View File

@ -50,21 +50,53 @@ UI::contentHeading(getMLText("groups"));
UI::contentContainerStart();
echo "<ul class=\"groupView\">\n";
$users = $dms->getAllUsers();
foreach ($groups as $group){
echo "<li>".$group->getName()." : ".$group->getComment()."</li>";
$members = $group->getUsers();
$managers = $group->getManagers();
$ismanager = false; /* set to true if current user is manager */
echo "<li>".$group->getName();
if($group->getComment())
echo " : ".$group->getComment();
foreach($managers as $manager)
if($manager->getId() == $user->getId()) {
echo " : you are the manager of this group";
$ismanager = true;
}
echo "</li>";
echo "<ul>\n";
$memberids = array();
foreach ($members as $member) {
$memberids[] = $member->getId();
echo "<li>".$member->getFullName();
if ($member->getEmail()!="")
echo " (<a href=\"mailto:".$member->getEmail()."\">".$member->getEmail()."</a>)</li>";
else echo "</li>";
echo " (<a href=\"mailto:".$member->getEmail()."\">".$member->getEmail()."</a>)";
foreach($managers as $manager)
if($manager->getId() == $member->getId())
echo ", Manager";
if($ismanager) {
echo ' <a href="../op/op.GroupView.php?action=del&groupid='.$group->getId().'&userid='.$member->getId().'"><img src="images/del.gif" width="15" height="15" border="0" align="absmiddle" alt=""> Remove this user</a>';
}
echo "</li>";
}
if($ismanager) {
echo "<li>Add user to this group:";
echo "<form action=\"../op/op.GroupView.php\">";
echo "<input type=\"hidden\" name=\"action\" value=\"add\" /><input type=\"hidden\" name=\"groupid\" value=\"".$group->getId()."\" />";
echo "<select name=\"userid\" onChange=\"javascript: submit();\">";
echo "<option value=\"\"></option>";
foreach($users as $u) {
if(!$u->isAdmin() && !$u->isGuest() && !in_array($u->getId(), $memberids))
echo "<option value=\"".$u->getId()."\">".$u->getFullName()."</option>";
}
echo "</select>";
echo "</form>";
echo "</li>";
}
echo "</ul>\n";
}