From: Meik S. <acy...@ph...> - 2009-07-22 09:07:57
|
Author: acydburn Date: Wed Jul 22 09:07:24 2009 New Revision: 9823 Log: Parse email text files with the template engine. Did not check if this influences styles template cache list/purge/etc. Modified: branches/phpBB-3_0_0/phpBB/docs/CHANGELOG.html branches/phpBB-3_0_0/phpBB/includes/functions_messenger.php Modified: branches/phpBB-3_0_0/phpBB/docs/CHANGELOG.html ============================================================================== *** branches/phpBB-3_0_0/phpBB/docs/CHANGELOG.html (original) --- branches/phpBB-3_0_0/phpBB/docs/CHANGELOG.html Wed Jul 22 09:07:24 2009 *************** *** 219,224 **** --- 219,225 ---- <li>[Feature] Ability to empty a user's outbox from the user ACP quick tools.</li> <li>[Feature] Ability to filter ACP / MCP logs</li> <li>[Feature] Users can report PMs to moderators which are then visible in a new MCP module</li> + <li>[Feature] Parse email text files with the template engine.</li> </ul> <a name="v304"></a><h3>1.ii. Changes since 3.0.4</h3> Modified: branches/phpBB-3_0_0/phpBB/includes/functions_messenger.php ============================================================================== *** branches/phpBB-3_0_0/phpBB/includes/functions_messenger.php (original) --- branches/phpBB-3_0_0/phpBB/includes/functions_messenger.php Wed Jul 22 09:07:24 2009 *************** *** 27,32 **** --- 27,34 ---- var $mail_priority = MAIL_NORMAL_PRIORITY; var $use_queue = true; + + var $tpl_obj = NULL; var $tpl_msg = array(); var $eol = "\n"; *************** *** 177,183 **** if (!trim($template_file)) { ! trigger_error('No template file set', E_USER_ERROR); } if (!trim($template_lang)) --- 179,185 ---- if (!trim($template_file)) { ! trigger_error('No template file for emailing set.', E_USER_ERROR); } if (!trim($template_lang)) *************** *** 185,209 **** $template_lang = basename($config['default_lang']); } ! if (empty($this->tpl_msg[$template_lang . $template_file])) { ! $tpl_file = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; ! $tpl_file .= $template_lang . "/email/$template_file.txt"; ! if (!file_exists($tpl_file)) ! { ! trigger_error("Could not find email template file [ $tpl_file ]", E_USER_ERROR); ! } ! if (($data = @file_get_contents($tpl_file)) === false) ! { ! trigger_error("Failed opening template file [ $tpl_file ]", E_USER_ERROR); ! } ! $this->tpl_msg[$template_lang . $template_file] = $data; } ! $this->msg = $this->tpl_msg[$template_lang . $template_file]; return true; } --- 187,211 ---- $template_lang = basename($config['default_lang']); } ! // tpl_msg now holds a template object we can use to parse the template file ! if (!isset($this->tpl_msg[$template_lang . $template_file])) { ! $this->tpl_msg[$template_lang . $template_file] = new template(); ! $tpl = &$this->tpl_msg[$template_lang . $template_file]; ! $template_path = (!empty($user->lang_path)) ? $user->lang_path : $phpbb_root_path . 'language/'; ! $template_path .= $template_lang . '/email'; ! $tpl->set_custom_template($template_path, $template_lang . '_email'); ! $tpl->set_filenames(array( ! 'body' => $template_file . '.txt', ! )); } ! $this->tpl_obj = &$this->tpl_msg[$template_lang . $template_file]; ! $this->vars = &$this->tpl_obj->_rootref; ! $this->tpl_msg = ''; return true; } *************** *** 213,219 **** */ function assign_vars($vars) { ! $this->vars = (empty($this->vars)) ? $vars : $this->vars + $vars; } /** --- 215,236 ---- */ function assign_vars($vars) { ! if (!is_object($this->tpl_obj)) ! { ! return; ! } ! ! $this->tpl_obj->assign_vars($vars); ! } ! ! function assign_block_vars($blockname, $vars) ! { ! if (!is_object($this->tpl_obj)) ! { ! return; ! } ! ! $this->tpl_obj->assign_block_vars($blockname, $vars); } /** *************** *** 224,238 **** global $config, $user; // We add some standard variables we always use, no need to specify them always ! $this->vars['U_BOARD'] = (!isset($this->vars['U_BOARD'])) ? generate_board_url() : $this->vars['U_BOARD']; ! $this->vars['EMAIL_SIG'] = (!isset($this->vars['EMAIL_SIG'])) ? str_replace('<br />', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])) : $this->vars['EMAIL_SIG']; ! $this->vars['SITENAME'] = (!isset($this->vars['SITENAME'])) ? htmlspecialchars_decode($config['sitename']) : $this->vars['SITENAME']; ! // Escape all quotes, else the eval will fail. ! $this->msg = str_replace ("'", "\'", $this->msg); ! $this->msg = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "' . ((isset(\$this->vars['\\1'])) ? \$this->vars['\\1'] : '') . '", $this->msg); ! eval("\$this->msg = '$this->msg';"); // We now try and pull a subject from the email body ... if it exists, // do this here because the subject may contain a variable --- 241,269 ---- global $config, $user; // We add some standard variables we always use, no need to specify them always ! if (!isset($this->vars['U_BOARD'])) ! { ! $this->assign_vars(array( ! 'U_BOARD' => generate_board_url(), ! )); ! } ! if (!isset($this->vars['EMAIL_SIG'])) ! { ! $this->assign_vars(array( ! 'EMAIL_SIG' => str_replace('<br />', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), ! )); ! } ! if (!isset($this->vars['SITENAME'])) ! { ! $this->assign_vars(array( ! 'SITENAME' => htmlspecialchars_decode($config['sitename']), ! )); ! } ! ! // Parse message through template ! $this->msg = trim($this->tpl_obj->assign_display('body')); // We now try and pull a subject from the email body ... if it exists, // do this here because the subject may contain a variable |