add initial support for attribute definition groups

This commit is contained in:
Uwe Steinmann 2016-07-29 07:52:51 +02:00
parent 253fd08a0b
commit 41f771a796
12 changed files with 1297 additions and 38 deletions

View File

@ -1066,6 +1066,14 @@ class SeedDMS_Core_AttributeDefinitionGroup { /* {{{ */
*/
protected $_dms;
/*
* When an attribute in a attribute definition group is shown
*/
const show_never = 0x0;
const show_list = 0x1;
const show_details = 0x2;
const show_search = 0x4;
function __construct($id, $name, $comment) { /* {{{ */
$this->_id = $id;
$this->_name = $name;
@ -1161,13 +1169,70 @@ class SeedDMS_Core_AttributeDefinitionGroup { /* {{{ */
return true;
} /* }}} */
function getAttributesDefinitions() { /* {{{ */
function getSequence($attrdef) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "SELECT * FROM `tblAttributeDefinitionGroupAttributeDefinition` ".
"WHERE `attrgrp` = '". $this->_id ."' AND `attrdef` = ".$attrdef->getID();
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false)
return false;
if(!$resArr)
return false;
return (float) $resArr[0]['sequence'];
} /* }}} */
function setSequence($attrdef, $newSequence) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE tblAttributeDefinitionGroupAttributeDefinition SET `sequence` = ".$db->qstr($newSequence)." WHERE `attrgrp` = " . $this->_id . " AND `attrdef` = " . $attrdef->getID();
if (!$db->getResult($queryStr))
return false;
return true;
} /* }}} */
function getShow($attrdef) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "SELECT * FROM `tblAttributeDefinitionGroupAttributeDefinition` ".
"WHERE `attrgrp` = '". $this->_id ."' AND `attrdef` = ".$attrdef->getID();
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false)
return false;
if(!$resArr)
return false;
return (float) $resArr[0]['show'];
} /* }}} */
function setShow($attrdef, $newShow) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "UPDATE tblAttributeDefinitionGroupAttributeDefinition SET `show` = ".$db->qstr($newShow)." WHERE `attrgrp` = " . $this->_id . " AND `attrdef` = " . $attrdef->getID();
if (!$db->getResult($queryStr))
return false;
return true;
} /* }}} */
function getAttributeDefinitions($objtype=array()) { /* {{{ */
$db = $this->_dms->getDB();
if (!isset($this->_attrdefs)) {
$queryStr = "SELECT `tblAttributeDefinitions`.* FROM `tblAttributeDefinitions` ".
"LEFT JOIN `tblAttributeDefinitionGroupAttributeDefinition` ON `tblAttributeDefinitionGroupAttributeDefinition`.`attrdef`=`tblAttributeDefinitions`.`id` ".
"WHERE `tblAttributeDefinitionGroupAttributeDefinition`.`attrgrp` = '". $this->_id ."'";
"WHERE `tblAttributeDefinitionGroupAttributeDefinition`.`attrgrp` = '". $this->_id ."' ";
if($objtype) {
if(is_array($objtype))
$queryStr .= ' AND `tblAttributeDefinitions`.`objtype` in (\''.implode("','", $objtype).'\') ';
else
$queryStr .= ' AND `tblAttributeDefinitions`.`objtype`='.intval($objtype).' ';
}
$queryStr .= "ORDER BY `tblAttributeDefinitionGroupAttributeDefinition`.`sequence` ASC";
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false)
return false;
@ -1186,7 +1251,18 @@ class SeedDMS_Core_AttributeDefinitionGroup { /* {{{ */
function addAttributeDefinition($attrdef, $show=false) { /* {{{ */
$db = $this->_dms->getDB();
$queryStr = "INSERT INTO tblAttributeDefinitionGroupAttributeDefinition (attrgrp, attrdef, show) VALUES (".$this->_id.", ".$attrdef->getID(). ", " . (int)$show ." )";
$queryStr = "SELECT MAX(`sequence`) as m FROM `tblAttributeDefinitionGroupAttributeDefinition` ".
"WHERE `attrgrp` = '". $this->_id."'";
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false)
return false;
if(!$resArr)
$seq = 10.0;
else
$seq = $resArr[0]['m'] + 10.0;
$queryStr = "INSERT INTO tblAttributeDefinitionGroupAttributeDefinition (`attrgrp`, `attrdef`, `sequence`, `show`) VALUES (".$this->_id.", ".$attrdef->getID(). ", " . $seq . ", " . (int) $show ." )";
$res = $db->getResult($queryStr);
if (!$res) return false;
@ -1224,6 +1300,31 @@ class SeedDMS_Core_AttributeDefinitionGroup { /* {{{ */
return true;
} /* }}} */
/**
* Get all folders this attribute definition is assigned to
*
* @return array list of folders
*/
function getFolders() { /* {{{ */
$db = $this->_dms->getDB();
if (!isset($this->_folders))
{
$queryStr = "SELECT `tblFolderAttributeDefinitionGroup`.* FROM `tblFolderAttributeDefinitionGroup` WHERE `tblFolderAttributeDefinitionGroup`.`attrgrp`='". $this->_id ."'";
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false)
return false;
$this->_folders = array();
foreach ($resArr as $row) {
$folder = $this->_dms->getFolder($row["folder"]);
$folder->setDMS($this->_dms);
array_push($this->_folders, $folder);
}
}
return $this->_folders;
} /* }}} */
/**
* Delete attribute definition group
* This function deletes the attribute definition group and all it

View File

@ -402,6 +402,7 @@ class SeedDMS_Core_DMS {
$this->classnames['user'] = 'SeedDMS_Core_User';
$this->classnames['role'] = 'SeedDMS_Core_Role';
$this->classnames['group'] = 'SeedDMS_Core_Group';
$this->classnames['attributedefinitiongroup'] = 'SeedDMS_Core_AttributeDefinitionGroup';
$this->classnames['transmittal'] = 'SeedDMS_Core_Transmittal';
$this->classnames['transmittalitem'] = 'SeedDMS_Core_TransmittalItem';
$this->callbacks = array();
@ -2308,53 +2309,65 @@ class SeedDMS_Core_DMS {
} /* }}} */
/**
* Return a attribute definition group by its id
* Get a group by its id
*
* This function retrieves a attribute definition group from the database by
* its id.
*
* @param integer $id internal id of attribute defintion group
* @return object instance of {@link SeedDMS_Core_AttributeDefinitionGroup} or false
* @param integer $id id of group
* @return object/boolean group or false if no group was found
*/
function getAttributeDefinitionGroup($id) { /* {{{ */
if (!is_numeric($id))
return false;
$queryStr = "SELECT * FROM tblAttributeDefinitionGroups WHERE id = " . (int) $id;
$resArr = $this->db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false) return false;
if (count($resArr) != 1) return false;
$resArr = $resArr[0];
$attrdef = new SeedDMS_Core_AttributeDefinitionGroup($resArr["id"], $resArr["name"], $resArr["comment"]);
$attrdef->setDMS($this);
return $attrdef;
$classname = $this->classnames['attributedefinitiongroup'];
return $classname::getInstance($id, $this, '');
} /* }}} */
/**
* Return list of all attributes definition groups
* Get a group by its name
*
* @return array of instances of {@link SeedDMS_Core_AttributeDefinitionGroup} or false
* @param string $name name of group
* @return object/boolean group or false if no group was found
*/
function getAttributeDefinitionGroupByName($name) { /* {{{ */
$classname = $this->classnames['attributedefinitiongroup'];
return $classname::getInstance($name, $this, 'name');
} /* }}} */
/**
* Get a list of all groups
*
* @return array array of instances of {@link SeedDMS_Core_Group}
*/
function getAllAttributeDefinitionGroups() { /* {{{ */
$queryStr = "SELECT * FROM tblAttributeDefinitionGroups";
$queryStr .= ' ORDER BY name';
$resArr = $this->db->getResultArray($queryStr);
$classname = $this->classnames['attributedefinitiongroup'];
return $classname::getAllInstances('name', $this);
} /* }}} */
if (is_bool($resArr) && $resArr == false)
/**
* Create a new attribute defintion group
*
* @param string $name name of group
* @param string $comment comment of group
* @return object/boolean instance of {@link SeedDMS_Core_AttributeDefinitionGroup}
* or false in case of an error.
*/
function addAttributeDefinitionGroup($name, $comment) { /* {{{ */
if (is_object($this->getAttributeDefinitionGroupByName($name))) {
return false;
$attrdefs = array();
for ($i = 0; $i < count($resArr); $i++) {
$attrdef = new SeedDMS_Core_AttributeDefinitionGroup($resArr[$i]["id"], $resArr[$i]["name"], $resArr[$i]["comment"]);
$attrdef->setDMS($this);
$attrdefs[$i] = $attrdef;
}
return $attrdefs;
$queryStr = "INSERT INTO tblAttributeDefinitionGroups (name, comment) VALUES (".$this->db->qstr($name).", ".$this->db->qstr($comment).")";
if (!$this->db->getResult($queryStr))
return false;
$group = $this->getAttributeDefinitionGroup($this->db->getInsertID());
/* Check if 'onPostAddAttributeDefinitionGroup' callback is set */
if(isset($this->_dms->callbacks['onPostAddAttributeDefinitionGroup'])) {
foreach($this->_dms->callbacks['onPostAddAttributeDefinitionGroup'] as $callback) {
if(!call_user_func($callback[0], $callback[1], $group)) {
}
}
}
return $group;
} /* }}} */
/**

View File

@ -1667,6 +1667,81 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
return true;
} /* }}} */
/**
* Get a list of all assigned attribute defintion groups
*
* @return array array with a the elements 'users' and 'groups' which
* contain a list of users and groups.
*/
function getAttributeDefintionGroupList() { /* {{{ */
if (empty($this->_attrdefgrpList)) {
$db = $this->_dms->getDB();
$queryStr ="SELECT * FROM tblFolderAttributeDefinitionGroup WHERE folder = " . $this->_id . " ORDER BY `sequence`";
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false)
return false;
$this->_attrdefgrpList = array();
foreach ($resArr as $row) {
array_push($this->_attrdefgrpList, array('group'=>$this->_dms->getAttributeDefinitionGroup($row["attrgrp"]), 'sequence'=>$row['sequence']));
}
}
return $this->_attrdefgrpList;
} /* }}} */
/*
* Add an attribute definition group to the folder
*
* @param object $attrdefgroup
* @param float $seq
* @return integer error code
* -1: Invalid attrdefgroup.
* -3: Attribute Definition Group is already added.
* -4: Database / internal error.
* 0: Update successful.
*/
function addAttributeDefinitionGroup($attrdefgroup, $seq=false) { /* {{{ */
$db = $this->_dms->getDB();
/* Verify that attribute definition group exists */
if (!is_object($attrdefgroup)) {
return -1;
}
// Check to see if attribute definition group is already on the list.
$queryStr = "SELECT * FROM `tblFolderAttributeDefinitionGroup` WHERE `folder` = '".$this->_id."' ".
"AND `attrgrp` = '". (int) $attrdefgroup->getID()."'";
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr)) {
return -4;
}
if (count($resArr)>0) {
return -3;
}
if(!$seq || !is_numeric($seq)) {
$queryStr = "SELECT MAX(`sequence`) as m FROM `tblFolderAttributeDefinitionGroup` ".
"WHERE `folder` = '". $this->_id."'";
$resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr == false)
return false;
if(!$resArr)
$seq = 10.0;
else
$seq = $resArr[0]['m'] + 10.0;
}
$queryStr = "INSERT INTO tblFolderAttributeDefinitionGroup (folder, attrgrp, sequence) VALUES (" . $this->_id . ", " . (int) $attrdefgroup->getID() . ", " . $seq . ")";
if (!$db->getResult($queryStr))
return -4;
unset($this->_attrdefgrpList);
return 0;
} /* }}} */
}
?>

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

@ -45,10 +45,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('rootfolderid', $settings->_rootFolderID);
$view->setParam('orderby', $settings->_sortFoldersDefault);

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

@ -726,6 +726,7 @@ $(document).ready(function () {
echo " <li><a href=\"../out/out.Categories.php\">".getMLText("global_document_categories")."</a></li>\n";
if ($this->check_access('AttributeMgr'))
echo " <li><a href=\"../out/out.AttributeMgr.php\">".getMLText("global_attributedefinitions")."</a></li>\n";
echo " <li><a href=\"../out/out.AttributeGroupMgr.php\">".getMLText("global_attributedefinitiongroups")."</a></li>\n";
if($this->params['workflowmode'] == 'advanced') {
if ($this->check_access('WorkflowMgr'))
echo " <li><a href=\"../out/out.WorkflowMgr.php\">".getMLText("global_workflows")."</a></li>\n";

View File

@ -91,6 +91,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'];
$orderby = $this->params['orderby'];
@ -127,8 +128,36 @@ $(document).ready(function() {
print "</td></tr>\n";
}
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) {
$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)) {
echo $txt;
@ -144,6 +173,16 @@ $(document).ready(function() {
</tr>
<?php
}
} else {
if($attribute = $folder->getAttribute($attrdef)) {
?>
<tr>
<td><?php echo htmlspecialchars($attrdef->getName()); ?></td>
<td><?php echo $attribute->getValue() ?></td>
</tr>
<?php
}
}
}
}
?>

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();
} /* }}} */
}
?>