seeddms-code/views/bootstrap/class.FolderAccess.php

313 lines
11 KiB
PHP
Raw Normal View History

2012-12-14 07:53:13 +00:00
<?php
/**
* Implementation of FolderAccess view
*
* @category DMS
* @package SeedDMS
2012-12-14 07:53:13 +00:00
* @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 FolderAccess view
*
* @category DMS
* @package SeedDMS
2012-12-14 07:53:13 +00:00
* @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_FolderAccess extends SeedDMS_Bootstrap_Style {
2012-12-14 07:53:13 +00:00
function printAccessModeSelection($defMode) { /* {{{ */
2018-06-22 08:20:17 +00:00
echo self::getAccessModeSelection($defMode);
} /* }}} */
function getAccessModeSelection($defMode) { /* {{{ */
$content = "<select name=\"mode\">\n";
$content .= "\t<option value=\"".M_NONE."\"" . (($defMode == M_NONE) ? " selected" : "") . ">" . getMLText("access_mode_none") . "\n";
$content .= "\t<option value=\"".M_READ."\"" . (($defMode == M_READ) ? " selected" : "") . ">" . getMLText("access_mode_read") . "\n";
$content .= "\t<option value=\"".M_READWRITE."\"" . (($defMode == M_READWRITE) ? " selected" : "") . ">" . getMLText("access_mode_readwrite") . "\n";
$content .= "\t<option value=\"".M_ALL."\"" . (($defMode == M_ALL) ? " selected" : "") . ">" . getMLText("access_mode_all") . "\n";
$content .= "</select>\n";
return $content;
2012-12-14 07:53:13 +00:00
} /* }}} */
2016-03-16 19:10:59 +00:00
function js() { /* {{{ */
header('Content-Type: application/javascript; charset=UTF-8');
2012-12-14 07:53:13 +00:00
?>
function checkForm()
{
2013-05-23 14:07:00 +00:00
msg = new Array()
2012-12-14 07:53:13 +00:00
if ((document.form1.userid.options[document.form1.userid.selectedIndex].value == -1) &&
(document.form1.groupid.options[document.form1.groupid.selectedIndex].value == -1))
2013-05-23 14:07:00 +00:00
msg.push("<?php printMLText("js_select_user_or_group");?>");
if (msg != "") {
noty({
text: msg.join('<br />'),
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
_timeout: 1500,
});
2012-12-14 07:53:13 +00:00
return false;
}
else
return true;
}
2016-03-16 19:10:59 +00:00
$(document).ready(function() {
$('body').on('submit', '#form1', function(ev){
if(checkForm()) return;
2016-03-22 13:47:13 +00:00
ev.preventDefault();
2016-03-16 19:10:59 +00:00
});
});
2012-12-14 07:53:13 +00:00
<?php
2016-03-16 19:10:59 +00:00
} /* }}} */
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$allUsers = $this->params['allusers'];
$allGroups = $this->params['allgroups'];
$rootfolderid = $this->params['rootfolderid'];
$this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))));
$this->globalNavigation($folder);
$this->contentStart();
$this->pageNavigation($this->getFolderPathHTML($folder, true), "view_folder", $folder);
2012-12-14 07:53:13 +00:00
$this->contentHeading(getMLText("edit_folder_access"));
2018-06-22 11:40:09 +00:00
echo "<div class=\"row-fluid\">\n";
echo "<div class=\"span4\">\n";
2012-12-14 07:53:13 +00:00
$this->contentContainerStart();
if ($user->isAdmin()) {
?>
2018-06-22 14:54:49 +00:00
<form action="../op/op.FolderAccess.php">
2012-12-14 07:53:13 +00:00
<?php echo createHiddenFieldWithKey('folderaccess'); ?>
2018-06-22 11:40:09 +00:00
<input type="hidden" name="action" value="setowner">
<input type="hidden" name="folderid" value="<?php print $folder->getID();?>">
2012-12-14 07:53:13 +00:00
<?php
2018-06-22 11:40:09 +00:00
$owner = $folder->getOwner();
$options = array();
foreach ($allUsers as $currUser) {
if (!$currUser->isGuest())
$options[] = array($currUser->getID(), htmlspecialchars($currUser->getLogin()), ($currUser->getID()==$owner->getID()), array(array('data-subtitle', htmlspecialchars($currUser->getFullName()))));
}
$this->formField(
getMLText("set_owner"),
array(
'element'=>'select',
'name'=>'ownerid',
'class'=>'chzn-select',
'options'=>$options
)
);
$this->formSubmit("<i class=\"icon-save\"></i> ".getMLText('save'));
2012-12-14 07:53:13 +00:00
?>
</form>
2018-06-22 11:40:09 +00:00
<?php
2012-12-14 07:53:13 +00:00
}
if ($folder->getID() != $rootfolderid && $folder->getParent()){
$this->contentSubHeading(getMLText("access_inheritance"));
if ($folder->inheritsAccess()) {
printMLText("inherits_access_msg");
?>
<p>
2018-06-22 14:54:49 +00:00
<form action="../op/op.FolderAccess.php" style="display: inline-block;">
2012-12-14 07:53:13 +00:00
<?php echo createHiddenFieldWithKey('folderaccess'); ?>
<input type="hidden" name="folderid" value="<?php print $folder->getID();?>">
<input type="hidden" name="action" value="notinherit">
<input type="hidden" name="mode" value="copy">
<input type="submit" class="btn" value="<?php printMLText("inherits_access_copy_msg")?>">
</form>
2018-06-22 14:54:49 +00:00
<form action="../op/op.FolderAccess.php" style="display: inline-block;">
2012-12-14 07:53:13 +00:00
<?php echo createHiddenFieldWithKey('folderaccess'); ?>
<input type="hidden" name="folderid" value="<?php print $folder->getID();?>">
<input type="hidden" name="action" value="notinherit">
<input type="hidden" name="mode" value="empty">
<input type="submit" class="btn" value="<?php printMLText("inherits_access_empty_msg")?>">
</form>
</p>
<?php
$this->contentContainerEnd();
2018-06-22 11:40:09 +00:00
echo "</div>";
echo "</div>";
$this->contentEnd();
2012-12-14 07:53:13 +00:00
$this->htmlEndPage();
return;
}
?>
<form action="../op/op.FolderAccess.php">
<?php echo createHiddenFieldWithKey('folderaccess'); ?>
<input type="hidden" name="folderid" value="<?php print $folder->getID();?>">
<input type="hidden" name="action" value="inherit">
<input type="submit" class="btn" value="<?php printMLText("does_not_inherit_access_msg")?>">
</form>
<?php
}
2018-06-22 11:40:09 +00:00
$this->contentContainerEnd();
echo "</div>";
echo "<div class=\"span4\">";
$this->contentContainerStart();
2012-12-14 07:53:13 +00:00
$accessList = $folder->getAccessList();
?>
2018-06-22 11:40:09 +00:00
<form class="form-horizontal" action="../op/op.FolderAccess.php">
2012-12-14 07:53:13 +00:00
<?php echo createHiddenFieldWithKey('folderaccess'); ?>
2017-01-01 18:19:31 +00:00
<input type="hidden" name="folderid" value="<?php print $folder->getID();?>">
<input type="hidden" name="action" value="setdefault">
2018-06-22 11:40:09 +00:00
<?php
$this->formField(
getMLText("default_access"),
$this->getAccessModeSelection($folder->getDefaultAccess())
);
$this->formSubmit("<i class=\"icon-save\"></i> ".getMLText('save'));
?>
2012-12-14 07:53:13 +00:00
</form>
2018-06-22 11:40:09 +00:00
<form class="form-horizontal" action="../op/op.FolderAccess.php" id="form1" name="form1">
<?php echo createHiddenFieldWithKey('folderaccess'); ?>
<input type="hidden" name="folderid" value="<?php print $folder->getID()?>">
<input type="hidden" name="action" value="addaccess">
<?php
$options = array();
$options[] = array(-1, getMLText('select_one'));
foreach ($allUsers as $currUser) {
if (!$currUser->isGuest())
$options[] = array($currUser->getID(), htmlspecialchars($currUser->getLogin()), ($currUser->getID()==$user->getID()), array(array('data-subtitle', htmlspecialchars($currUser->getFullName()))));
}
$this->formField(
getMLText("user"),
array(
'element'=>'select',
'name'=>'userid',
'id'=>'userid',
2018-06-22 11:40:09 +00:00
'class'=>'chzn-select',
'attributes'=>array(array('data-allow-clear', 'true'), array('data-placeholder',getMLText('select_user'))),
2018-06-22 11:40:09 +00:00
'options'=>$options
)
);
$options = array();
$options[] = array(-1, getMLText('select_one'));
foreach ($allGroups as $groupObj) {
$options[] = array($groupObj->getID(), htmlspecialchars($groupObj->getName()));
}
$this->formField(
getMLText("group"),
array(
'element'=>'select',
'name'=>'groupid',
'class'=>'chzn-select',
'attributes'=>array(array('data-allow-clear', 'true'), array('data-placeholder', getMLText('select_group'))),
2018-06-22 11:40:09 +00:00
'options'=>$options
)
);
$this->formField(
getMLText("access_mode"),
$this->getAccessModeSelection(M_READ)
);
$this->formSubmit("<i class=\"icon-plus\"></i> ".getMLText('add'));
?>
</form>
<?php
$this->contentContainerEnd();
?>
</div>
<div class="span4">
2012-12-14 07:53:13 +00:00
<?php
if ((count($accessList["users"]) != 0) || (count($accessList["groups"]) != 0)) {
print "<table class=\"table-condensed\">";
foreach ($accessList["users"] as $userAccess) {
$userObj = $userAccess->getUser();
print "<tr>\n";
2013-05-22 20:47:33 +00:00
print "<td><i class=\"icon-user\"></i></td>\n";
2012-12-14 07:53:13 +00:00
print "<td>". htmlspecialchars($userObj->getFullName()) . "</td>\n";
print "<form action=\"../op/op.FolderAccess.php\">\n";
echo createHiddenFieldWithKey('folderaccess')."\n";
2017-01-01 18:19:31 +00:00
print "<input type=\"hidden\" name=\"folderid\" value=\"".$folder->getID()."\">\n";
print "<input type=\"hidden\" name=\"action\" value=\"editaccess\">\n";
print "<input type=\"hidden\" name=\"userid\" value=\"".$userObj->getID()."\">\n";
2012-12-14 07:53:13 +00:00
print "<td>\n";
$this->printAccessModeSelection($userAccess->getMode());
print "</td>\n";
print "<td>\n";
print "<button type=\"submit\" class=\"btn btn-mini\"><i class=\"icon-save\"></i> ".getMLText("save")."</button>";
2012-12-14 07:53:13 +00:00
print "</td>\n";
print "</form>\n";
print "<form action=\"../op/op.FolderAccess.php\">\n";
echo createHiddenFieldWithKey('folderaccess')."\n";
2017-01-01 18:19:31 +00:00
print "<input type=\"hidden\" name=\"folderid\" value=\"".$folder->getID()."\">\n";
print "<input type=\"hidden\" name=\"action\" value=\"delaccess\">\n";
print "<input type=\"hidden\" name=\"userid\" value=\"".$userObj->getID()."\">\n";
2012-12-14 07:53:13 +00:00
print "<td>\n";
2013-01-24 09:18:17 +00:00
print "<button type=\"submit\" class=\"btn btn-mini\"><i class=\"icon-remove\"></i> ".getMLText("delete")."</button>";
2012-12-14 07:53:13 +00:00
print "</td>\n";
print "</form>\n";
print "</tr>\n";
}
foreach ($accessList["groups"] as $groupAccess) {
$groupObj = $groupAccess->getGroup();
$mode = $groupAccess->getMode();
print "<tr>";
2013-05-22 20:47:33 +00:00
print "<td><i class=\"icon-group\"></i></td>";
2012-12-14 07:53:13 +00:00
print "<td>". htmlspecialchars($groupObj->getName()) . "</td>";
print "<form action=\"../op/op.FolderAccess.php\">";
echo createHiddenFieldWithKey('folderaccess')."\n";
2017-01-01 18:19:31 +00:00
print "<input type=\"hidden\" name=\"folderid\" value=\"".$folder->getID()."\">";
print "<input type=\"hidden\" name=\"action\" value=\"editaccess\">";
print "<input type=\"hidden\" name=\"groupid\" value=\"".$groupObj->getID()."\">";
2012-12-14 07:53:13 +00:00
print "<td>";
$this->printAccessModeSelection($groupAccess->getMode());
print "</td>\n";
print "<td><span class=\"actions\">\n";
print "<button type=\"submit\" class=\"btn btn-mini\"><i class=\"icon-save\"></i> ".getMLText("save")."</button>";
2012-12-14 07:53:13 +00:00
print "</span></td>\n";
print "</form>";
print "<form action=\"../op/op.FolderAccess.php\">\n";
echo createHiddenFieldWithKey('folderaccess')."\n";
2017-01-01 18:19:31 +00:00
print "<input type=\"hidden\" name=\"folderid\" value=\"".$folder->getID()."\">\n";
print "<input type=\"hidden\" name=\"action\" value=\"delaccess\">\n";
print "<input type=\"hidden\" name=\"groupid\" value=\"".$groupObj->getID()."\">\n";
2013-01-24 09:18:17 +00:00
print "<td>";
print "<button type=\"submit\" class=\"btn btn-mini\"><i class=\"icon-remove\"></i> ".getMLText("delete")."</button>";
print "</td>\n";
2012-12-14 07:53:13 +00:00
print "</form>";
print "</tr>\n";
}
print "</table><br>";
}
?>
2018-06-22 11:40:09 +00:00
</div>
</div>
2012-12-14 07:53:13 +00:00
<?php
$this->contentEnd();
2012-12-14 07:53:13 +00:00
$this->htmlEndPage();
} /* }}} */
}
?>