diff --git a/addressbook/inc/class.addressbook_bo.inc.php b/addressbook/inc/class.addressbook_bo.inc.php index 8fb89f8104..e38b5effcf 100755 --- a/addressbook/inc/class.addressbook_bo.inc.php +++ b/addressbook/inc/class.addressbook_bo.inc.php @@ -66,6 +66,7 @@ class addressbook_bo extends addressbook_so 'adr_one_region', 'adr_one_postalcode', 'adr_one_countryname', + 'adr_one_countrycode', 'label', 'tel_work', 'tel_fax', @@ -291,6 +292,17 @@ class addressbook_bo extends addressbook_so if ($GLOBALS['egw_info']['server']['org_fileds_to_update']) { $this->org_fields = unserialize($GLOBALS['egw_info']['server']['org_fileds_to_update']); + + // Set country code if country name is selected + $supported_fields = $this->get_fields('supported',null,0); + if(in_array('adr_one_countrycode', $supported_fields) && in_array('adr_one_countryname',$this->org_fields)) + { + $this->org_fields[] = 'adr_one_countrycode'; + } + if(in_array('adr_two_countrycode', $supported_fields) && in_array('adr_two_countryname',$this->org_fields)) + { + $this->org_fields[] = 'adr_two_countrycode'; + } } $this->categories = new categories($this->user,'addressbook'); diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index 7cc276b286..eb51edfc8a 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -95,6 +95,17 @@ class addressbook_ui extends addressbook_bo } if ($this->config['copy_fields'] && ($fields = unserialize($this->config['copy_fields']))) { + // Set country code if country name is selected + $supported_fields = $this->get_fields('supported',null,0); + if(in_array('adr_one_countrycode', $supported_fields) && in_array('adr_one_countryname',$fields)) + { + $fields[] = 'adr_one_countrycode'; + } + if(in_array('adr_two_countrycode', $supported_fields) && in_array('adr_two_countryname',$fields)) + { + $fields[] = 'adr_two_countrycode'; + } + self::$copy_fields = $fields; } } diff --git a/addressbook/inc/hook_config.inc.php b/addressbook/inc/hook_config.inc.php index d97bfe951b..78ddf2803b 100644 --- a/addressbook/inc/hook_config.inc.php +++ b/addressbook/inc/hook_config.inc.php @@ -107,6 +107,13 @@ function org_fileds_to_update($config) $fields['#'.$name] = $data['label']; } } + + // Remove country codes as an option, it will be added by BO constructor + if(in_array('adr_one_countrycode', $supported_fields)) + { + unset($fields['adr_one_countrycode']); + unset($fields['adr_two_countrycode']); + } return html::checkbox_multiselect('newsettings[org_fileds_to_update]', $config['org_fileds_to_update'] ? $config['org_fileds_to_update'] : $bocontacts->org_fields,$fields,true,'',4); } @@ -138,6 +145,12 @@ function copy_fields($config) $fields['#'.$name] = $data['label']; } } + // Remove country codes as an option, it will be added by UI constructor + if(in_array('adr_one_countrycode', $supported_fields)) + { + unset($fields['adr_one_countrycode']); + unset($fields['adr_two_countrycode']); + } return html::checkbox_multiselect('newsettings[copy_fields]', $config['copy_fields'] ? $config['copy_fields'] : addressbook_ui::$copy_fields,