SeedDMS_Core_DMS::getAllAttributeDefinitions() has second parameter to filter attributes by type

This commit is contained in:
Uwe Steinmann 2022-05-20 12:03:47 +02:00
parent 55126a689b
commit f718f565ff
2 changed files with 21 additions and 7 deletions

View File

@ -2640,17 +2640,30 @@ class SeedDMS_Core_DMS {
/** /**
* Return list of all attributes definitions * Return list of all attributes definitions
* *
* @param integer $objtype select those attributes defined for an object type * @param integer|array $objtype select those attributes defined for an object type
* @param integer|array $type select those attributes defined for a type
* @return bool|SeedDMS_Core_AttributeDefinition[] of instances of <a href='psi_element://SeedDMS_Core_AttributeDefinition'>SeedDMS_Core_AttributeDefinition</a> or false * @return bool|SeedDMS_Core_AttributeDefinition[] of instances of <a href='psi_element://SeedDMS_Core_AttributeDefinition'>SeedDMS_Core_AttributeDefinition</a> or false
* or false * or false
*/ */
function getAllAttributeDefinitions($objtype=0) { /* {{{ */ function getAllAttributeDefinitions($objtype=0, $type=0) { /* {{{ */
$queryStr = "SELECT * FROM `tblAttributeDefinitions`"; $queryStr = "SELECT * FROM `tblAttributeDefinitions`";
if($objtype) { if($objtype || $type) {
if(is_array($objtype)) $queryStr .= ' WHERE ';
$queryStr .= ' WHERE `objtype` in (\''.implode("','", $objtype).'\')'; if($objtype) {
else if(is_array($objtype))
$queryStr .= ' WHERE `objtype`='.intval($objtype); $queryStr .= '`objtype` in (\''.implode("','", $objtype).'\')';
else
$queryStr .= '`objtype`='.intval($objtype);
}
if($objtype && $type) {
$queryStr .= ' AND ';
}
if($type) {
if(is_array($type))
$queryStr .= '`type` in (\''.implode("','", $type).'\')';
else
$queryStr .= '`type`='.intval($type);
}
} }
$queryStr .= ' ORDER BY `name`'; $queryStr .= ' ORDER BY `name`';
$resArr = $this->db->getResultArray($queryStr); $resArr = $this->db->getResultArray($queryStr);

View File

@ -29,6 +29,7 @@
- add more types to getStatisticalData() - add more types to getStatisticalData()
- add optional parameter $op to SeedDMS_Core_AttributeDefinition::getObjects() - add optional parameter $op to SeedDMS_Core_AttributeDefinition::getObjects()
- SeedDMS_Core_AttributeDefinition::getObjects() will not filter by value if null is passed - SeedDMS_Core_AttributeDefinition::getObjects() will not filter by value if null is passed
- SeedDMS_Core_DMS::getAllAttributeDefinitions() has second parameter to filter attributes by type
</notes> </notes>
<contents> <contents>
<dir baseinstalldir="SeedDMS" name="/"> <dir baseinstalldir="SeedDMS" name="/">