mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 00:29:18 +01:00
Better dealing with 2 letter country code:
- Moved handling into BO layer, per Ralf - Clear country name if user saves with a code, and use the code - Updated search filter to use code, so filter works in any language
This commit is contained in:
parent
c4e46dc172
commit
b86490c0a7
@ -802,6 +802,24 @@ class addressbook_bo extends addressbook_so
|
||||
{
|
||||
$contact['cat_id'] = implode(',',$contact['cat_id']);
|
||||
}
|
||||
|
||||
// Update country codes
|
||||
if($contact['adr_one_countryname'] && $code = $GLOBALS['egw']->country->country_code($contact['adr_one_countryname']))
|
||||
{
|
||||
if(strlen($code) == 2)
|
||||
{
|
||||
$contact['adr_one_countrycode'] = $code;
|
||||
}
|
||||
else
|
||||
{
|
||||
$contact['adr_one_countrycode'] = null;
|
||||
}
|
||||
}
|
||||
if($contact['adr_one_countrycode'] != null)
|
||||
{
|
||||
$contact['adr_one_countryname'] = null;
|
||||
}
|
||||
|
||||
// last modified
|
||||
$contact['modifier'] = $this->user;
|
||||
$contact['modified'] = $this->now_su;
|
||||
@ -884,6 +902,14 @@ class addressbook_bo extends addressbook_so
|
||||
// determine the file-as type
|
||||
$data['fileas_type'] = $this->fileas_type($data);
|
||||
|
||||
// Update country name from code
|
||||
if($data['adr_one_countrycode'] != null) {
|
||||
$data['adr_one_countryname'] = $GLOBALS['egw']->country->get_full_name($data['adr_one_countrycode'], true);
|
||||
}
|
||||
if($data['adr_two_countrycode'] != null) {
|
||||
$data['adr_two_countryname'] = $GLOBALS['egw']->country->get_full_name($data['adr_two_countrycode'], true);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -563,12 +563,6 @@ class addressbook_so
|
||||
//echo "<p>socontacts::search(".print_r($criteria,true).",'$only_keys','$order_by','$extra_cols','$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')</p>\n";
|
||||
//error_log("socontacts::search(".print_r($criteria,true).",'$only_keys','$order_by','$extra_cols','$wildcard','$empty','$op','$start',".print_r($filter,true).",'$join')");
|
||||
|
||||
// the nextmatch custom-filter-header country-select returns a 2 letter country-code
|
||||
if (isset($filter['adr_one_countryname']) && strlen($filter['adr_one_countryname']) == 2)
|
||||
{
|
||||
$filter['adr_one_countryname'] = $GLOBALS['egw']->country->get_full_name($filter['adr_one_countryname']);
|
||||
}
|
||||
|
||||
// Hide deleted items unless type is specifically deleted
|
||||
if(!is_array($filter)) $filter = $filter ? (array) $filter : array();
|
||||
if($filter['tid'] !== self::DELETED_TYPE)
|
||||
|
@ -553,14 +553,6 @@ class addressbook_sql extends so_sql_cf
|
||||
}
|
||||
$contact = parent::read($keys,$extra_cols,$join);
|
||||
|
||||
// Translate country code
|
||||
if($contact['adr_one_countrycode'] != null) {
|
||||
$contact['adr_one_countryname'] = $GLOBALS['egw']->country->get_full_name($contact['adr_one_countrycode'], true);
|
||||
}
|
||||
if($contact['adr_two_countrycode'] != null) {
|
||||
$contact['adr_two_countryname'] = $GLOBALS['egw']->country->get_full_name($contact['adr_two_countrycode'], true);
|
||||
}
|
||||
|
||||
// Change autoinc_id to match $this->db_cols
|
||||
$this->autoinc_id = $this->db_cols[$this->autoinc_id];
|
||||
if(($id = (int)$this->data[$this->autoinc_id]) && $cfs = $this->read_customfields($keys)) {
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user