From: <ral...@us...> - 2013-06-12 14:13:06
|
Author: ralfbecker Date: Wed Jun 12 16:12:58 2013 New Revision: 42752 URL: http://svn.stylite.de/viewvc/egroupware?rev=42752&view=rev Log: fixed not working multiple value "select-account" or "home-accounts" (rows > 1) custom fields Modified: trunk/addressbook/inc/class.addressbook_sql.inc.php trunk/etemplate/inc/class.so_sql_cf.inc.php trunk/infolog/inc/class.infolog_so.inc.php Modified: trunk/addressbook/inc/class.addressbook_sql.inc.php URL: http://svn.stylite.de/viewvc/egroupware/trunk/addressbook/inc/class.addressbook_sql.inc.php?rev=42752&r1=42751&r2=42752&view=diff ============================================================================== --- trunk/addressbook/inc/class.addressbook_sql.inc.php (original) +++ trunk/addressbook/inc/class.addressbook_sql.inc.php Wed Jun 12 16:12:58 2013 @@ -1,11 +1,11 @@ <?php /** - * Addressbook - SQL backend + * EGroupware : Addressbook - SQL backend * * @link http://www.egroupware.org * @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @package addressbook - * @copyright (c) 2006-12 by Ralf Becker <RalfBecker-AT-outdoor-training.de> + * @copyright (c) 2006-13 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @version $Id$ */ @@ -816,31 +816,7 @@ */ function save_customfields($data) { - foreach ((array)$this->customfields as $name => $options) - { - if (!isset($data[$field = $this->get_cf_field($name)])) continue; - - $where = array( - $this->extra_id => $data['id'], - $this->extra_key => $name, - ); - $is_multiple = $this->is_multiple($name); - - // we explicitly need to delete fields, if value is empty or field allows multiple values or we have no unique index - if(empty($data[$field]) || $is_multiple || !$this->extra_has_unique_index) - { - $this->db->delete($this->extra_table,$where,__LINE__,__FILE__,$this->app); - if (empty($data[$field])) continue; // nothing else to do for empty values - } - foreach($is_multiple && !is_array($data[$field]) ? explode(',',$data[$field]) : (array)$data[$field] as $value) - { - if (!$this->db->insert($this->extra_table,array($this->extra_value => $value, 'contact_owner' => $data['owner']),$where,__LINE__,__FILE__,$this->app)) - { - return $this->db->Errno; - } - } - } - return false; // no error + return parent::save_customfields($data, array('contact_owner' => $data['owner'])); } /** Modified: trunk/etemplate/inc/class.so_sql_cf.inc.php URL: http://svn.stylite.de/viewvc/egroupware/trunk/etemplate/inc/class.so_sql_cf.inc.php?rev=42752&r1=42751&r2=42752&view=diff ============================================================================== --- trunk/etemplate/inc/class.so_sql_cf.inc.php (original) +++ trunk/etemplate/inc/class.so_sql_cf.inc.php Wed Jun 12 16:12:58 2013 @@ -1,12 +1,12 @@ <?php /** - * eGroupWare generalized SQL Storage Object with build in custom field support + * EGroupware generalized SQL Storage Object with build in custom field support * * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @package etemplate * @link http://www.egroupware.org * @author Ralf Becker <Ral...@ou...> - * @copyright 2009 by Ral...@ou... + * @copyright 2009-13 by Ral...@ou... * @version $Id$ */ @@ -206,16 +206,17 @@ * saves custom field data * * @param array $data data to save (cf's have to be prefixed with self::CF_PREFIX = #) + * @param array $extra_cols=array() * @return bool false on success, errornumber on failure */ - function save_customfields($data) + function save_customfields($data, array $extra_cols=array()) { foreach ((array)$this->customfields as $name => $options) { if (!isset($data[$field = $this->get_cf_field($name)])) continue; $where = array( - $this->extra_id => $data[$this->autoinc_id], + $this->extra_id => isset($data[$this->autoinc_id]) ? $data[$this->autoinc_id] : $data[$this->db_key_cols[$this->autoinc_id]], $this->extra_key => $name, ); $is_multiple = $this->is_multiple($name); @@ -226,9 +227,11 @@ $this->db->delete($this->extra_table,$where,__LINE__,__FILE__,$this->app); if (empty($data[$field])) continue; // nothing else to do for empty values } - foreach($is_multiple && !is_array($data[$field]) ? explode(',',$data[$field]) : (array)$data[$field] as $value) - { - if (!$this->db->insert($this->extra_table,array($this->extra_value => $value),$where,__LINE__,__FILE__,$this->app)) + foreach($is_multiple && !is_array($data[$field]) ? explode(',',$data[$field]) : + // regular custom fields (!$is_multiple) eg. addressbook store multiple values comma-separated + (array)(!$is_multiple && is_array($data[$field]) ? implode(',', $data[$field]) : $data[$field]) as $value) + { + if (!$this->db->insert($this->extra_table,array($this->extra_value => $value)+$extra_cols,$where,__LINE__,__FILE__,$this->app)) { return $this->db->Errno; } @@ -590,11 +593,11 @@ elseif(is_int($name) && $this->is_cf($val)) // lettersearch: #cfname LIKE 's%' { $_cf = explode(' ',$val); - foreach($_cf as $ci => $cf_np) + foreach($_cf as $ci => $cf_np) { // building cf_name by glueing parts together (, in case someone used whitespace in their custom field names) $tcf_name = ($tcf_name?$tcf_name.' ':'').$cf_np; - // reacts on the first one found that matches an existing customfield, should be better then the old behavior of + // reacts on the first one found that matches an existing customfield, should be better then the old behavior of // simply splitting by " " and using the first part if ($this->is_cf($tcf_name) && ($cfn = $this->get_cf_name($tcf_name)) && array_search($cfn,(array)$_cfnames,true)!==false ) { Modified: trunk/infolog/inc/class.infolog_so.inc.php URL: http://svn.stylite.de/viewvc/egroupware/trunk/infolog/inc/class.infolog_so.inc.php?rev=42752&r1=42751&r2=42752&view=diff ============================================================================== --- trunk/infolog/inc/class.infolog_so.inc.php (original) +++ trunk/infolog/inc/class.infolog_so.inc.php Wed Jun 12 16:12:58 2013 @@ -5,7 +5,7 @@ * @link http://www.egroupware.org * @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @package infolog - * @copyright (c) 2003-11 by Ralf Becker <RalfBecker-AT-outdoor-training.de> + * @copyright (c) 2003-13 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @version $Id$ */ @@ -599,7 +599,8 @@ if ($val) { $this->db->insert($this->extra_table,array( - 'info_extra_value' => is_array($val) ? serialize($val) : $val, + // store multivalued CalDAV properties as serialized array, everything else get comma-separated + 'info_extra_value' => is_array($val) ? ($key[1] == '#' ? serialize($val) : implode(',',$val)) : $val, ),array( 'info_id' => $info_id, 'info_extra_name' => substr($key,1), |