diff --git a/addressbook/inc/class.socontacts.inc.php b/addressbook/inc/class.socontacts.inc.php index f2e68fba02..0ada04a487 100755 --- a/addressbook/inc/class.socontacts.inc.php +++ b/addressbook/inc/class.socontacts.inc.php @@ -496,7 +496,7 @@ class socontacts * * '*' and '?' are replaced with sql-wildcards '%' and '_' * - * @param array/string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!) + * @param array/string $criteria array of key and data cols, OR string to search over all standard search fields * @param boolean/string $only_keys=true True returns only keys, False returns all cols. comma seperated list of keys to return * @param string $order_by='' fieldnames + {ASC|DESC} separated by colons ',', can also contain a GROUP BY (if it contains ORDER BY) * @param string/array $extra_cols='' string or array of strings to be added to the SELECT, eg. "count(*) as num" @@ -505,15 +505,29 @@ class socontacts * @param string $op='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together * @param mixed $start=false if != false, return only maxmatch rows begining with start, or array($start,$num) * @param array $filter=null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards - * @param string $join='' sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or - * "LEFT JOIN table2 ON (x=y)", Note: there's no quoting done on $join! - * @param boolean $need_full_no_count=false If true an unlimited query is run to determine the total number of rows, default false * @return array of matching rows (the row is an array of the cols) or False */ - function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null,$join='',$need_full_no_count=false) + function &search($criteria,$only_keys=True,$order_by='',$extra_cols='',$wildcard='',$empty=False,$op='AND',$start=false,$filter=null) { //echo "

socontacts::search(".print_r($criteria,true).",'$only_keys','$order_by','$extra_cols','$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')

\n"; + // single string to search for --> create so_sql conformant search criterial for the standard search columns + if ($criteria && !is_array($criteria)) + { + $op = 'OR'; + $wildcard = '%'; + $search = $criteria; + $criteria = array(); + $cols = $this->columns_to_search; + if (!$filter['owner']) // extra columns for search if accounts are included, eg. account_lid + { + $cols = array_merge($cols,$this->account_extra_search); + } + foreach($cols as $col) + { + $criteria[$col] = $search; + } + } if (is_array($criteria) && count($criteria)) { $criteria = $this->data2db($criteria); diff --git a/addressbook/inc/class.uicontacts.inc.php b/addressbook/inc/class.uicontacts.inc.php index 44081a75b7..20f0804e7c 100644 --- a/addressbook/inc/class.uicontacts.inc.php +++ b/addressbook/inc/class.uicontacts.inc.php @@ -308,19 +308,6 @@ class uicontacts extends bocontacts $order = 'n_fileas '.$sort; break; } - $criteria = array(); - if ($query['search']) - { - $cols = $this->columns_to_search; - if (!$query['filter']) // extra columns for search if accounts are included, eg. account_lid - { - $cols = array_merge($cols,$this->account_extra_search); - } - foreach($cols as $col) - { - $criteria[$col] = $query['search']; - } - } if ($query['searchletter']) // only show contacts which ordercriteria starts with the given letter { $query['col_filter'][] = $query['order'].' LIKE '.$GLOBALS['egw']->db->quote($query['searchletter'].'%'); @@ -329,7 +316,7 @@ class uicontacts extends bocontacts { $query['col_filter'][] = $query['order']."!=''"; } - $rows = (array) parent::search($criteria,$id_only,$order,'','%',false,'OR',array((int)$query['start'],(int) $query['num_rows']),$query['col_filter']); + $rows = (array) parent::search($query['search'],$id_only,$order,'','%',false,'OR',array((int)$query['start'],(int) $query['num_rows']),$query['col_filter']); //echo "

".$this->somain->db->Query_ID->sql."

\n"; if ($id_only) return $this->total; // no need to set other fields or $readonlys