seeddms-code/views/bootstrap/class.FolderAttributeGroup.php
2022-09-05 11:49:48 +02:00

154 lines
4.9 KiB
PHP

<?php
/**
* Implementation of FolderAttributeGroup view
*
* @category DMS
* @package SeedDMS
* @license GPL 2
* @version @version@
* @author Uwe Steinmann <uwe@steinmann.cx>
* @copyright Copyright (C) 202-2005 Markus Westphal,
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
* 2010-2016 Uwe Steinmann
* @version Release: @package_version@
*/
/**
* Include parent class
*/
//require_once("class.Bootstrap.php");
/**
* Class which outputs the html page for FolderAttributeGroup 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-2016 Uwe Steinmann
* @version Release: @package_version@
*/
class SeedDMS_View_FolderAttributeGroup extends SeedDMS_Bootstrap_Style {
function js() { /* {{{ */
header('Content-Type: application/javascript; charset=UTF-8');
?>
function checkForm()
{
msg = new Array();
if ((document.form1.userid.options[document.form1.userid.selectedIndex].value == -1) &&
(document.form1.groupid.options[document.form1.groupid.selectedIndex].value == -1))
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,
});
return false;
}
else
return true;
}
$(document).ready(function() {
$('body').on('submit', '#form1', function(ev){
if(checkForm()) return;
ev.preventDefault();
});
});
<?php
} /* }}} */
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$folder = $this->params['folder'];
$allGroups = $this->params['allattrgrps'];
$strictformcheck = $this->params['strictformcheck'];
$ifolder = null; // will be set to folder the current folder inherits a attr def group
$attrgrpList = $folder->getAttributeDefintionGroupList(true, $ifolder);
$this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))));
$this->globalNavigation($folder);
$this->contentStart();
$this->pageNavigation($this->getFolderPathHTML($folder, true), "view_folder", $folder);
$this->contentHeading(getMLText("edit_existing_attribute_groups"));
$attrgrpIDs = array();
print "<table class=\"table-condensed\">\n";
if (empty($attrgrpList)) {
print "<tr><td>".getMLText("empty_attribute_group_list")."</td></tr>";
}
else {
if($ifolder->getID() == $folder->getID()) {
foreach ($attrgrpList as $attrgrp) {
print "<tr>";
print "<td><i class=\"icon-tags\"></i></td>";
print "<td>" . htmlspecialchars($attrgrp['group']->getName()) . "</td>";
if ($user->isAdmin()) {
print "<form action=\"../op/op.FolderAttributeGroup.php\" method=\"post\">\n";
echo createHiddenFieldWithKey('folderattributegroup')."\n";
print "<input type=\"Hidden\" name=\"folderid\" value=\"".$folder->getID()."\">\n";
print "<input type=\"Hidden\" name=\"action\" value=\"delattributegroup\">\n";
print "<input type=\"Hidden\" name=\"groupid\" value=\"".$attrgrp['group']->getID()."\">\n";
print "<td>";
print "<button type=\"submit\" class=\"btn btn-danger btn-mini btn-sm\"><i class=\"icon-remove\"></i> ".getMLText("delete")."</button>";
print "</td>";
print "</form>\n";
}else print "<td></td>";
print "</tr>";
$attrgrpIDs[] = $attrgrp['group']->getID();
}
} else {
foreach ($attrgrpList as $attrgrp) {
print "<tr>";
print "<td><i class=\"icon-tags\"></i></td>";
print "<td>" . htmlspecialchars($attrgrp['group']->getName()) . "</td>";
print "<td><i class=\"icon-folder-close\"></i> <a href=\"../out/out.ViewFolder.php?folderid=".$ifolder->getID()."\">" . htmlspecialchars($ifolder->getName()) . "</a></td>";
print "</tr>";
}
}
}
print "</table>\n";
?>
<br>
<form action="../op/op.FolderAttributeGroup.php" class="form-horizontal" method="post" id="form1" name="form1">
<?php echo createHiddenFieldWithKey('folderattributegroup'); ?>
<input type="hidden" name="folderid" value="<?php print $folder->getID()?>">
<input type="hidden" name="action" value="addattributegroup">
<?php
$this->contentContainerStart();
$options = array();
$options[] = array(0, getMLText('select_one'));
foreach($allGroups as $groupObj) {
$options[] = array($groupObj->getID(), htmlspecialchars($groupObj->getName()), $user->isAdmin() && in_array($groupObj->getID(), $attrgrpIDs));
}
$this->formField(
getMLText("group"),
array(
'element'=>'select',
'name'=>'groupid',
'options'=>$options
)
);
$this->contentContainerEnd();
$this->formSubmit('<i class="fa fa-save"></i> '.getMLText("add"));
?>
</form>
<?php
$this->contentEnd();
$this->htmlEndPage();
} /* }}} */
}
?>