typeahead search for folders can search in subfolders

This commit is contained in:
Uwe Steinmann 2021-05-04 09:03:10 +02:00
parent a8dfcd9528
commit 4be72880a8
2 changed files with 32 additions and 0 deletions

View File

@ -8,6 +8,7 @@
- fixed error due to multiple declared function when controller method
RemoveFolder::run was called more than once
- fix php error setting mandatory workflow when uploading documents via webdav
- typeahead search for folders can search in subfolders
--------------------------------------------------------------------------------
Changes in version 5.1.22

View File

@ -145,6 +145,37 @@ switch($command) {
if($user) {
$query = $_GET['query'];
if(false !== ($pos = strpos($query, '/'))) {
$subquery = substr($query, 0, $pos);
$hits = $dms->search($subquery, $limit=0, $offset=0, $logicalmode='AND', $searchin=array(), $startFolder=$dms->getRootFolder(), $owner=null, $status = array(), $creationstartdate=array(), $creationenddate=array(), $modificationstartdate=array(), $modificationenddate=array(), $categories=array(), $attributes=array(), $mode=0x2, $expirationstartdate=array(), $expirationenddate=array());
if($hits) {
if(count($hits['folders']) == 1) {
$hit = $hits['folders'][0];
$basefolder = $dms->getFolder($hit->getID());
if($subquery = substr($query, $pos+1)) {
$hits = $dms->search($subquery, $limit=0, $offset=0, $logicalmode='AND', $searchin=array(), $startFolder=$basefolder, $owner=null, $status = array(), $creationstartdate=array(), $creationenddate=array(), $modificationstartdate=array(), $modificationenddate=array(), $categories=array(), $attributes=array(), $mode=0x2, $expirationstartdate=array(), $expirationenddate=array());
if($hits) {
$result = array();
foreach($hits['folders'] as $hit) {
$result[] = $hit->getID().'#'.$basefolder->getName().'/'.$hit->getName();
}
header('Content-Type: application/json');
echo json_encode($result);
return;
}
} else {
$subfolders = $basefolder->getSubFolders();
$result = array();
foreach($subfolders as $subfolder) {
$result[] = $subfolder->getID().'#'.$basefolder->getName().'/'.$subfolder->getName();
}
header('Content-Type: application/json');
echo json_encode($result);
return;
}
}
}
}
$hits = $dms->search($query, $limit=0, $offset=0, $logicalmode='AND', $searchin=array(), $startFolder=$dms->getRootFolder(), $owner=null, $status = array(), $creationstartdate=array(), $creationenddate=array(), $modificationstartdate=array(), $modificationenddate=array(), $categories=array(), $attributes=array(), $mode=0x2, $expirationstartdate=array(), $expirationenddate=array());
if($hits) {
$result = array();