Index: includes/functions_messenger.php =================================================================== --- includes/functions_messenger.php (Revision 10449) +++ includes/functions_messenger.php (Arbeitskopie) @@ -182,17 +182,8 @@ trigger_error('No template file for emailing set.', E_USER_ERROR); } - if (!$template_path) + if (!trim($template_lang)) { - $path_check = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; - } - else - { - $path_check = $template_path; - } - - if (!trim($template_lang) || !file_exists("$path_check$template_lang/email/$template_file.txt")) - { // fall back to board default language if the user's language is // missing $template_file. If this does not exist either, // $tpl->set_custom_template will do a trigger_error @@ -205,13 +196,23 @@ $this->tpl_msg[$template_lang . $template_file] = new template(); $tpl = &$this->tpl_msg[$template_lang . $template_file]; + $fallback_template_path = false; + if (!$template_path) { $template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; $template_path .= $template_lang . '/email'; + + // we can only specify default language fallback when the path is not a custom one for which we + // do not know the default language alternative + if ($template_lang !== basename($config['default_lang'])) + { + $fallback_template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; + $fallback_template_path .= basename($config['default_lang']) . '/email'; + } } - $tpl->set_custom_template($template_path, $template_lang . '_email', 'email'); + $tpl->set_custom_template($template_path, $template_lang . '_email', $fallback_template_path); $tpl->set_filenames(array( 'body' => $template_file . '.txt', Index: includes/template.php =================================================================== --- includes/template.php (Revision 10449) +++ includes/template.php (Arbeitskopie) @@ -90,7 +90,7 @@ * Set custom template location (able to use directory outside of phpBB) * @access public */ - function set_custom_template($template_path, $template_name, $template_mode = 'template') + function set_custom_template($template_path, $template_name, $fallback_template_path = false) { global $phpbb_root_path, $user; @@ -103,13 +103,25 @@ $this->root = $template_path; $this->cachepath = $phpbb_root_path . 'cache/ctpl_' . str_replace('_', '-', $template_name) . '_'; - // As the template-engine is used for more than the template (emails, etc.), we should not set $user->theme in all cases, but only on the real template. - if ($template_mode == 'template') + if ($fallback_template_path !== false) { - $user->theme['template_storedb'] = false; - $user->theme['template_inherits_id'] = false; + if (substr($fallback_template_path, -1) == '/') + { + $fallback_template_path = substr($fallback_template_path, 0, -1); + } + + $this->inherit_root = $fallback_template_path; + $this->orig_tpl_inherits_id = true; } + else + { + $this->orig_tpl_inherits_id = false; + } + // the database does not store the path or name of a custom template + // so there is no way we can properly store custom templates tehre + $this->orig_tpl_storedb = false; + $this->_rootref = &$this->_tpldata['.'][0]; return true; @@ -254,6 +266,12 @@ trigger_error("template->_tpl_load(): No file specified for handle $handle", E_USER_ERROR); } + // reload these settings to have the values they had when this object was initialised + // using set_template or set_custom_template, they might otherwise have been overwritten + // by other template class instances in between. + $user->theme['template_storedb'] = $this->orig_tpl_storedb; + $user->theme['template_inherits_id'] = $this->orig_tpl_inherits_id; + $filename = $this->cachepath . str_replace('/', '.', $this->filename[$handle]) . '.' . $phpEx; $this->files_template[$handle] = (isset($user->theme['template_id'])) ? $user->theme['template_id'] : 0; Index: docs/CHANGELOG.html =================================================================== --- docs/CHANGELOG.html (Revision 10449) +++ docs/CHANGELOG.html (Arbeitskopie) @@ -149,6 +149,7 @@
  • [Fix] Fall back to default language email template if specified file does not exist. (Bug #35595)
  • [Fix] Update users last visit field correctly when changing activation status. (Bug #56185)
  • [Fix] Database updater now separates ADD COLUMN from SET NOT NULL and SET DEFAULT, when using PostgreSQL <= 7.4 (Bug #54435)
  • +
  • [Fix] Do not store email templates in database. (Bug #54505)
  • [Change] Move redirect into a hidden field to avoid issues with mod_security. (Bug #54145)
  • [Change] Log activation through inactive users ACP. (Bug #30145)
  • [Change] Send time of last item instead of current time in ATOM Feeds. (Bug #53305)