Fix category search missing when result is a child, but parent does not match too

This commit is contained in:
Nathan Gray 2012-11-05 17:56:03 +00:00
parent 1e53272309
commit 2218fd8956
2 changed files with 31 additions and 22 deletions

View File

@ -338,7 +338,8 @@ class admin_categories
}
$cats = new categories($filter['owner'],$query['appname']);
$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;
foreach($rows as $key => &$row)
{

View File

@ -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());
$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();
}
@ -341,6 +344,10 @@ class categories
{
$parents[] = $cat['id'];
}
if($parent_id || !$cats) // Avoid wiping search results
{
// Go find the children
while (count($parents))
{
if (!($subs = $this->return_array('all',0,false,$query,$sort,$order,$globals,$parents,-1,'',$filter,$unserialize_data)))
@ -371,6 +378,7 @@ class categories
}
}
}
}
$this->total_records = count($cats);
// limit the number of returned rows