From a41761660e88b6116568ee816cba301a9d751a08 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Thu, 3 Nov 2005 14:30:40 +0000 Subject: [PATCH] fixed bug: addressbook popup for email apps: adding all search results was not working with ldap (contacts_ldap class did not support the "!''" filter used) --- phpgwapi/inc/class.contacts_ldap.inc.php | 41 ++++++++++++------------ 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/phpgwapi/inc/class.contacts_ldap.inc.php b/phpgwapi/inc/class.contacts_ldap.inc.php index 400120314f..75ed5b4a7e 100644 --- a/phpgwapi/inc/class.contacts_ldap.inc.php +++ b/phpgwapi/inc/class.contacts_ldap.inc.php @@ -336,28 +336,24 @@ if($filter) { if($DEBUG) { echo 'DEBUG - Inbound filter is: #'.$filter.'#'; } - $filterarray = split(',',$filter); - if($filterarray[1]) + + foreach(explode(',',$filter) as $f) { - $i=0; - for($i=0;$istock_contact_fields[$name]) { - list($name,$value) = split("=",$filterarray[$i]); - if($name) - { - if($DEBUG) { echo '
DEBUG - Filter strings: #'.$this->non_contact_fields[$name].'# => #'.$value.'#'; } - $filterfields[$this->non_contact_fields[$name]] = $value; - } + $filterfields[$this->stock_contact_fields[$name]] = $value; } - } - else - { - list($name,$value) = split('=',$filter); - if($DEBUG) + elseif ($this->non_contact_fields[$name]) { - echo '
DEBUG - Filter strings: #'.$this->non_contact_fields[$name].'# => #'.$value.'#'; + $filterfields[$this->non_contact_fields[$name]] = $value; + } + else + + { + if ($DEBUG) echo "

contacts_ldap::read(filter=$filter): Cant filter for '$name', allowed only: ".implode(', ',array_keys($this->non_contact_fields))."

\n"; } - $filterfields = array($this->non_contact_fields[$name] => $value); } } else @@ -544,6 +540,8 @@ /* Used by read() above to build the ldap filter string */ function makefilter($qarray,$extra='',$query='', $DEBUG=False) { + if($DEBUG) echo "

contacts_ldap::makefilter(".print_r($qarray,true).",'$extra','$query')

\n"; + if(!@is_array($qarray)) { return $qarray; @@ -623,7 +621,7 @@ { if (!is_object($GLOBALS['egw']->categories)) { - $GLOBALS['egw']->categories = CreateObject('phpgwapi.categories'); + $GLOBALS['egw']->categories =& CreateObject('phpgwapi.categories'); } $cats = $GLOBALS['egw']->categories->return_all_children((int)$value); @@ -634,6 +632,10 @@ } $aquery .= ')'; } + elseif ($value == "!''") // query for not empty + { + $aquery .= '(' . $name . '=*)'; + } else { $aquery .= '(' . $name . '=' . $value . ')'; @@ -670,10 +672,9 @@ echo '
AND query: "' . $aquery . '"'; echo '
OR query: "' . $oquery . '"'; echo '
Full query: "' . $fquery . '"'; - echo '
Will search in "' . $GLOBALS['egw_info']['server']['ldap_contact_context'] . '"'; + echo '
Will search in "' . $GLOBALS['egw_info']['server']['ldap_contact_context'] . '"'; } -// echo $fquery; return $fquery; }