add initial support for attribute definition groups

This commit is contained in:
Uwe Steinmann 2026-04-20 19:38:23 +02:00
parent e4074bd3d4
commit 4f43c62f1a
12 changed files with 7124 additions and 2 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

275
op/op.AttributeGroupMgr.php Normal file
View File

@ -0,0 +1,275 @@
<?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.Language.php");
include("../inc/inc.Init.php");
include("../inc/inc.Extension.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
if (!$user->isAdmin()) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
}
if (isset($_POST["action"])) $action = $_POST["action"];
else $action = null;
// Create new group --------------------------------------------------------
if ($action == "addgroup") {
/* Check if the form data comes for a trusted request */
if(!checkFormKey('addgroup')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
$name = $_POST["name"];
$comment = $_POST["comment"];
if (is_object($dms->getAttributeDefinitionGroupByName($name))) {
UI::exitError(getMLText("admin_tools"),getMLText("group_exists"));
}
$newGroup = $dms->addAttributeDefinitionGroup($name, $comment);
if (!$newGroup) {
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
}
$groupid=$newGroup->getID();
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_add_group')));
add_log_line("&action=addgroup&name=".$name);
}
// Delete group -------------------------------------------------------------
else if ($action == "removegroup") {
/* Check if the form data comes for a trusted request */
if(!checkFormKey('removegroup')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
if (!isset($_POST["attrdefgroupid"]) || !is_numeric($_POST["attrdefgroupid"]) || intval($_POST["attrdefgroupid"])<1) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id"));
}
$group = $dms->getAttributeDefinitionGroup($_POST["attrdefgroupid"]);
if (!is_object($group)) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id"));
}
if (!$group->remove($user)) {
UI::exitError(getMLText("admin_tools"),getMLText("error_occured"));
}
$groupid = '';
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_rm_group')));
add_log_line("?attrdefgroupid=".$_POST["attrdefgroupid"]."&action=removegroup");
}
// Modifiy group ------------------------------------------------------------
else if ($action == "editgroup") {
/* Check if the form data comes for a trusted request */
if(!checkFormKey('editgroup')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
if (!isset($_POST["attrdefgroupid"]) || !is_numeric($_POST["attrdefgroupid"]) || intval($_POST["attrdefgroupid"])<1) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id"));
}
$groupid=$_POST["attrdefgroupid"];
$group = $dms->getAttributeDefinitionGroup($groupid);
if (!is_object($group)) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id"));
}
$name = $_POST["name"];
$comment = $_POST["comment"];
if ($group->getName() != $name)
$group->setName($name);
if ($group->getComment() != $comment)
$group->setComment($comment);
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_edit_group')));
add_log_line("?attrdefgroupid=".$_POST["attrdefgroupid"]."&action=editgroup");
}
// Add user to group --------------------------------------------------------
else if ($action == "addmember") {
/* Check if the form data comes for a trusted request */
if(!checkFormKey('addmember')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
if (!isset($_POST["attrdefgroupid"]) || !is_numeric($_POST["attrdefgroupid"]) || intval($_POST["attrdefgroupid"])<1) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id"));
}
$groupid=$_POST["attrdefgroupid"];
$group = $dms->getAttributeDefinitionGroup($groupid);
if (!is_object($group)) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id"));
}
if (!isset($_POST["attrdefid"]) || !is_numeric($_POST["attrdefid"]) || intval($_POST["attrdefid"])<1) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id"));
}
$newMember = $dms->getAttributeDefinition($_POST["attrdefid"]);
if (!is_object($newMember)) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id"));
}
$show = 0;
foreach($_POST['shows'] as $s) {
$show += $s;
}
if (!$group->isMember($newMember)){
$group->addAttributeDefinition($newMember, $show);
}
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_add_group_member')));
add_log_line("?attrdefgroupid=".$groupid."&attrdefid=".$_POST["attrdefid"]."&action=addmember");
}
// Remove attribute definition from group --------------------------------------------------
else if ($action == "rmmember") {
/* Check if the form data comes for a trusted request */
if(!checkFormKey('rmmember')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
if (!isset($_POST["attrdefgroupid"]) || !is_numeric($_POST["attrdefgroupid"]) || intval($_POST["attrdefgroupid"])<1) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id"));
}
$groupid=$_POST["attrdefgroupid"];
$group = $dms->getAttributeDefinitionGroup($groupid);
if (!is_object($group)) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id"));
}
if (!isset($_POST["attrdefid"]) || !is_numeric($_POST["attrdefid"]) || intval($_POST["attrdefid"])<1) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id"));
}
$oldMember = $dms->getAttributeDefinition($_POST["attrdefid"]);
if (!is_object($oldMember)) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id"));
}
$group->removeAttributeDefinition($oldMember);
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_rm_group_member')));
add_log_line("?attrdefgroupid=".$groupid."&attrdefid=".$_POST["attrdefid"]."&action=rmmember");
}
// Set sequence of member of group --------------------------------------------------
else if ($action == "setsequence") {
/* Check if the form data comes for a trusted request */
if(!checkFormKey('setsequence')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
if (!isset($_POST["attrdefgroupid"]) || !is_numeric($_POST["attrdefgroupid"]) || intval($_POST["attrdefgroupid"])<1) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id"));
}
$groupid=$_POST["attrdefgroupid"];
$group = $dms->getAttributeDefinitionGroup($groupid);
if (!is_object($group)) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id"));
}
if (!isset($_POST["attrdefid"]) || !is_numeric($_POST["attrdefid"]) || intval($_POST["attrdefid"])<1) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id"));
}
$member = $dms->getAttributeDefinition($_POST["attrdefid"]);
if (!is_object($member)) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id"));
}
$group->setSequence($member, $_POST['sequence']);
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_set_group_sequence')));
add_log_line("?attrdefgroupid=".$groupid."&attrdefid=".$_POST["attrdefid"]."&action=setsequence");
}
// Set show of member of group --------------------------------------------------
else if ($action == "setshow") {
/* Check if the form data comes for a trusted request */
if(!checkFormKey('setshow')) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_request_token"));
}
if (!isset($_POST["attrdefgroupid"]) || !is_numeric($_POST["attrdefgroupid"]) || intval($_POST["attrdefgroupid"])<1) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id"));
}
$groupid=$_POST["attrdefgroupid"];
$group = $dms->getAttributeDefinitionGroup($groupid);
if (!is_object($group)) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_group_id"));
}
if (!isset($_POST["attrdefid"]) || !is_numeric($_POST["attrdefid"]) || intval($_POST["attrdefid"])<1) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id"));
}
$member = $dms->getAttributeDefinition($_POST["attrdefid"]);
if (!is_object($member)) {
UI::exitError(getMLText("admin_tools"),getMLText("invalid_user_id"));
}
$show = 0;
foreach($_POST['shows'] as $s) {
$show += $s;
}
$group->setShow($member, $show);
$session->setSplashMsg(array('type'=>'success', 'msg'=>getMLText('splash_set_group_show')));
add_log_line("?attrdefgroupid=".$groupid."&attrdefid=".$_POST["attrdefid"]."&action=setshow");
}
header("Location:../out/out.AttributeGroupMgr.php?attrdefgroupid=".$groupid);
?>

View File

@ -0,0 +1,117 @@
<?php
// MyDMS. Document Management System
// Copyright (C) 2002-2005 Markus Westphal
// Copyright (C) 2006-2008 Malcolm Cowe
//
// 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.Language.php");
include("../inc/inc.Init.php");
include("../inc/inc.Extension.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
if(!checkFormKey('folderattributegroup')) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("invalid_request_token"));
}
if (!isset($_POST["folderid"]) || !is_numeric($_POST["folderid"]) || intval($_POST["folderid"])<1) {
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))),getMLText("invalid_folder_id"));
}
$folderid = $_POST["folderid"];
$folder = $dms->getFolder($folderid);
if (!is_object($folder)) {
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))),getMLText("invalid_folder_id"));
}
if (!isset($_POST["action"]) || (strcasecmp($_POST["action"], "delattributegroup") && strcasecmp($_POST["action"], "addattributegroup"))) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("invalid_action"));
}
$action = $_POST["action"];
if (isset($_POST["groupid"]) && (!is_numeric($_POST["groupid"]) || $_POST["groupid"]<-1)) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("unknown_group"));
}
$groupid = isset($_POST["groupid"]) ? $_POST["groupid"] : -1;
if (isset($_POST["groupid"])&&$_POST["groupid"]!=-1){
$group=$dms->getAttributeDefinitionGroup($groupid);
if (!$user->isAdmin())
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("access_denied"));
}
$folderPathHTML = getFolderPathHTML($folder, true);
if ($folder->getAccessMode($user) < M_READ) {
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("access_denied"));
}
// Delete notification -------------------------------------------------------
if ($action == "delattributegroup") {
if ($groupid > 0) {
$res = $folder->removeAttributeDefinitionGroup($group);
$obj = $dms->getGroup($groupid);
}
switch ($res) {
case -1:
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),isset($userid) ? getMLText("unknown_user") : getMLText("unknown_group"));
break;
case -2:
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("access_denied"));
break;
case -3:
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("already_subscribed"));
break;
case -4:
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("internal_error"));
break;
case 0:
break;
}
}
// Add notification ----------------------------------------------------------
else if ($action == "addattributegroup") {
if ($groupid != -1) {
$res = $folder->addAttributeDefinitionGroup($group, false);
switch ($res) {
case -1:
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("unknown_group"));
break;
case -2:
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("access_denied"));
break;
case -3:
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("already_subscribed"));
break;
case -4:
UI::exitError(getMLText("folder_title", array("foldername" => $folder->getName())),getMLText("internal_error"));
break;
case 0:
break;
}
}
}
header("Location:../out/out.FolderAttributeGroup.php?folderid=".$folderid);
?>

View File

@ -0,0 +1,64 @@
<?php
// MyDMS. Document Management System
// Copyright (C) 2002-2005 Markus Westphal
// Copyright (C) 2006-2008 Malcolm Cowe
// Copyright (C) 2010 Matteo Lucarelli
// Copyright (C) 2010-2012 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.Language.php");
include("../inc/inc.Init.php");
include("../inc/inc.Extension.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
if (!$accessop->check_view_access($view, $_GET)) {
UI::exitError(getMLText("admin_tools"),getMLText("access_denied"));
}
$attrdefs = $dms->getAllAttributeDefinitions();
if (is_bool($attrdefs)) {
UI::exitError(getMLText("admin_tools"),getMLText("internal_error"));
}
$attrdefgroups = $dms->getAllAttributeDefinitionGroups();
if (is_bool($attrdefgroups)) {
UI::exitError(getMLText("admin_tools"),getMLText("internal_error"));
}
if(isset($_GET['attrdefgroupid']) && $_GET['attrdefgroupid']) {
$selgroup = $dms->getAttributeDefinitionGroup($_GET['attrdefgroupid']);
} else {
$selgroup = null;
}
if($view) {
$view->setParam('selattrdefgroup', $selgroup);
$view->setParam('attrdefgroups', $attrdefgroups);
$view->setParam('attrdefs', $attrdefs);
$view->setParam('strictformcheck', $settings->_strictFormCheck);
$view->setParam('cachedir', $settings->_cacheDir);
$view->setParam('previewWidthList', $settings->_previewWidthList);
$view->setParam('workflowmode', $settings->_workflowMode);
$view->setParam('timeout', $settings->_cmdTimeout);
$view->setParam('accessobject', $accessop);
$view($_GET);
}

View File

@ -50,10 +50,12 @@ if ($folder->getAccessMode($user) < M_READWRITE) {
}
$attrdefs = $dms->getAllAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_folder, SeedDMS_Core_AttributeDefinition::objtype_all));
$attrdefgrps = $folder->getAttributeDefintionGroupList();
if($view) {
$view->setParam('folder', $folder);
$view->setParam('attrdefs', $attrdefs);
$view->setParam('attrdefgrps', $attrdefgrps);
$view->setParam('strictformcheck', $settings->_strictFormCheck);
$view->setParam('nofolderformfields', $settings->_noFolderFormFields);
$view->setParam('rootfolderid', $settings->_rootFolderID);

View File

@ -0,0 +1,58 @@
<?php
// MyDMS. Document Management System
// Copyright (C) 2002-2005 Markus Westphal
// Copyright (C) 2006-2008 Malcolm Cowe
// Copyright (C) 2006-2008 Malcolm Cowe
//
// 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.Language.php");
include("../inc/inc.Init.php");
include("../inc/inc.Extension.php");
include("../inc/inc.DBInit.php");
include("../inc/inc.ClassUI.php");
include("../inc/inc.Authentication.php");
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
if (!isset($_GET["folderid"]) || !is_numeric($_GET["folderid"]) || intval($_GET["folderid"])<1) {
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))),getMLText("invalid_folder_id"));
}
$folder = $dms->getFolder($_GET["folderid"]);
if (!is_object($folder)) {
UI::exitError(getMLText("folder_title", array("foldername" => getMLText("invalid_folder_id"))),getMLText("invalid_folder_id"));
}
if ($folder->getAccessMode($user) < M_READ) {
UI::exitError(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName()))),getMLText("access_denied"));
}
$allAttrGroups = $dms->getAllAttributeDefinitionGroups($settings->_sortUsersInList);
if($view) {
$view->setParam('folder', $folder);
$view->setParam('allattrgrps', $allAttrGroups);
$view->setParam('strictformcheck', $settings->_strictFormCheck);
$view->setParam('accessobject', $accessop);
$view($_GET);
exit;
}
?>

View File

@ -0,0 +1,367 @@
<?php
/**
* Implementation of AttributeGroupMgr 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");
/**
* Include class to preview documents
*/
require_once("SeedDMS/Preview.php");
/**
* Class which outputs the html page for AttributeGroupMgr 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_AttributeGroupMgr extends SeedDMS_Bootstrap_Style {
function js() { /* {{{ */
$selgroup = $this->params['selattrdefgroup'];
$strictformcheck = $this->params['strictformcheck'];
header("Content-type: text/javascript");
?>
function checkForm1() {
msg = new Array();
if($("#name").val() == "") msg.push("<?php printMLText("js_no_name");?>");
<?php
if ($strictformcheck) {
?>
if($("#comment").val() == "") msg.push("<?php printMLText("js_no_comment");?>");
<?php
}
?>
if (msg != "") {
noty({
text: msg.join('<br />'),
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
_timeout: 1500,
});
return false;
} else
return true;
}
function checkForm2() {
msg = "";
if($("#attrdefid").val() == -1) msg += "<?php printMLText("js_select_user");?>\n";
if (msg != "") {
noty({
text: msg,
type: 'error',
dismissQueue: true,
layout: 'topRight',
theme: 'defaultTheme',
_timeout: 1500,
});
return false;
} else
return true;
}
$(document).ready( function() {
$('body').on('submit', '#form_1', function(ev){
if(checkForm1())
return;
ev.preventDefault();
});
$('body').on('submit', '#form_2', function(ev){
if(checkForm2())
return;
ev.preventDefault();
});
$( "#selector" ).change(function() {
$('div.ajax').trigger('update', {attrdefgroupid: $(this).val()});
});
});
<?php
} /* }}} */
function info() { /* {{{ */
$dms = $this->params['dms'];
$selgroup = $this->params['selattrdefgroup'];
$cachedir = $this->params['cachedir'];
$previewwidth = $this->params['previewWidthList'];
$workflowmode = $this->params['workflowmode'];
$timeout = $this->params['timeout'];
if($selgroup) {
$previewer = new SeedDMS_Preview_Previewer($cachedir, $previewwidth, $timeout);
$this->contentHeading(getMLText("group_info"));
$folders = $selgroup->getFolders();
print "<table id=\"viewfolder-table\" class=\"table table-condensed\">";
print "<thead>\n<tr>\n";
print "<th></th>\n";
print "<th>".getMLText("name")."</th>\n";
print "<th>".getMLText("status")."</th>\n";
print "<th>".getMLText("action")."</th>\n";
print "</tr>\n</thead>\n<tbody>\n";
foreach($folders as $subFolder) {
echo $this->folderListRow($subFolder);
}
echo "</tbody>\n</table>\n";
}
} /* }}} */
function showAttributeGroupForm($group) { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$allUsers = $this->params['attrdefs'];
$groups = $this->params['attrdefgroups'];
?>
<form action="../op/op.AttributeGroupMgr.php" name="form_1" id="form_1" method="post">
<?php
if($group) {
echo createHiddenFieldWithKey('editgroup');
?>
<input type="hidden" name="attrdefgroupid" value="<?php print $group->getID();?>">
<input type="hidden" name="action" value="editgroup">
<?php
} else {
echo createHiddenFieldWithKey('addgroup');
?>
<input type="hidden" name="action" value="addgroup">
<?php
}
?>
<table class="table-condensed">
<?php
if($group && $this->check_access('RemoveAttributeDefinitionGroup')) {
?>
<tr>
<td></td>
<td><?php echo $this->html_link('RemoveAttributeDefinitionGroup', array('attrdefgroupid'=>$group->getID()), array('class'=>'btn'), '<i class="icon-remove"></i> '.getMLText("rm_attrdefgroup"), false); ?></td>
</tr>
<?php
}
?>
<tr>
<td><?php printMLText("name");?>:</td>
<td><input type="text" name="name" id="name" value="<?php print $group ? htmlspecialchars($group->getName()) : '';?>"></td>
</tr>
<tr>
<td><?php printMLText("comment");?>:</td>
<td><textarea name="comment" id="comment" rows="4" cols="50"><?php print $group ? htmlspecialchars($group->getComment()) : '';?></textarea></td>
</tr>
<tr>
<td></td>
<td><button type="submit" class="btn"><i class="icon-save"></i> <?php printMLText("save")?></button></td>
</tr>
</table>
</form>
<?php
if($group) {
$this->contentSubHeading(getMLText("group_members"));
?>
<table class="table-condensed">
<?php
$members = $group->getAttributeDefinitions();
if (count($members) == 0)
print "<tr><td>".getMLText("no_group_members")."</td></tr>";
else {
$seqs = array();
$i = 0;
foreach ($members as $member) {
$seqs[$i] = $group->getSequence($member);
$i++;
}
$i = 0;
foreach ($members as $member) {
$seq = $seqs[$i];
$pseq = isset($seqs[$i-1]) ? $seqs[$i-1] : $seqs[$i] - 20.0;
$ppseq = isset($seqs[$i-2]) ? $seqs[$i-2] : $pseq - 20.0;
$nseq = isset($seqs[$i+1]) ? $seqs[$i+1] : $seqs[$i] + 20.0;
$nnseq = isset($seqs[$i+2]) ? $seqs[$i+2] : $nseq + 20.0;
$newupseq = ($pseq-$ppseq)/2+$ppseq;
$newdownseq = ($nnseq-$nseq)/2+$nseq;
switch($member->getObjType()) {
case SeedDMS_Core_AttributeDefinition::objtype_all:
$ot = getMLText("all");
break;
case SeedDMS_Core_AttributeDefinition::objtype_folder:
$ot = getMLText("folder");
break;
case SeedDMS_Core_AttributeDefinition::objtype_document:
$ot = getMLText("document");
break;
case SeedDMS_Core_AttributeDefinition::objtype_documentcontent:
$ot = getMLText("version");
break;
}
switch($member->getType()) {
case SeedDMS_Core_AttributeDefinition::type_int:
$t = getMLText("attrdef_type_int");
break;
case SeedDMS_Core_AttributeDefinition::type_float:
$t = getMLText("attrdef_type_float");
break;
case SeedDMS_Core_AttributeDefinition::type_string:
$t = getMLText("attrdef_type_string");
break;
case SeedDMS_Core_AttributeDefinition::type_date:
$t = getMLText("attrdef_type_date");
break;
case SeedDMS_Core_AttributeDefinition::type_boolean:
$t = getMLText("attrdef_type_boolean");
break;
}
print "<tr>";
print "<td><i class=\"icon-tag\"></i></td>";
print "<td>" . htmlspecialchars($member->getName()) ." (".$ot.", ".$t.")"."</td>";
print "<td>";
$show = $group->getShow($member);
$shows = array();
for($i=0; $i<4; $i++) {
if(1 << $i & $show)
$shows[] = 1 << $i;
}
print "<form action=\"../op/op.AttributeGroupMgr.php\" method=\"post\" class=\"form-inline\" style=\"display: inline-block; margin-bottom: 0px;\"><input type=\"hidden\" name=\"attrdefgroupid\" value=\"".$group->getID()."\" /><input type=\"hidden\" name=\"action\" value=\"setshow\" /><input type=\"hidden\" name=\"attrdefid\" value=\"".$member->getID()."\" />".createHiddenFieldWithKey('setshow');
echo "<select class=\"chzn-select\" multiple=\"multiple\" name=\"shows[]\" data-placeholder=\"".getMLText('select_attrdefgrp_show')."\">";
foreach(array(1=>'list', 2=>'detail', 4=>'search') as $i=>$k)
echo "<option value=\"".$i."\"".(($show & $i) ? " selected" : "").">".getMLText('attrdefgrp_show_'.$k)."</option>";
echo "</select> ";
print "<button type=\"submit\" class=\"btn\"><i class=\"icon-save\"></i></button></form>";
print "</td>";
print "<td>";
if($i != 0)
print "<form action=\"../op/op.AttributeGroupMgr.php\" method=\"post\" class=\"form-inline\" style=\"display: inline-block; margin-bottom: 0px;\"><input type=\"hidden\" name=\"attrdefgroupid\" value=\"".$group->getID()."\" /><input type=\"hidden\" name=\"action\" value=\"setsequence\" /><input type=\"hidden\" name=\"attrdefid\" value=\"".$member->getID()."\" /><input type=\"hidden\" name=\"sequence\" value=\"".($newupseq)."\" />".createHiddenFieldWithKey('setsequence')."<button type=\"submit\" class=\"btn btn-_mini\"><i class=\"icon-arrow-up\"></i></button></form>";
print "</td><td>";
if($i < count($members)-1)
print "<form action=\"../op/op.AttributeGroupMgr.php\" method=\"post\" class=\"form-inline\" style=\"display: inline-block; margin-bottom: 0px;\"><input type=\"hidden\" name=\"attrdefgroupid\" value=\"".$group->getID()."\" /><input type=\"hidden\" name=\"action\" value=\"setsequence\" /><input type=\"hidden\" name=\"attrdefid\" value=\"".$member->getID()."\" /><input type=\"hidden\" name=\"sequence\" value=\"".($newdownseq)."\" />".createHiddenFieldWithKey('setsequence')."<button type=\"submit\" class=\"btn btn-_mini\"><i class=\"icon-arrow-down\"></i></button></form>";
print "</td><td>";
print "<form action=\"../op/op.AttributeGroupMgr.php\" method=\"post\" class=\"form-inline\" style=\"display: inline-block; margin-bottom: 0px;\"><input type=\"hidden\" name=\"action\" value=\"rmmember\" /><input type=\"hidden\" name=\"attrdefgroupid\" value=\"".$group->getID()."\" /><input type=\"hidden\" name=\"attrdefid\" value=\"".$member->getID()."\" />".createHiddenFieldWithKey('rmmember')."<button type=\"submit\" class=\"btn btn-_mini\"><i class=\"icon-remove\"></i> ".getMLText("delete")."</button></form>";
print "</td></tr>";
$i++;
}
}
?>
</table>
<?php
$this->contentSubHeading(getMLText("add_member"));
?>
<form class="form-inline" action="../op/op.AttributeGroupMgr.php" method="POST" name="form_2" id="form_2">
<?php echo createHiddenFieldWithKey('addmember'); ?>
<input type="Hidden" name="action" value="addmember">
<input type="Hidden" name="attrdefgroupid" value="<?php print $group->getID();?>">
<table class="table-condensed">
<tr>
<td>
<select name="attrdefid" id="attrdefid">
<option value="-1"><?php printMLText("select_one");?>
<?php
foreach ($allUsers as $currUser)
if (!$group->isMember($currUser))
print "<option value=\"".$currUser->getID()."\">" . htmlspecialchars($currUser->getName()) . "\n";
?>
</select>
</td>
<td>
<select class="chzn-select" multiple="multiple" name="shows[]" data-placeholder="<?php printMLText('select_attrdefgrp_show'); ?>">
<?php
foreach(array(1=>'list', 2=>'detail', 4=>'search') as $i=>$k)
echo "<option value=\"".$i."\"".(($show & $i) ? " selected" : "").">".getMLText('attrdefgrp_show_'.$k)."</option>";
?>
</select>
</td>
<td>
<input type="submit" class="btn" value="<?php printMLText("add");?>">
</td>
</tr>
</table>
</form>
<?php
}
} /* }}} */
function form() { /* {{{ */
$selgroup = $this->params['selattrdefgroup'];
$this->showAttributeGroupForm($selgroup);
} /* }}} */
function show() { /* {{{ */
$dms = $this->params['dms'];
$user = $this->params['user'];
$accessop = $this->params['accessobject'];
$selgroup = $this->params['selattrdefgroup'];
$allGroups = $this->params['attrdefgroups'];
$strictformcheck = $this->params['strictformcheck'];
$this->htmlStartPage(getMLText("admin_tools"));
$this->globalNavigation();
$this->contentStart();
$this->pageNavigation(getMLText("admin_tools"), "admin_tools");
$this->contentHeading(getMLText("attrdefgroup_management"));
?>
<div class="row-fluid">
<div class="span4">
<div class="well">
<?php echo getMLText("selection")?>:
<select class="chzn-select" id="selector">
<option value="-1"><?php echo getMLText("choose_attrdefgroup")?>
<option value="0"><?php echo getMLText("add_attrdefgroup")?>
<?php
foreach ($allGroups as $group) {
print "<option value=\"".$group->getID()."\" ".($selgroup && $group->getID()==$selgroup->getID() ? 'selected' : '').">" . htmlspecialchars($group->getName());
}
?>
</select>
</div>
<?php if($accessop->check_view_access($this, array('action'=>'info'))) { ?>
<div class="ajax" data-view="AttributeGroupMgr" data-action="info" <?php echo ($selgroup ? "data-query=\"attrdefgroupid=".$selgroup->getID()."\"" : "") ?>></div>
<?php } ?>
</div>
<div class="span8">
<div class="well">
<?php if($accessop->check_view_access($this, array('action'=>'form'))) { ?>
<div class="ajax" data-view="AttributeGroupMgr" data-action="form" <?php echo ($selgroup ? "data-query=\"attrdefgroupid=".$selgroup->getID()."\"" : "") ?>></div>
<?php } ?>
</div>
</div>
</div>
<?php
$this->contentEnd();
$this->htmlEndPage();
} /* }}} */
}
?>

View File

@ -1096,6 +1096,8 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
$menuitems['definitions']['children']['document_categories'] = array('link'=>$this->params['settings']->_httpRoot."out/out.Categories.php", 'label'=>getMLText('global_document_categories'));
if ($accessobject->check_view_access('AttributeMgr'))
$menuitems['definitions']['children']['attribute_definitions'] = array('link'=>$this->params['settings']->_httpRoot."out/out.AttributeMgr.php", 'label'=>getMLText('global_attributedefinitions'));
if ($accessobject->check_view_access('AttributeGroupMgr'))
$menuitems['definitions']['children']['attributegroup_definitions'] = array('link'=>$this->params['settings']->_httpRoot."out/out.AttributeGroupMgr.php", 'label'=>getMLText("global_attributedefinitiongroups"));
if($this->params['workflowmode'] == 'advanced') {
if ($accessobject->check_view_access('WorkflowMgr'))
$menuitems['definitions']['children']['workflows'] = array('link'=>$this->params['settings']->_httpRoot."out/out.WorkflowMgr.php", 'label'=>getMLText('global_workflows'));

View File

@ -52,6 +52,7 @@ $(document).ready(function() {
$user = $this->params['user'];
$folder = $this->params['folder'];
$attrdefs = $this->params['attrdefs'];
$attrdefgrps = $this->params['attrdefgrps'];
$rootfolderid = $this->params['rootfolderid'];
$strictformcheck = $this->params['strictformcheck'];
$nofolderformfields = $this->params['nofolderformfields'];
@ -111,9 +112,38 @@ $(document).ready(function() {
$this->formField(getMLText("sequence"), $this->getSequenceChooser($parent, 'f', $folder->getID()).($orderby != 's' ? "<br />".getMLText('order_by_sequence_off') : ''));
}
}
if($attrdefs) {
if($attrdefgrps) {
foreach($attrdefgrps as $attrdefgrp) {
$attrdefs = $attrdefgrp['group']->getAttributeDefinitions(array(SeedDMS_Core_AttributeDefinition::objtype_all, SeedDMS_Core_AttributeDefinition::objtype_folder));
echo "<tr><td colspan=\"2\"><b>".htmlspecialchars($attrdefgrp['group']->getComment())."</b></td></tr>";
foreach($attrdefs as $attrdef) {
$arr = $this->callHook('folderEditAttribute', $folder, $attrdef);
if(is_array($arr)) {
echo $txt;
echo "<tr>";
echo "<td>".$arr[0]."</td>";
echo "<td>".$arr[1]."</td>";
echo "</tr>";
} else {
?>
<tr>
<td><?php echo htmlspecialchars($attrdef->getName()); ?></td>
<td><?php $this->printAttributeEditField($attrdef, $folder->getAttribute($attrdef)) ?></td>
</tr>
<?php
}
}
}
} elseif($attrdefs) {
foreach($attrdefs as $attrdef) {
$arr = $this->callHook('editFolderAttribute', $folder, $attrdef);
$found = false;
foreach($attrdefgrps as $attrdefgrp) {
if($attrdefgrp['group']->isMember($attrdef))
$found = true;
}
if($found) {
$arr = $this->callHook('folderEditAttribute', $folder, $attrdef);
if(is_array($arr)) {
if($arr) {
$this->formField($arr[0], $arr[1], isset($arr[2]) ? $arr[2] : null);
@ -123,6 +153,16 @@ $(document).ready(function() {
} else {
$this->formField(htmlspecialchars($attrdef->getName()), $this->getAttributeEditField($attrdef, $folder->getAttribute($attrdef)));
}
} else {
if($attribute = $folder->getAttribute($attrdef)) {
?>
<tr>
<td><?php echo htmlspecialchars($attrdef->getName()); ?></td>
<td><?php echo $attribute->getValue() ?></td>
</tr>
<?php
}
}
}
}
$arrs = $this->callHook('addFolderAttributes', $folder);

View File

@ -0,0 +1,147 @@
<?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'];
$attrgrpList = $folder->getAttributeDefintionGroupList();
$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"));
$this->contentContainerStart();
$attrgrpIDs = array();
print "<table class=\"table-condensed\">\n";
if (empty($attrgrpList)) {
print "<tr><td>".getMLText("empty_attribute_group_list")."</td></tr>";
}
else {
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-mini\"><i class=\"icon-remove\"></i> ".getMLText("delete")."</button>";
print "</td>";
print "</form>\n";
}else print "<td></td>";
print "</tr>";
$attrgrpIDs[] = $attrgrp['group']->getID();
}
}
print "</table>\n";
?>
<br>
<form action="../op/op.FolderAttributeGroup.php" 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">
<table class="table-condensed">
<tr>
<td><?php printMLText("group");?>:</td>
<td>
<select name="groupid">
<option value="-1"><?php printMLText("select_one");?>
<?php
foreach ($allGroups as $groupObj) {
if ($user->isAdmin() && !in_array($groupObj->getID(), $attrgrpIDs)) {
print "<option value=\"".$groupObj->getID()."\">" . htmlspecialchars($groupObj->getName()) . "\n";
}
}
?>
</select>
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" class="btn" value="<?php printMLText("add") ?>"></td>
</tr>
</table>
</form>
<?php
$this->contentContainerEnd();
$this->contentEnd();
$this->htmlEndPage();
} /* }}} */
}
?>