diff --git a/addressbook/inc/class.addressbook_ui.inc.php b/addressbook/inc/class.addressbook_ui.inc.php index 8ba71d64fd..1d1dc4fa6d 100644 --- a/addressbook/inc/class.addressbook_ui.inc.php +++ b/addressbook/inc/class.addressbook_ui.inc.php @@ -2153,7 +2153,11 @@ window.egw_LAB.wait(function() { $content['jpegphoto'] = !empty($content['jpegphoto']); // unused and messes up json encoding (not utf-8) $this->tmpl->setElementAttribute('tabs', 'add_tabs', true); $tabs =& $this->tmpl->getElementAttribute('tabs', 'tabs'); - if (true) $tabs = array(); + if (($first_call = !isset($tabs))) + { + $tabs = array(); + } + //error_log(__LINE__.': '.__METHOD__."() first_call=$first_call"); $hook_data = $GLOBALS['egw']->hooks->process(array('location' => 'addressbook_edit')+$content); //error_log(__METHOD__."() hook_data=".array2string($hook_data)); foreach($hook_data as $extra_tabs) @@ -2162,12 +2166,6 @@ window.egw_LAB.wait(function() { foreach(isset($extra_tabs[0]) ? $extra_tabs : array($extra_tabs) as $extra_tab) { - $tabs[] = array( - 'label' => $extra_tab['label'], - 'template' => $extra_tab['name'], - 'prepend' => $extra_tab['prepend'], - ); - //error_log(__METHOD__."() changed tabs=".array2string($tabs)); if ($extra_tab['data'] && is_array($extra_tab['data'])) { $content = array_merge($content, $extra_tab['data']); @@ -2180,6 +2178,9 @@ window.egw_LAB.wait(function() { { $readonlys = array_merge($readonlys, $extra_tab['readonlys']); } + // we must NOT add tabs and callbacks more then once! + if (!$first_call) continue; + if (!empty($extra_tab['pre_save_callback'])) { $preserve['pre_save_callbacks'][] = $extra_tab['pre_save_callback']; @@ -2188,6 +2189,15 @@ window.egw_LAB.wait(function() { { $preserve['post_save_callbacks'][] = $extra_tab['post_save_callback']; } + if (!empty($extra_tab['label']) && !empty($extra_tab['name'])) + { + $tabs[] = array( + 'label' => $extra_tab['label'], + 'template' => $extra_tab['name'], + 'prepend' => $extra_tab['prepend'], + ); + } + //error_log(__METHOD__."() changed tabs=".array2string($tabs)); } } return $this->tmpl->exec('addressbook.addressbook_ui.edit', $content, $sel_options, $readonlys, $preserve, 2); diff --git a/etemplate/inc/class.etemplate_widget_tabbox.inc.php b/etemplate/inc/class.etemplate_widget_tabbox.inc.php index b5a2448b0f..dbe868c975 100644 --- a/etemplate/inc/class.etemplate_widget_tabbox.inc.php +++ b/etemplate/inc/class.etemplate_widget_tabbox.inc.php @@ -41,8 +41,10 @@ class etemplate_widget_tabbox extends etemplate_widget { // Make sure additional tabs are processed for any method - if($this->attrs['tabs']) + if($this->attrs['tabs'] && !$this->tabs_attr_evaluated) { + $this->tabs_attr_evaluated = true; // we must not evaluate tabs attribte more then once! + // add_tabs toggles replacing or adding to existing tabs if(!$this->attrs['add_tabs']) { @@ -95,7 +97,7 @@ class etemplate_widget_tabbox extends etemplate_widget { $value = self::get_array($content, $form_name); $valid =& self::get_array($validated, $form_name, true); - if (true) $valid = $value; + if (true) $valid = $value; } } }