From 8bb226ba6b08512bd2bb5180587b25e04cee32e6 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 3 Mar 2014 11:49:41 +0000 Subject: [PATCH] explicitly set custom fields as to search, if custom fields are defined, also added a couple more columns for explicitly not to search --- addressbook/inc/class.addressbook_so.inc.php | 16 +++++++++++----- addressbook/inc/class.addressbook_sql.inc.php | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/addressbook/inc/class.addressbook_so.inc.php b/addressbook/inc/class.addressbook_so.inc.php index 9bda483a4b..b126d4b889 100755 --- a/addressbook/inc/class.addressbook_so.inc.php +++ b/addressbook/inc/class.addressbook_so.inc.php @@ -120,7 +120,8 @@ class addressbook_so var $sql_cols_not_to_search = array( 'jpegphoto','owner','tid','private','cat_id','etag', 'modified','modifier','creator','created','tz','account_id', - 'uid', + 'uid','carddav_name','freebusy_uri','calendar_uri', + 'geo','pubkey', ); /** * columns to search, if we search for a single pattern @@ -193,7 +194,6 @@ class addressbook_so */ var $soextra; var $sodistrib_list; - var $backend; /** * Constructor @@ -217,6 +217,7 @@ class addressbook_so { $this->account_repository = $GLOBALS['egw_info']['server']['auth_type']; } + $this->customfields = config::get_customfields('addressbook'); // contacts backend (contacts in LDAP require accounts in LDAP!) if($GLOBALS['egw_info']['server']['contact_repository'] == 'ldap' && $this->account_repository == 'ldap') { @@ -234,6 +235,10 @@ class addressbook_so // remove some columns, absolutly not necessary to search in sql $this->columns_to_search = array_diff(array_values($this->somain->db_cols),$this->sql_cols_not_to_search); + if ($this->customfields) // add custom fields, if configured + { + $this->columns_to_search[] = addressbook_sql::EXTRA_TABLE.'.'.addressbook_sql::EXTRA_VALUE; + } } if ($this->user) { @@ -276,7 +281,6 @@ class addressbook_so $this->soextra = new addressbook_sql($db); } - $this->customfields = config::get_customfields('addressbook'); $this->content_types = config::get_content_types('addressbook'); if (!$this->content_types) { @@ -642,7 +646,9 @@ class addressbook_so foreach($cols as $key => &$col) { - if(!array_key_exists($col, $backend->db_cols)) + if($col != addressbook_sql::EXTRA_VALUE && + $col != addressbook_sql::EXTRA_TABLE.'.'.addressbook_sql::EXTRA_VALUE && + !array_key_exists($col, $backend->db_cols)) { if(!($col = array_search($col, $backend->db_cols))) { @@ -817,7 +823,7 @@ class addressbook_so * * @param array|string|int $keys=null * @param int $owner=null account_id of owner or 0 for accounts - * @return object + * @return addressbook_sql */ function get_backend($keys=null,$owner=null) { diff --git a/addressbook/inc/class.addressbook_sql.inc.php b/addressbook/inc/class.addressbook_sql.inc.php index 183408e535..2a8490fd49 100644 --- a/addressbook/inc/class.addressbook_sql.inc.php +++ b/addressbook/inc/class.addressbook_sql.inc.php @@ -55,6 +55,7 @@ class addressbook_sql extends so_sql_cf var $ab2list_table = 'egw_addressbook2list'; const EXTRA_TABLE = 'egw_addressbook_extra'; + const EXTRA_VALUE = 'contact_value'; /** * Constructor