diff --git a/addressbook/inc/class.so_ldap.inc.php b/addressbook/inc/class.so_ldap.inc.php index daa8fa803f..97dbe62d9d 100644 --- a/addressbook/inc/class.so_ldap.inc.php +++ b/addressbook/inc/class.so_ldap.inc.php @@ -644,9 +644,8 @@ class so_ldap } } $colFilter = $this->_colFilter($filter); - $ldapFilter = "(&$objectFilter$searchFilter$colFilter)"; - + if (!($rows = $this->_searchLDAP($searchDN, $ldapFilter, $this->all_attributes, $addressbookType))) { return $rows; @@ -703,7 +702,7 @@ class so_ldap $filters = ''; foreach($filter as $key => $value) { - if (!$value) continue; + if ($key != 'cat_id' && !$value) continue; switch((string) $key) { @@ -712,11 +711,25 @@ class so_ldap break; case 'cat_id': - if((int)$value) + if (is_null($value)) { - $catName = $GLOBALS['egw']->translation->convert( - ExecMethod('phpgwapi.categories.id2name',$value),$this->charset,'utf-8'); - $filters .= '(category='.ldap::quote($catName).')'; + $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( + $GLOBALS['egw']->categories->id2name($cat),$this->charset,'utf-8'); + $filters .= '(category='.ldap::quote($catName).')'; + } + if (count($cats) > 1) $filters .= ')'; } break; diff --git a/addressbook/inc/class.uicontacts.inc.php b/addressbook/inc/class.uicontacts.inc.php index 9d7c06c1ce..15afa8e42a 100644 --- a/addressbook/inc/class.uicontacts.inc.php +++ b/addressbook/inc/class.uicontacts.inc.php @@ -136,6 +136,7 @@ class uicontacts extends bocontacts 'never_hide' => True, // I never hide the nextmatch-line if less then maxmatch entrie 'start' => 0, // IO position in list 'cat_id' => 0, // IO category, if not 'no_cat' => True + 'options-cat_id' => array(lang('none')), 'search' => '', // IO search pattern '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' @@ -448,15 +449,13 @@ class uicontacts extends bocontacts $GLOBALS['egw']->preferences->save_repository(false,'user',false); } } - if (isset($query['col_filter']['cat_id'])) unset($query['col_filter']['cat_id']); - if ($query['cat_id']) + if ((string)$query['cat_id'] != '') { - if (!is_object($GLOBALS['egw']->categories)) - { - $GLOBALS['egw']->categories =& CreateObject('phpgwapi.categories'); - } - $cats = $GLOBALS['egw']->categories->return_all_children((int)$query['cat_id']); - $query['col_filter']['cat_id'] = count($cats) > 1 ? $cats : $query['cat_id']; + $query['col_filter']['cat_id'] = $query['cat_id'] ? $query['cat_id'] : null; + } + else + { + unset($query['col_filter']['cat_id']); } if ($query['filter'] !== '') // not all addressbooks { @@ -651,6 +650,10 @@ class uicontacts extends bocontacts } 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']); } if ($query['searchletter'])