From 1125c3f52c947dc6e23d2b97c8222d919c23469c Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 9 Sep 2014 14:12:07 +0000 Subject: [PATCH] fixing the fix: now cat_id=1 got not lost with a 2nd default option set in addressbook (0=None) --- addressbook/inc/class.addressbook_ui.inc.php | 2 +- etemplate/inc/class.etemplate_widget_menupopup.inc.php | 8 ++++---- etemplate/inc/class.etemplate_widget_nextmatch.inc.php | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index 21550737a6..72fa84c5e3 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -244,7 +244,7 @@ class addressbook_ui extends addressbook_bo $content['nm'] = array_merge($content['nm'],$state); } } - $sel_options['cat_id'] = array(array('value' => '', 'label' => lang('all')), array('value' => 0, 'label'=>lang('None'))); + $sel_options['cat_id'] = array('' => lang('all'), '0' => lang('None')); // Delete list action depends on permissions if($this->get_lists(EGW_ACL_EDIT)) diff --git a/etemplate/inc/class.etemplate_widget_menupopup.inc.php b/etemplate/inc/class.etemplate_widget_menupopup.inc.php index e408e81b0f..6d8140d6ba 100644 --- a/etemplate/inc/class.etemplate_widget_menupopup.inc.php +++ b/etemplate/inc/class.etemplate_widget_menupopup.inc.php @@ -202,7 +202,7 @@ class etemplate_widget_menupopup extends etemplate_widget if($this->attrs['type'] == 'select-account' && !$GLOBALS['egw_info']['user']['apps']['admin'] && $select_pref == 'none') { self::$request->preserv[$this->id] = self::$request->content[$this->id]; - unset(self::$request->content[$this->id]); + unset(self::$request->content[$this->id]); $this->attrs['readonly'] = true; } @@ -256,12 +256,12 @@ class etemplate_widget_menupopup extends etemplate_widget // either uses the same ID in the template, or adds the options twice if(is_numeric($value) && (!is_array($label) || is_array($label) && !array_key_exists('value',$label))) { - $check_value = is_array($label) && array_key_exists('value', $label) ? $label['value'] : $value; - if($value == $check_value) + $check_value = (string)(is_array($label) && array_key_exists('value', $label) ? $label['value'] : $value); + if((string)$value === $check_value) { foreach($options as $key => $existing) { - if(is_array($existing) && $existing['value'] == $check_value && $key != $value) + if(is_array($existing) && isset($existing['value']) && (string)$existing['value'] === $check_value && $key != $value) { unset($options[$value]); continue 2; diff --git a/etemplate/inc/class.etemplate_widget_nextmatch.inc.php b/etemplate/inc/class.etemplate_widget_nextmatch.inc.php index 043841f3e2..6502195c61 100644 --- a/etemplate/inc/class.etemplate_widget_nextmatch.inc.php +++ b/etemplate/inc/class.etemplate_widget_nextmatch.inc.php @@ -188,8 +188,7 @@ class etemplate_widget_nextmatch extends etemplate_widget { $value['options-cat_id'][''] = lang('all'); } - $value['options-cat_id'] = array_merge($value['options-cat_id'], - etemplate_widget_menupopup::typeOptions('select-cat', ',,'.$cat_app,$no_lang,false,$value['cat_id'])); + $value['options-cat_id'] += etemplate_widget_menupopup::typeOptions('select-cat', ',,'.$cat_app,$no_lang,false,$value['cat_id']); etemplate_widget_menupopup::fix_encoded_options($value['options-cat_id']); }