Ignore:
Timestamp:
Mar 13, 2008, 2:43:45 AM (16 years ago)
Author:
rvelices
Message:
  • changes to template to accomodate nbm (solved issue when we had same template filename with different root dirs)
  • started some changes in mail templates
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_mail.inc.php

    r2262 r2278  
    171171 *       o theme: template to use [default get_default_template()]
    172172 */
    173 function get_mail_template($email_format, $args = array())
     173function & get_mail_template($email_format, $args = array())
    174174{
    175175  $args = get_array_template_theme($args);
    176176
    177177  $mail_template = new Template(PHPWG_ROOT_PATH.'template/'.$args['template'], $args['theme']);
    178   $mail_template->_old->set_rootdir(PHPWG_ROOT_PATH.'template/'.$args['template'].'/mail/'.$email_format);
    179   $mail_template->smarty->template_dir = PHPWG_ROOT_PATH.'template/'.$args['template'].'/mail/'.$email_format;
    180  
     178  $mail_template->set_template_dir(PHPWG_ROOT_PATH.'template/'.$args['template'].'/mail/'.$email_format);
    181179  return $mail_template;
    182180}
     
    298296{
    299297  // Check arguments
    300   if 
     298  if
    301299    (
    302300      empty($keyargs_subject) or
     
    392390{
    393391  // Check arguments
    394   if 
     392  if
    395393    (
    396394      empty($group_id) or
     
    476474            (empty($dirname) ? '' : $dirname.'/').$tpl_shortname.'.tpl');
    477475
    478           $mail_template->assign_vars(
     476          $mail_template->assign(
    479477            trigger_event('mail_group_assign_vars', $assign_vars));
    480478
     
    630628    $mail_template->set_filename('mail_footer', 'footer.tpl');
    631629
    632     $mail_template->assign_vars(
     630    $mail_template->assign(
    633631      array(
    634632        //Header
     
    655653    if ($args['email_format'] == 'text/html')
    656654    {
    657       $old_root = $mail_template->root;
    658 
    659       if (is_file($mail_template->root.'/global-mail-css.tpl'))
     655      if (is_file($mail_template->get_template_dir().'/global-mail-css.tpl'))
    660656      {
    661         $mail_template->set_filename('global_mail_css', 'global-mail-css.tpl');
    662         $mail_template->assign_var_from_handle('GLOBAL_MAIL_CSS', 'global_mail_css');
     657        $mail_template->set_filename('css', 'global-mail-css.tpl');
     658        $mail_template->assign_var_from_handle('GLOBAL_MAIL_CSS', 'css');
    663659      }
    664660
    665       $mail_template->root = PHPWG_ROOT_PATH.'template/'.$args['template'].'/theme/'.$args['theme'];
    666       if (is_file($mail_template->root.'/mail-css.tpl'))
     661      $root_abs_path = dirname(dirname(__FILE__));
     662
     663      $file = $root_abs_path.'/template/'.$args['template'].'/theme/'.$args['theme'].'/mail-css.tpl';
     664      if (is_file($file))
    667665      {
    668         $mail_template->set_filename('mail_css', 'mail-css.tpl');
    669         $mail_template->assign_var_from_handle('MAIL_CSS', 'mail_css');
     666        $mail_template->set_filename('css', $file);
     667        $mail_template->assign_var_from_handle('MAIL_CSS', 'css');
    670668      }
    671669
    672       $mail_template->root = PHPWG_ROOT_PATH.'template-common';
    673       if (is_file($mail_template->root.'/local-mail-css.tpl'))
     670      $file = $root_abs_path.'/template-common/local-mail-css.tpl';
     671      if (is_file($file))
    674672      {
    675         $mail_template->set_filename('local_mail_css', 'local-mail-css.tpl');
    676         $mail_template->assign_var_from_handle('LOCAL_MAIL_CSS', 'local_mail_css');
     673        $mail_template->set_filename('css', $file);
     674        $mail_template->assign_var_from_handle('LOCAL_MAIL_CSS', 'css');
    677675      }
    678 
    679       $mail_template->root = $old_root;
    680676    }
    681677
     
    771767}
    772768
    773 /*Testing block
    774 function pwg_send_mail_test($result, $to, $subject, $content, $headers, $args)
    775 {
    776     global $user, $lang_info;
    777     @mkdir(PHPWG_ROOT_PATH.'testmail');
    778     $filename = PHPWG_ROOT_PATH.'testmail/mail.'.$user['username'].'.'.$lang_info['code'].'.'.$args['template'].'.'.$args['theme'];
     769/*Testing block*/
     770/*function pwg_send_mail_test($result, $to, $subject, $content, $headers, $args)
     771{
     772    global $conf, $user, $lang_info;
     773    $dir = $conf['local_data_dir'].'/tmp';
     774    @mkdir( $dir );
     775    $filename = $dir.'/mail.'.$user['username'].'.'.$lang_info['code'].'.'.$args['template'].'.'.$args['theme'];
    779776    if ($args['content_format'] == 'text/plain')
    780777    {
     
    786783    }
    787784    $file = fopen($filename, 'w+');
    788     fwrite($file, $to);
    789     fwrite($file, $subject);
     785    fwrite($file, $to ."\n");
     786    fwrite($file, $subject ."\n");
    790787    fwrite($file, $headers);
    791788    fwrite($file, $content);
    792789    fclose($file);
    793     return true;
    794 }
    795 add_event_handler('send_mail', 'pwg_send_mail_test', 0, 6);*/
     790    return $result;
     791}
     792add_event_handler('send_mail', 'pwg_send_mail_test', EVENT_HANDLER_PRIORITY_NEUTRAL+10, 6);*/
    796793
    797794
Note: See TracChangeset for help on using the changeset viewer.