mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-06-18 02:59:27 +00:00
fix searching for folders by attributes
do not search documents if not at least one search criteria is given
This commit is contained in:
parent
b1fe82f193
commit
0acc1fad4d
|
@ -623,12 +623,11 @@ class SeedDMS_Core_DMS {
|
||||||
foreach($attributes as $attrdefid=>$attribute) {
|
foreach($attributes as $attrdefid=>$attribute) {
|
||||||
if($attribute) {
|
if($attribute) {
|
||||||
$attrdef = $this->getAttributeDefinition($attrdefid);
|
$attrdef = $this->getAttributeDefinition($attrdefid);
|
||||||
if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_document) {
|
if($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_folder) {
|
||||||
if($attrdef->getValueSet())
|
if($attrdef->getValueSet())
|
||||||
$searchAttributes[] = "`tblFolderAttributes`.`attrdef`=".$attrdefid." AND `tblFolderAttributes`.`value`='".$attribute."'";
|
$searchAttributes[] = "`tblFolderAttributes`.`attrdef`=".$attrdefid." AND `tblFolderAttributes`.`value`='".$attribute."'";
|
||||||
else
|
else
|
||||||
$searchAttributes[] = "`tblFolderAttributes`.`attrdef`=".$attrdefid." AND `tblFolderAttributes`.`value` like '%".$attribute."%'";
|
$searchAttributes[] = "`tblFolderAttributes`.`attrdef`=".$attrdefid." AND `tblFolderAttributes`.`value` like '%".$attribute."%'";
|
||||||
} elseif($attrdef->getObjType() == SeedDMS_Core_AttributeDefinition::objtype_documentcontent) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -665,11 +664,14 @@ class SeedDMS_Core_DMS {
|
||||||
if (strlen($searchCreateDate)>0) {
|
if (strlen($searchCreateDate)>0) {
|
||||||
$searchQuery .= " AND (".$searchCreateDate.")";
|
$searchQuery .= " AND (".$searchCreateDate.")";
|
||||||
}
|
}
|
||||||
|
if ($searchAttributes) {
|
||||||
|
$searchQuery .= " AND (".implode(" AND ", $searchAttributes).")";
|
||||||
|
}
|
||||||
|
|
||||||
/* Do not search for folders if not at least a search for a key,
|
/* Do not search for folders if not at least a search for a key,
|
||||||
* an owner, or creation date is requested.
|
* an owner, or creation date is requested.
|
||||||
*/
|
*/
|
||||||
if($searchKey || $searchOwner || $searchCreateDate) {
|
if($searchKey || $searchOwner || $searchCreateDate || $searchAttributes) {
|
||||||
// Count the number of rows that the search will produce.
|
// Count the number of rows that the search will produce.
|
||||||
$resArr = $this->db->getResultArray("SELECT COUNT(*) AS num ".$searchQuery);
|
$resArr = $this->db->getResultArray("SELECT COUNT(*) AS num ".$searchQuery);
|
||||||
if ($resArr && isset($resArr[0]) && is_numeric($resArr[0]["num"]) && $resArr[0]["num"]>0) {
|
if ($resArr && isset($resArr[0]) && is_numeric($resArr[0]["num"]) && $resArr[0]["num"]>0) {
|
||||||
|
@ -895,6 +897,7 @@ class SeedDMS_Core_DMS {
|
||||||
$searchQuery .= " AND `tblDocumentStatusLog`.`status` IN (".implode(',', $status).")";
|
$searchQuery .= " AND `tblDocumentStatusLog`.`status` IN (".implode(',', $status).")";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($searchKey || $searchOwner || $searchCategories || $searchCreateDate || $searchExpirationDate || $searchAttributes || $status) {
|
||||||
// Count the number of rows that the search will produce.
|
// Count the number of rows that the search will produce.
|
||||||
$resArr = $this->db->getResultArray("SELECT COUNT(*) AS num FROM (SELECT DISTINCT `tblDocuments`.id ".$searchQuery.") a");
|
$resArr = $this->db->getResultArray("SELECT COUNT(*) AS num FROM (SELECT DISTINCT `tblDocuments`.id ".$searchQuery.") a");
|
||||||
$totalDocs = 0;
|
$totalDocs = 0;
|
||||||
|
@ -946,6 +949,9 @@ class SeedDMS_Core_DMS {
|
||||||
} else {
|
} else {
|
||||||
$docresult = array('totalDocs'=>0, 'docs'=>array());
|
$docresult = array('totalDocs'=>0, 'docs'=>array());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$docresult = array('totalDocs'=>0, 'docs'=>array());
|
||||||
|
}
|
||||||
|
|
||||||
if($limit) {
|
if($limit) {
|
||||||
$totalPages = (integer)(($totalDocs+$totalFolders)/$limit);
|
$totalPages = (integer)(($totalDocs+$totalFolders)/$limit);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user