- do not list groups/users for which an entry in the acl already exists

This commit is contained in:
steinm 2012-05-08 08:10:08 +00:00
parent ef0200acdc
commit 020165de17

View File

@ -1,234 +1,242 @@
<?php <?php
// MyDMS. Document Management System // MyDMS. Document Management System
// Copyright (C) 2002-2005 Markus Westphal // Copyright (C) 2002-2005 Markus Westphal
// Copyright (C) 2006-2008 Malcolm Cowe // Copyright (C) 2006-2008 Malcolm Cowe
// Copyright (C) 2006-2008 Malcolm Cowe // Copyright (C) 2006-2008 Malcolm Cowe
// //
// This program is free software; you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or // the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
include("../inc/inc.Settings.php"); include("../inc/inc.Settings.php");
include("../inc/inc.Utils.php"); include("../inc/inc.Utils.php");
include("../inc/inc.DBInit.php"); include("../inc/inc.DBInit.php");
include("../inc/inc.Language.php"); include("../inc/inc.Language.php");
include("../inc/inc.ClassUI.php"); include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php"); include("../inc/inc.Authentication.php");
function printAccessModeSelection($defMode) { function printAccessModeSelection($defMode) {
print "<select name=\"mode\">\n"; print "<select name=\"mode\">\n";
print "\t<option value=\"".M_NONE."\"" . (($defMode == M_NONE) ? " selected" : "") . ">" . getMLText("access_mode_none") . "</option>\n"; print "\t<option value=\"".M_NONE."\"" . (($defMode == M_NONE) ? " selected" : "") . ">" . getMLText("access_mode_none") . "</option>\n";
print "\t<option value=\"".M_READ."\"" . (($defMode == M_READ) ? " selected" : "") . ">" . getMLText("access_mode_read") . "</option>\n"; print "\t<option value=\"".M_READ."\"" . (($defMode == M_READ) ? " selected" : "") . ">" . getMLText("access_mode_read") . "</option>\n";
print "\t<option value=\"".M_READWRITE."\"" . (($defMode == M_READWRITE) ? " selected" : "") . ">" . getMLText("access_mode_readwrite") . "</option>\n"; print "\t<option value=\"".M_READWRITE."\"" . (($defMode == M_READWRITE) ? " selected" : "") . ">" . getMLText("access_mode_readwrite") . "</option>\n";
print "\t<option value=\"".M_ALL."\"" . (($defMode == M_ALL) ? " selected" : "") . ">" . getMLText("access_mode_all") . "</option>\n"; print "\t<option value=\"".M_ALL."\"" . (($defMode == M_ALL) ? " selected" : "") . ">" . getMLText("access_mode_all") . "</option>\n";
print "</select>\n"; print "</select>\n";
}
if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
}
$documentid = $_GET["documentid"];
$document = $dms->getDocument($documentid);
if (!is_object($document)) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
}
$folder = $document->getFolder();
$docPathHTML = getFolderPathHTML($folder, true). " / <a href=\"../out/out.ViewDocument.php?documentid=".$documentid."\">".htmlspecialchars($document->getName())."</a>";
if ($document->getAccessMode($user) < M_ALL) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
} }
UI::htmlStartPage(getMLText("document_title", array("documentname" => $document->getName()))); if (!isset($_GET["documentid"]) || !is_numeric($_GET["documentid"]) || intval($_GET["documentid"])<1) {
UI::globalNavigation($folder); UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
}
$documentid = $_GET["documentid"];
$document = $dms->getDocument($documentid);
if (!is_object($document)) {
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
}
$folder = $document->getFolder();
$docPathHTML = getFolderPathHTML($folder, true). " / <a href=\"../out/out.ViewDocument.php?documentid=".$documentid."\">".htmlspecialchars($document->getName())."</a>";
if ($document->getAccessMode($user) < M_ALL) {
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
}
UI::htmlStartPage(getMLText("document_title", array("documentname" => $document->getName())));
UI::globalNavigation($folder);
UI::pageNavigation($docPathHTML, "view_document"); UI::pageNavigation($docPathHTML, "view_document");
?> ?>
<script language="JavaScript"> <script language="JavaScript">
function checkForm() function checkForm()
{ {
msg = ""; msg = "";
if ((document.form1.userid.options[document.form1.userid.selectedIndex].value == -1) && if ((document.form1.userid.options[document.form1.userid.selectedIndex].value == -1) &&
(document.form1.groupid.options[document.form1.groupid.selectedIndex].value == -1)) (document.form1.groupid.options[document.form1.groupid.selectedIndex].value == -1))
msg += "<?php printMLText("js_select_user_or_group");?>\n"; msg += "<?php printMLText("js_select_user_or_group");?>\n";
if (msg != "") if (msg != "")
{ {
alert(msg); alert(msg);
return false; return false;
} }
else else
return true; return true;
} }
</script> </script>
<?php <?php
$allUsers = $dms->getAllUsers(); $allUsers = $dms->getAllUsers();
UI::contentHeading(getMLText("edit_document_access")); UI::contentHeading(getMLText("edit_document_access"));
UI::contentContainerStart(); UI::contentContainerStart();
if ($user->isAdmin()) { if ($user->isAdmin()) {
UI::contentSubHeading(getMLText("set_owner")); UI::contentSubHeading(getMLText("set_owner"));
?> ?>
<form action="../op/op.DocumentAccess.php"> <form action="../op/op.DocumentAccess.php">
<input type="Hidden" name="action" value="setowner"> <input type="Hidden" name="action" value="setowner">
<input type="Hidden" name="documentid" value="<?php print $documentid;?>"> <input type="Hidden" name="documentid" value="<?php print $documentid;?>">
<?php printMLText("owner");?> : <select name="ownerid"> <?php printMLText("owner");?> : <select name="ownerid">
<?php <?php
$owner = $document->getOwner(); $owner = $document->getOwner();
foreach ($allUsers as $currUser) { foreach ($allUsers as $currUser) {
if ($currUser->isGuest()) if ($currUser->isGuest())
continue; continue;
print "<option value=\"".$currUser->getID()."\""; print "<option value=\"".$currUser->getID()."\"";
if ($currUser->getID() == $owner->getID()) if ($currUser->getID() == $owner->getID())
print " selected"; print " selected";
print ">" . htmlspecialchars($currUser->getFullname()) . "</option>\n"; print ">" . htmlspecialchars($currUser->getFullname()) . "</option>\n";
} }
?> ?>
</select> </select>
<input type="Submit" value="<?php printMLText("save")?>"> <input type="Submit" value="<?php printMLText("save")?>">
</form> </form>
<?php <?php
} }
UI::contentSubHeading(getMLText("access_inheritance")); UI::contentSubHeading(getMLText("access_inheritance"));
if ($document->inheritsAccess()) { if ($document->inheritsAccess()) {
printMLText("inherits_access_msg", array( printMLText("inherits_access_msg", array(
"copyurl" => "../op/op.DocumentAccess.php?documentid=".$documentid."&action=notinherit&mode=copy", "copyurl" => "../op/op.DocumentAccess.php?documentid=".$documentid."&action=notinherit&mode=copy",
"emptyurl" => "../op/op.DocumentAccess.php?documentid=".$documentid."&action=notinherit&mode=empty")); "emptyurl" => "../op/op.DocumentAccess.php?documentid=".$documentid."&action=notinherit&mode=empty"));
UI::contentContainerEnd(); UI::contentContainerEnd();
UI::htmlEndPage(); UI::htmlEndPage();
exit(); exit();
} }
printMLText("does_not_inherit_access_msg", array("inheriturl" => "../op/op.DocumentAccess.php?documentid=".$documentid."&action=inherit")); printMLText("does_not_inherit_access_msg", array("inheriturl" => "../op/op.DocumentAccess.php?documentid=".$documentid."&action=inherit"));
$accessList = $document->getAccessList(); $accessList = $document->getAccessList();
UI::contentSubHeading(getMLText("default_access")); UI::contentSubHeading(getMLText("default_access"));
?> ?>
<form action="../op/op.DocumentAccess.php"> <form action="../op/op.DocumentAccess.php">
<input type="Hidden" name="documentid" value="<?php print $documentid;?>"> <input type="Hidden" name="documentid" value="<?php print $documentid;?>">
<input type="Hidden" name="action" value="setdefault"> <input type="Hidden" name="action" value="setdefault">
<?php printAccessModeSelection($document->getDefaultAccess()); ?> <?php printAccessModeSelection($document->getDefaultAccess()); ?>
<input type="Submit" value="<?php printMLText("save");?>"> <input type="Submit" value="<?php printMLText("save");?>">
</form> </form>
<?php <?php
UI::contentSubHeading(getMLText("edit_existing_access")); UI::contentSubHeading(getMLText("edit_existing_access"));
if (count($accessList["users"]) != 0 || count($accessList["groups"]) != 0) { if (count($accessList["users"]) != 0 || count($accessList["groups"]) != 0) {
print "<table class=\"defaultView\">"; print "<table class=\"defaultView\">";
foreach ($accessList["users"] as $userAccess) { /* memorїze users with access rights */
$userObj = $userAccess->getUser(); $memusers = array();
print "<form action=\"../op/op.DocumentAccess.php\">\n"; foreach ($accessList["users"] as $userAccess) {
print "<input type=\"Hidden\" name=\"documentid\" value=\"".$documentid."\">\n"; $userObj = $userAccess->getUser();
print "<input type=\"Hidden\" name=\"action\" value=\"editaccess\">\n"; $memusers[] = $userObj->getID();
print "<input type=\"Hidden\" name=\"userid\" value=\"".$userObj->getID()."\">\n"; print "<form action=\"../op/op.DocumentAccess.php\">\n";
print "<tr>\n"; print "<input type=\"Hidden\" name=\"documentid\" value=\"".$documentid."\">\n";
print "<td><img src=\"images/usericon.gif\" class=\"mimeicon\"></td>\n"; print "<input type=\"Hidden\" name=\"action\" value=\"editaccess\">\n";
print "<td>". htmlspecialchars($userObj->getFullName()) . "</td>\n"; print "<input type=\"Hidden\" name=\"userid\" value=\"".$userObj->getID()."\">\n";
print "<td>\n"; print "<tr>\n";
printAccessModeSelection($userAccess->getMode()); print "<td><img src=\"images/usericon.gif\" class=\"mimeicon\"></td>\n";
print "</td>\n"; print "<td>". htmlspecialchars($userObj->getFullName()) . "</td>\n";
print "<td><span class=\"actions\">\n"; print "<td>\n";
print "<input type=\"Image\" class=\"mimeicon\" src=\"images/save.gif\">".getMLText("save")." "; printAccessModeSelection($userAccess->getMode());
print "<a href=\"../op/op.DocumentAccess.php?documentid=".$documentid."&action=delaccess&userid=".$userObj->getID()."\"><img src=\"images/del.gif\" class=\"mimeicon\"></a>".getMLText("delete"); print "</td>\n";
print "</span></td></tr>\n"; print "<td><span class=\"actions\">\n";
print "</form>\n"; print "<input type=\"Image\" class=\"mimeicon\" src=\"images/save.gif\">".getMLText("save")." ";
} print "<a href=\"../op/op.DocumentAccess.php?documentid=".$documentid."&action=delaccess&userid=".$userObj->getID()."\"><img src=\"images/del.gif\" class=\"mimeicon\"></a>".getMLText("delete");
print "</span></td></tr>\n";
foreach ($accessList["groups"] as $groupAccess) { print "</form>\n";
$groupObj = $groupAccess->getGroup(); }
$mode = $groupAccess->getMode();
print "<form action=\"../op/op.DocumentAccess.php\">"; /* memorїze groups with access rights */
print "<input type=\"Hidden\" name=\"documentid\" value=\"".$documentid."\">"; $memgroups = array();
print "<input type=\"Hidden\" name=\"action\" value=\"editaccess\">"; foreach ($accessList["groups"] as $groupAccess) {
print "<input type=\"Hidden\" name=\"groupid\" value=\"".$groupObj->getID()."\">"; $groupObj = $groupAccess->getGroup();
print "<tr>"; $memgroups[] = $groupObj->getID();
print "<td><img src=\"images/groupicon.gif\" class=\"mimeicon\"></td>"; $mode = $groupAccess->getMode();
print "<td>". htmlspecialchars($groupObj->getName()) . "</td>"; print "<form action=\"../op/op.DocumentAccess.php\">";
print "<td>"; print "<input type=\"Hidden\" name=\"documentid\" value=\"".$documentid."\">";
printAccessModeSelection($groupAccess->getMode()); print "<input type=\"Hidden\" name=\"action\" value=\"editaccess\">";
print "</td>\n"; print "<input type=\"Hidden\" name=\"groupid\" value=\"".$groupObj->getID()."\">";
print "<td><span class=\"actions\">\n"; print "<tr>";
print "<input type=\"Image\" class=\"mimeicon\" src=\"images/save.gif\">".getMLText("save")." "; print "<td><img src=\"images/groupicon.gif\" class=\"mimeicon\"></td>";
print "<a href=\"../op/op.DocumentAccess.php?documentid=".$documentid."&action=delaccess&groupid=".$groupObj->getID()."\"><img src=\"images/del.gif\" class=\"mimeicon\"></a>".getMLText("delete"); print "<td>". htmlspecialchars($groupObj->getName()) . "</td>";
print "</span></td></tr>"; print "<td>";
print "</form>"; printAccessModeSelection($groupAccess->getMode());
print "</td>\n";
print "<td><span class=\"actions\">\n";
print "<input type=\"Image\" class=\"mimeicon\" src=\"images/save.gif\">".getMLText("save")." ";
print "<a href=\"../op/op.DocumentAccess.php?documentid=".$documentid."&action=delaccess&groupid=".$groupObj->getID()."\"><img src=\"images/del.gif\" class=\"mimeicon\"></a>".getMLText("delete");
print "</span></td></tr>";
print "</form>";
} }
print "</table><br>"; print "</table><br>";
} }
?> ?>
<form action="../op/op.DocumentAccess.php" name="form1" onsubmit="return checkForm();"> <form action="../op/op.DocumentAccess.php" name="form1" onsubmit="return checkForm();">
<input type="Hidden" name="documentid" value="<?php print $documentid?>"> <input type="Hidden" name="documentid" value="<?php print $documentid?>">
<input type="Hidden" name="action" value="addaccess"> <input type="Hidden" name="action" value="addaccess">
<table> <table>
<tr> <tr>
<td><?php printMLText("user");?>:</td> <td><?php printMLText("user");?>:</td>
<td> <td>
<select name="userid"> <select name="userid">
<option value="-1"><?php printMLText("select_one");?></option> <option value="-1"><?php printMLText("select_one");?></option>
<?php <?php
foreach ($allUsers as $userObj) { foreach ($allUsers as $userObj) {
if ($userObj->isGuest()) { if ($userObj->isGuest() || in_array($userObj->getID(), $memusers)) {
continue; continue;
} }
print "<option value=\"".$userObj->getID()."\">" . htmlspecialchars($userObj->getFullName()) . "</option>\n"; print "<option value=\"".$userObj->getID()."\">" . htmlspecialchars($userObj->getFullName()) . "</option>\n";
} }
?> ?>
</select> </select>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><?php printMLText("group");?>:</td> <td><?php printMLText("group");?>:</td>
<td> <td>
<select name="groupid"> <select name="groupid">
<option value="-1"><?php printMLText("select_one");?></option> <option value="-1"><?php printMLText("select_one");?></option>
<?php <?php
$allGroups = $dms->getAllGroups(); $allGroups = $dms->getAllGroups();
foreach ($allGroups as $groupObj) { foreach ($allGroups as $groupObj) {
print "<option value=\"".$groupObj->getID()."\">" . htmlspecialchars($groupObj->getName()) . "</option>\n"; if(in_array($groupObj->getID(), $memgroups))
} continue;
?> print "<option value=\"".$groupObj->getID()."\">" . htmlspecialchars($groupObj->getName()) . "</option>\n";
</select> }
</td> ?>
</tr> </select>
<tr> </td>
<td><?php printMLText("access_mode");?>:</td> </tr>
<td> <tr>
<?php <td><?php printMLText("access_mode");?>:</td>
printAccessModeSelection(M_READ); <td>
?> <?php
</td> printAccessModeSelection(M_READ);
</tr> ?>
<tr> </td>
<td colspan="2"><input type="Submit" value="<?php printMLText("add");?>"></td> </tr>
</tr> <tr>
</table> <td colspan="2"><input type="Submit" value="<?php printMLText("add");?>"></td>
</form> </tr>
</table>
<?php </form>
UI::contentContainerEnd();
UI::htmlEndPage(); <?php
?> UI::contentContainerEnd();
UI::htmlEndPage();
?>