mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-27 16:29:22 +01:00
Fix category search missing when result is a child, but parent does not match too
This commit is contained in:
parent
1e53272309
commit
2218fd8956
@ -338,7 +338,8 @@ class admin_categories
|
|||||||
}
|
}
|
||||||
$cats = new categories($filter['owner'],$query['appname']);
|
$cats = new categories($filter['owner'],$query['appname']);
|
||||||
$globalcat = isset($GLOBALS['egw_info']['user']['apps']['admin']) ? 'all_no_acl' : $globalcat; // ignore acl only for admins
|
$globalcat = isset($GLOBALS['egw_info']['user']['apps']['admin']) ? 'all_no_acl' : $globalcat; // ignore acl only for admins
|
||||||
$rows = $cats->return_sorted_array($query['start'],false,$query['search'],$query['sort'],$query['order'],$globalcat,$parent=0,true,$filter);
|
$parent = $query['search'] ? false : 0;
|
||||||
|
$rows = $cats->return_sorted_array($query['start'],false,$query['search'],$query['sort'],$query['order'],$globalcat,$parent,true,$filter);
|
||||||
$count = $cats->total_records;
|
$count = $cats->total_records;
|
||||||
foreach($rows as $key => &$row)
|
foreach($rows as $key => &$row)
|
||||||
{
|
{
|
||||||
|
@ -333,7 +333,10 @@ class categories
|
|||||||
//error_log(__METHOD__."($start,$limit,$query,$sort,$order,globals=$globals,parent=$parent_id,$unserialize_data) account_id=$this->account_id, appname=$this->app_name: ".function_backtrace());
|
//error_log(__METHOD__."($start,$limit,$query,$sort,$order,globals=$globals,parent=$parent_id,$unserialize_data) account_id=$this->account_id, appname=$this->app_name: ".function_backtrace());
|
||||||
|
|
||||||
$parents = $cats = array();
|
$parents = $cats = array();
|
||||||
if (!($cats = $this->return_array('all',0,false,$query,$sort,$order,$globals,(array)$parent_id,-1,'',$filter,$unserialize_data)))
|
|
||||||
|
// Cast parent_id to array, but only if there is one
|
||||||
|
if($parent_id !== false && $parent_id !== null) $parent_id = (array)$parent_id;
|
||||||
|
if (!($cats = $this->return_array('all',0,false,$query,$sort,$order,$globals,$parent_id,-1,'',$filter,$unserialize_data)))
|
||||||
{
|
{
|
||||||
$cats = array();
|
$cats = array();
|
||||||
}
|
}
|
||||||
@ -341,31 +344,36 @@ class categories
|
|||||||
{
|
{
|
||||||
$parents[] = $cat['id'];
|
$parents[] = $cat['id'];
|
||||||
}
|
}
|
||||||
while (count($parents))
|
|
||||||
|
if($parent_id || !$cats) // Avoid wiping search results
|
||||||
{
|
{
|
||||||
if (!($subs = $this->return_array('all',0,false,$query,$sort,$order,$globals,$parents,-1,'',$filter,$unserialize_data)))
|
// Go find the children
|
||||||
|
while (count($parents))
|
||||||
{
|
{
|
||||||
break;
|
if (!($subs = $this->return_array('all',0,false,$query,$sort,$order,$globals,$parents,-1,'',$filter,$unserialize_data)))
|
||||||
}
|
|
||||||
$parents = $children = array();
|
|
||||||
foreach($subs as $cat)
|
|
||||||
{
|
|
||||||
$parents[] = $cat['id'];
|
|
||||||
$children[$cat['parent']][] = $cat;
|
|
||||||
}
|
|
||||||
// sort the cats into the mains
|
|
||||||
if (count($children))
|
|
||||||
{
|
|
||||||
$cats2 = $cats;
|
|
||||||
$cats = array();
|
|
||||||
foreach($cats2 as $cat)
|
|
||||||
{
|
{
|
||||||
$cats[] = $cat;
|
break;
|
||||||
if (isset($children[$cat['id']]))
|
}
|
||||||
|
$parents = $children = array();
|
||||||
|
foreach($subs as $cat)
|
||||||
|
{
|
||||||
|
$parents[] = $cat['id'];
|
||||||
|
$children[$cat['parent']][] = $cat;
|
||||||
|
}
|
||||||
|
// sort the cats into the mains
|
||||||
|
if (count($children))
|
||||||
|
{
|
||||||
|
$cats2 = $cats;
|
||||||
|
$cats = array();
|
||||||
|
foreach($cats2 as $cat)
|
||||||
{
|
{
|
||||||
foreach($children[$cat['id']] as $child)
|
$cats[] = $cat;
|
||||||
|
if (isset($children[$cat['id']]))
|
||||||
{
|
{
|
||||||
$cats[] = $child;
|
foreach($children[$cat['id']] as $child)
|
||||||
|
{
|
||||||
|
$cats[] = $child;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user