diff --git a/SeedDMS_Core/Core/inc.ClassAttribute.php b/SeedDMS_Core/Core/inc.ClassAttribute.php index df52ba5ff..6731bf7d1 100644 --- a/SeedDMS_Core/Core/inc.ClassAttribute.php +++ b/SeedDMS_Core/Core/inc.ClassAttribute.php @@ -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 diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index c701d5a2a..0d176da5a 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -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; } /* }}} */ /** diff --git a/SeedDMS_Core/Core/inc.ClassFolder.php b/SeedDMS_Core/Core/inc.ClassFolder.php index a60293017..6c9e84131 100644 --- a/SeedDMS_Core/Core/inc.ClassFolder.php +++ b/SeedDMS_Core/Core/inc.ClassFolder.php @@ -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; + } /* }}} */ + } ?> diff --git a/op/op.AttributeGroupMgr.php b/op/op.AttributeGroupMgr.php new file mode 100644 index 000000000..0c8eebb17 --- /dev/null +++ b/op/op.AttributeGroupMgr.php @@ -0,0 +1,275 @@ +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); + +?> diff --git a/op/op.FolderAttributeGroup.php b/op/op.FolderAttributeGroup.php new file mode 100644 index 000000000..9c9ab0cb5 --- /dev/null +++ b/op/op.FolderAttributeGroup.php @@ -0,0 +1,117 @@ + $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); + +?> diff --git a/out/out.AttributeGroupMgr.php b/out/out.AttributeGroupMgr.php new file mode 100644 index 000000000..d9b5b807a --- /dev/null +++ b/out/out.AttributeGroupMgr.php @@ -0,0 +1,64 @@ +$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); +} diff --git a/out/out.EditFolder.php b/out/out.EditFolder.php index fa64e9ef9..95b04f288 100644 --- a/out/out.EditFolder.php +++ b/out/out.EditFolder.php @@ -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); diff --git a/out/out.FolderAttributeGroup.php b/out/out.FolderAttributeGroup.php new file mode 100644 index 000000000..800b75c2e --- /dev/null +++ b/out/out.FolderAttributeGroup.php @@ -0,0 +1,58 @@ +$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; +} + +?> diff --git a/views/bootstrap/class.AttributeGroupMgr.php b/views/bootstrap/class.AttributeGroupMgr.php new file mode 100644 index 000000000..adfbab55b --- /dev/null +++ b/views/bootstrap/class.AttributeGroupMgr.php @@ -0,0 +1,367 @@ + + * @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 + * @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(""); + + if($("#comment").val() == "") msg.push(""); + + if (msg != "") { + noty({ + text: msg.join('
'), + type: 'error', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + _timeout: 1500, + }); + return false; + } else + return true; +} + +function checkForm2() { + msg = ""; + + if($("#attrdefid").val() == -1) msg += "\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()}); + }); +}); +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 ""; + print "\n\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n\n\n"; + foreach($folders as $subFolder) { + echo $this->folderListRow($subFolder); + } + echo "\n
".getMLText("name")."".getMLText("status")."".getMLText("action")."
\n"; + } + } /* }}} */ + + function showAttributeGroupForm($group) { /* {{{ */ + $dms = $this->params['dms']; + $user = $this->params['user']; + $allUsers = $this->params['attrdefs']; + $groups = $this->params['attrdefgroups']; +?> +
+ + + + + + + +check_access('RemoveAttributeDefinitionGroup')) { +?> + + + + + + + + + + + + + + + + + +
html_link('RemoveAttributeDefinitionGroup', array('attrdefgroupid'=>$group->getID()), array('class'=>'btn'), ' '.getMLText("rm_attrdefgroup"), false); ?>
:
:
+
+contentSubHeading(getMLText("group_members")); +?> + +getAttributeDefinitions(); + if (count($members) == 0) + print ""; + 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 ""; + print ""; + print ""; + print ""; + print ""; + $i++; + } + } +?> +
".getMLText("no_group_members")."
" . htmlspecialchars($member->getName()) ." (".$ot.", ".$t.")".""; + $show = $group->getShow($member); + $shows = array(); + for($i=0; $i<4; $i++) { + if(1 << $i & $show) + $shows[] = 1 << $i; + } + print "
getID()."\" />getID()."\" />".createHiddenFieldWithKey('setshow'); + echo " "; + print "
"; + print "
"; + if($i != 0) + print "
getID()."\" />getID()."\" />".createHiddenFieldWithKey('setsequence')."
"; + print "
"; + if($i < count($members)-1) + print "
getID()."\" />getID()."\" />".createHiddenFieldWithKey('setsequence')."
"; + print "
"; + print "
getID()."\" />getID()."\" />".createHiddenFieldWithKey('rmmember')."
"; + print "
+ +contentSubHeading(getMLText("add_member")); +?> + +
+ + + + + + + + + +
+ + + + + "> +
+
+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")); +?> + +
+
+
+: + +
+check_view_access($this, array('action'=>'info'))) { ?> +
getID()."\"" : "") ?>>
+ +
+ +
+
+check_view_access($this, array('action'=>'form'))) { ?> +
getID()."\"" : "") ?>>
+ +
+
+ +
+ +contentEnd(); + $this->htmlEndPage(); + } /* }}} */ +} +?> diff --git a/views/bootstrap/class.Bootstrap.php b/views/bootstrap/class.Bootstrap.php index a14184a2e..e72661267 100644 --- a/views/bootstrap/class.Bootstrap.php +++ b/views/bootstrap/class.Bootstrap.php @@ -726,6 +726,7 @@ $(document).ready(function () { echo "
  • ".getMLText("global_document_categories")."
  • \n"; if ($this->check_access('AttributeMgr')) echo "
  • ".getMLText("global_attributedefinitions")."
  • \n"; + echo "
  • ".getMLText("global_attributedefinitiongroups")."
  • \n"; if($this->params['workflowmode'] == 'advanced') { if ($this->check_access('WorkflowMgr')) echo "
  • ".getMLText("global_workflows")."
  • \n"; diff --git a/views/bootstrap/class.EditFolder.php b/views/bootstrap/class.EditFolder.php index edb215f21..1644ad894 100644 --- a/views/bootstrap/class.EditFolder.php +++ b/views/bootstrap/class.EditFolder.php @@ -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 "\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 "".htmlspecialchars($attrdefgrp['group']->getComment()).""; + foreach($attrdefs as $attrdef) { + $arr = $this->callHook('folderEditAttribute', $folder, $attrdef); + if(is_array($arr)) { + echo $txt; + echo ""; + echo "".$arr[0].""; + echo "".$arr[1].""; + echo ""; + } else { +?> + + getName()); ?> + printAttributeEditField($attrdef, $folder->getAttribute($attrdef)) ?> + +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() { getAttribute($attrdef)) { +?> + + getName()); ?> + getValue() ?> + + diff --git a/views/bootstrap/class.FolderAttributeGroup.php b/views/bootstrap/class.FolderAttributeGroup.php new file mode 100644 index 000000000..adece16fd --- /dev/null +++ b/views/bootstrap/class.FolderAttributeGroup.php @@ -0,0 +1,147 @@ + + * @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 + * @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(""); + if (msg != "") { + noty({ + text: msg.join('
    '), + 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(); + }); +}); +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 "\n"; + if (empty($attrgrpList)) { + print ""; + } + else { + + foreach ($attrgrpList as $attrgrp) { + print ""; + print ""; + print ""; + if ($user->isAdmin()) { + print "\n"; + echo createHiddenFieldWithKey('folderattributegroup')."\n"; + print "getID()."\">\n"; + print "\n"; + print "getID()."\">\n"; + print ""; + print "\n"; + }else print ""; + print ""; + $attrgrpIDs[] = $attrgrp['group']->getID(); + } + } + print "
    ".getMLText("empty_attribute_group_list")."
    " . htmlspecialchars($attrgrp['group']->getName()) . "
    "; + print ""; + print "
    \n"; + +?> +
    +
    + + + + + + + + + + + + +
    : + +
    ">
    +
    + +contentContainerEnd(); + $this->contentEnd(); + $this->htmlEndPage(); + } /* }}} */ +} +?>