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:
Ralf Becker 2006-10-02 07:49:00 +00:00
parent f4e79928f6
commit 816e11629a
2 changed files with 31 additions and 15 deletions

View File

@ -644,7 +644,6 @@ 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)))
@ -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,12 +711,26 @@ class so_ldap
break; break;
case 'cat_id': case 'cat_id':
if((int)$value) if (is_null($value))
{
$filters .= '(!(category=*))';
}
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( $catName = $GLOBALS['egw']->translation->convert(
ExecMethod('phpgwapi.categories.id2name',$value),$this->charset,'utf-8'); $GLOBALS['egw']->categories->id2name($cat),$this->charset,'utf-8');
$filters .= '(category='.ldap::quote($catName).')'; $filters .= '(category='.ldap::quote($catName).')';
} }
if (count($cats) > 1) $filters .= ')';
}
break; break;
default: default:

View File

@ -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');
} }
$cats = $GLOBALS['egw']->categories->return_all_children((int)$query['cat_id']); else
$query['col_filter']['cat_id'] = count($cats) > 1 ? $cats : $query['cat_id']; {
unset($query['col_filter']['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'])