mirror of
https://git.code.sf.net/p/seeddms/code
synced 2026-02-06 00:21:55 +00:00
finished implementation of class SeedDMS_Core_AttributeDefinitionGroup
This commit is contained in:
parent
f046adc555
commit
20591bec91
|
|
@ -853,8 +853,8 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
|
|||
if($this->isUsed())
|
||||
return false;
|
||||
|
||||
// Delete user itself
|
||||
$queryStr = "DELETE FROM tblAttributeDefinitions WHERE id = " . $this->_id;
|
||||
// Delete attribute definition group itself
|
||||
$queryStr = "DELETE FROM tblAttributeDefinitionGroups WHERE id = " . $this->_id;
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
|
||||
return true;
|
||||
|
|
@ -1037,30 +1037,30 @@ class SeedDMS_Core_AttributeDefinition { /* {{{ */
|
|||
* @copyright Copyright (C) 2016 Uwe Steinmann
|
||||
* @version Release: @package_version@
|
||||
*/
|
||||
class SeedDMS_Core_AttributeDefinitionGroup {
|
||||
class SeedDMS_Core_AttributeDefinitionGroup { /* {{{ */
|
||||
/**
|
||||
* The id of the user group
|
||||
* The id of the attribute definition group
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $_id;
|
||||
|
||||
/**
|
||||
* The name of the user group
|
||||
* The name of the attribute definition group
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_name;
|
||||
|
||||
/**
|
||||
* The comment of the user group
|
||||
* The comment of the attribute definition group
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_comment;
|
||||
|
||||
/**
|
||||
* Back reference to DMS this user group belongs to
|
||||
* Back reference to DMS this attribute definition group belongs to
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
|
|
@ -1166,28 +1166,27 @@ class SeedDMS_Core_AttributeDefinitionGroup {
|
|||
|
||||
if (!isset($this->_attrdefs)) {
|
||||
$queryStr = "SELECT `tblAttributeDefinitions`.* FROM `tblAttributeDefinitions` ".
|
||||
"LEFT JOIN `tblAttributeDefinitionGroupAttributeDefinition` ON `tblAttributeDefinitionGroupAttributeDefinition`.`userID`=`tblAttributeDefinitions`.`id` ".
|
||||
"WHERE `tblGroupMembers`.`groupID` = '". $this->_id ."'";
|
||||
"LEFT JOIN `tblAttributeDefinitionGroupAttributeDefinition` ON `tblAttributeDefinitionGroupAttributeDefinition`.`attrdef`=`tblAttributeDefinitions`.`id` ".
|
||||
"WHERE `tblAttributeDefinitionGroupAttributeDefinition`.`attrgrp` = '". $this->_id ."'";
|
||||
$resArr = $db->getResultArray($queryStr);
|
||||
if (is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
|
||||
$this->_attrdefs = array();
|
||||
|
||||
$classname = $this->_dms->getClassname('attributedefinition');
|
||||
foreach ($resArr as $row) {
|
||||
$user = new $classname($row["id"], $row["login"], $row["pwd"], $row["fullName"], $row["email"], $row["language"], $row["theme"], $row["comment"], $role, $row['hidden']);
|
||||
$user->setDMS($this->_dms);
|
||||
array_push($this->_attrdefs, $user);
|
||||
$attrdef = new SeedDMS_Core_AttributeDefinition($row["id"], $row["name"], $row["objtype"], $row["type"], $row["multiple"], $row["minvalues"], $row["maxvalues"], $row["valueset"], $row["regex"]);
|
||||
$attrdef->setDMS($this->_dms);
|
||||
array_push($this->_attrdefs, $attrdef);
|
||||
}
|
||||
}
|
||||
return $this->_attrdefs;
|
||||
} /* }}} */
|
||||
|
||||
function addAttributeDefinition($user,$show=false) { /* {{{ */
|
||||
function addAttributeDefinition($attrdef, $show=false) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
$queryStr = "INSERT INTO tblAttributeDefinitionGroupAttributeDefinition (attrgroupdef, attrdef, show) VALUES (".$this->_id.", ".$user->getID(). ", " . (int)$show ." )";
|
||||
$queryStr = "INSERT INTO tblAttributeDefinitionGroupAttributeDefinition (attrgrp, attrdef, show) VALUES (".$this->_id.", ".$attrdef->getID(). ", " . (int)$show ." )";
|
||||
$res = $db->getResult($queryStr);
|
||||
|
||||
if (!$res) return false;
|
||||
|
|
@ -1199,7 +1198,7 @@ class SeedDMS_Core_AttributeDefinitionGroup {
|
|||
function removeAttributeDefinition($attrdef) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
$queryStr = "DELETE FROM tblAttributeDefinitionGroupAttributeDefinition WHERE attrgroupdef = ".$this->_id." AND attrdef = ".$attrdef->getID();
|
||||
$queryStr = "DELETE FROM tblAttributeDefinitionGroupAttributeDefinition WHERE attrgrp = ".$this->_id." AND attrdef = ".$attrdef->getID();
|
||||
$res = $db->getResult($queryStr);
|
||||
|
||||
if (!$res) return false;
|
||||
|
|
@ -1207,11 +1206,15 @@ class SeedDMS_Core_AttributeDefinitionGroup {
|
|||
return true;
|
||||
} /* }}} */
|
||||
|
||||
// $asManager=false: verify if user is in group
|
||||
// $asManager=true : verify if user is in group as manager
|
||||
/**
|
||||
* Check if attribute definition is member of group
|
||||
*
|
||||
* @param object $attrdef attribute definition to check
|
||||
* @return boolean true if attribute definition is a member otherwise false
|
||||
*/
|
||||
function isMember($attrdef) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
$queryStr = "SELECT * FROM tblAttributeDefinitionGroupAttributeDefinition WHERE attrgroupdef = " . $this->_id . " AND attrdef = " . $attrdef->getID();
|
||||
$queryStr = "SELECT * FROM tblAttributeDefinitionGroupAttributeDefinition WHERE attrgrp = " . $this->_id . " AND attrdef = " . $attrdef->getID();
|
||||
|
||||
$resArr = $db->getResultArray($queryStr);
|
||||
|
||||
|
|
@ -1221,28 +1224,14 @@ class SeedDMS_Core_AttributeDefinitionGroup {
|
|||
return true;
|
||||
} /* }}} */
|
||||
|
||||
function toggleManager($user) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
if (!$this->isMember($user)) return false;
|
||||
|
||||
if ($this->isMember($user,true)) $queryStr = "UPDATE tblGroupMembers SET manager = 0 WHERE groupID = ".$this->_id." AND userID = ".$user->getID();
|
||||
else $queryStr = "UPDATE tblGroupMembers SET manager = 1 WHERE groupID = ".$this->_id." AND userID = ".$user->getID();
|
||||
|
||||
if (!$db->getResult($queryStr)) return false;
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Delete user group
|
||||
* This function deletes the user group and all it references, like access
|
||||
* control lists, notifications, as a child of other groups, etc.
|
||||
* Delete attribute definition group
|
||||
* This function deletes the attribute definition group and all it
|
||||
* references.
|
||||
*
|
||||
* @param object $user the user doing the removal (needed for entry in
|
||||
* review log.
|
||||
* @return boolean true on success or false in case of an error
|
||||
*/
|
||||
function remove($user) { /* {{{ */
|
||||
function remove() { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
$db->startTransaction();
|
||||
|
|
@ -1258,5 +1247,5 @@ class SeedDMS_Core_AttributeDefinitionGroup {
|
|||
return true;
|
||||
} /* }}} */
|
||||
|
||||
}
|
||||
} /* }}} */
|
||||
?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user