mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 06:30:59 +01:00
fixed and enhanced cat-filter:
- cats with children were not working, because: + sql applied two filters (one in UI and one in SO, UI is removed now) + ldap did not handle it at all - new cat-filter 'None', which returns all contacts without a category
This commit is contained in:
parent
f4e79928f6
commit
816e11629a
@ -644,9 +644,8 @@ class so_ldap
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$colFilter = $this->_colFilter($filter);
|
$colFilter = $this->_colFilter($filter);
|
||||||
|
|
||||||
$ldapFilter = "(&$objectFilter$searchFilter$colFilter)";
|
$ldapFilter = "(&$objectFilter$searchFilter$colFilter)";
|
||||||
|
|
||||||
if (!($rows = $this->_searchLDAP($searchDN, $ldapFilter, $this->all_attributes, $addressbookType)))
|
if (!($rows = $this->_searchLDAP($searchDN, $ldapFilter, $this->all_attributes, $addressbookType)))
|
||||||
{
|
{
|
||||||
return $rows;
|
return $rows;
|
||||||
@ -703,7 +702,7 @@ class so_ldap
|
|||||||
$filters = '';
|
$filters = '';
|
||||||
foreach($filter as $key => $value)
|
foreach($filter as $key => $value)
|
||||||
{
|
{
|
||||||
if (!$value) continue;
|
if ($key != 'cat_id' && !$value) continue;
|
||||||
|
|
||||||
switch((string) $key)
|
switch((string) $key)
|
||||||
{
|
{
|
||||||
@ -712,11 +711,25 @@ class so_ldap
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'cat_id':
|
case 'cat_id':
|
||||||
if((int)$value)
|
if (is_null($value))
|
||||||
{
|
{
|
||||||
$catName = $GLOBALS['egw']->translation->convert(
|
$filters .= '(!(category=*))';
|
||||||
ExecMethod('phpgwapi.categories.id2name',$value),$this->charset,'utf-8');
|
}
|
||||||
$filters .= '(category='.ldap::quote($catName).')';
|
elseif((int)$value)
|
||||||
|
{
|
||||||
|
if (!is_object($GLOBALS['egw']->categories))
|
||||||
|
{
|
||||||
|
$GLOBALS['egw']->categories = CreateObject('phpgwapi.categories');
|
||||||
|
}
|
||||||
|
$cats = $GLOBALS['egw']->categories->return_all_children((int)$value);
|
||||||
|
if (count($cats) > 1) $filters .= '(|';
|
||||||
|
foreach($cats as $cat)
|
||||||
|
{
|
||||||
|
$catName = $GLOBALS['egw']->translation->convert(
|
||||||
|
$GLOBALS['egw']->categories->id2name($cat),$this->charset,'utf-8');
|
||||||
|
$filters .= '(category='.ldap::quote($catName).')';
|
||||||
|
}
|
||||||
|
if (count($cats) > 1) $filters .= ')';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -136,6 +136,7 @@ class uicontacts extends bocontacts
|
|||||||
'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entrie
|
'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entrie
|
||||||
'start' => 0, // IO position in list
|
'start' => 0, // IO position in list
|
||||||
'cat_id' => 0, // IO category, if not 'no_cat' => True
|
'cat_id' => 0, // IO category, if not 'no_cat' => True
|
||||||
|
'options-cat_id' => array(lang('none')),
|
||||||
'search' => '', // IO search pattern
|
'search' => '', // IO search pattern
|
||||||
'order' => 'n_family', // IO name of the column to sort after (optional for the sortheaders)
|
'order' => 'n_family', // IO name of the column to sort after (optional for the sortheaders)
|
||||||
'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC'
|
'sort' => 'ASC', // IO direction of the sort: 'ASC' or 'DESC'
|
||||||
@ -448,15 +449,13 @@ class uicontacts extends bocontacts
|
|||||||
$GLOBALS['egw']->preferences->save_repository(false,'user',false);
|
$GLOBALS['egw']->preferences->save_repository(false,'user',false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($query['col_filter']['cat_id'])) unset($query['col_filter']['cat_id']);
|
if ((string)$query['cat_id'] != '')
|
||||||
if ($query['cat_id'])
|
|
||||||
{
|
{
|
||||||
if (!is_object($GLOBALS['egw']->categories))
|
$query['col_filter']['cat_id'] = $query['cat_id'] ? $query['cat_id'] : null;
|
||||||
{
|
}
|
||||||
$GLOBALS['egw']->categories =& CreateObject('phpgwapi.categories');
|
else
|
||||||
}
|
{
|
||||||
$cats = $GLOBALS['egw']->categories->return_all_children((int)$query['cat_id']);
|
unset($query['col_filter']['cat_id']);
|
||||||
$query['col_filter']['cat_id'] = count($cats) > 1 ? $cats : $query['cat_id'];
|
|
||||||
}
|
}
|
||||||
if ($query['filter'] !== '') // not all addressbooks
|
if ($query['filter'] !== '') // not all addressbooks
|
||||||
{
|
{
|
||||||
@ -651,6 +650,10 @@ class uicontacts extends bocontacts
|
|||||||
}
|
}
|
||||||
if ($query['cat_id'])
|
if ($query['cat_id'])
|
||||||
{
|
{
|
||||||
|
if (!is_object($GLOBALS['egw']->categories))
|
||||||
|
{
|
||||||
|
$GLOBALS['egw']->categories =& CreateObject('phpgwapi.categories');
|
||||||
|
}
|
||||||
$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang('Category').' '.$GLOBALS['egw']->categories->id2name($query['cat_id']);
|
$GLOBALS['egw_info']['flags']['app_header'] .= ': '.lang('Category').' '.$GLOBALS['egw']->categories->id2name($query['cat_id']);
|
||||||
}
|
}
|
||||||
if ($query['searchletter'])
|
if ($query['searchletter'])
|
||||||
|
Loading…
Reference in New Issue
Block a user