From f718f565ffbffdd9445b800ce271ff45e30bcaf9 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 20 May 2022 12:03:47 +0200 Subject: [PATCH 1/3] SeedDMS_Core_DMS::getAllAttributeDefinitions() has second parameter to filter attributes by type --- SeedDMS_Core/Core/inc.ClassDMS.php | 27 ++++++++++++++++++++------- SeedDMS_Core/package.xml | 1 + 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index 9fd4a58a5..ad59145d3 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -2640,17 +2640,30 @@ class SeedDMS_Core_DMS { /** * 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 SeedDMS_Core_AttributeDefinition or false * or false */ - function getAllAttributeDefinitions($objtype=0) { /* {{{ */ + function getAllAttributeDefinitions($objtype=0, $type=0) { /* {{{ */ $queryStr = "SELECT * FROM `tblAttributeDefinitions`"; - if($objtype) { - if(is_array($objtype)) - $queryStr .= ' WHERE `objtype` in (\''.implode("','", $objtype).'\')'; - else - $queryStr .= ' WHERE `objtype`='.intval($objtype); + if($objtype || $type) { + $queryStr .= ' WHERE '; + if($objtype) { + if(is_array($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`'; $resArr = $this->db->getResultArray($queryStr); diff --git a/SeedDMS_Core/package.xml b/SeedDMS_Core/package.xml index 66669bd72..1d88541ca 100644 --- a/SeedDMS_Core/package.xml +++ b/SeedDMS_Core/package.xml @@ -29,6 +29,7 @@ - add more types to getStatisticalData() - add optional parameter $op to SeedDMS_Core_AttributeDefinition::getObjects() - 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 From 8f6402c51f839ab5bda4bc9596869c496661a206 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 20 May 2022 12:04:24 +0200 Subject: [PATCH 2/3] extension config can filter attributes by type --- views/bootstrap/class.Settings.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/views/bootstrap/class.Settings.php b/views/bootstrap/class.Settings.php index d266e5b8c..04b400c5c 100644 --- a/views/bootstrap/class.Settings.php +++ b/views/bootstrap/class.Settings.php @@ -613,10 +613,9 @@ if(($kkk = $this->callHook('getFullSearchEngine')) && is_array($kkk)) } break; case "attributedefinitions": - if(empty($conf['objtype'])) - $recs = $dms->getAllAttributeDefinitions(); - else - $recs = $dms->getAllAttributeDefinitions(explode(',', $conf['objtype'])); + $objtype = empty($conf['objtype']) ? 0 : $conf['objtype']; + $attrtype = empty($conf['attrtype']) ? 0 : $conf['attrtype']; + $recs = $dms->getAllAttributeDefinitions(explode(',', $objtype), explode(',', $attrtype)); if($recs) { echo "