Changeset 2129


Ignore:
Timestamp:
Oct 9, 2007, 11:35:31 PM (17 years ago)
Author:
rub
Message:

Fix some little bugs on mail functions

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        55phpmv2
        66map.php
         7upgrade65.log
  • trunk/include/functions_mail.inc.php

    r2126 r2129  
    411411      $list[] = $row;
    412412    }
    413   }
    414 
    415   foreach ($list as $elem)
    416   {
    417     $query = '
     413
     414    foreach ($list as $elem)
     415    {
     416      $query = '
    418417SELECT
    419418  u.'.$conf['user_fields']['username'].' as username,
     
    430429;';
    431430
    432     $result = pwg_query($query);
    433 
    434     if (mysql_num_rows($result) > 0)
    435     {
    436       $Bcc = array();
    437       while ($row = mysql_fetch_array($result))
     431      $result = pwg_query($query);
     432
     433      if (mysql_num_rows($result) > 0)
    438434      {
    439         if (!empty($row['mail_address']))
     435        $Bcc = array();
     436        while ($row = mysql_fetch_array($result))
    440437        {
    441           array_push($Bcc, format_email($row['username'], $row['mail_address']));
     438          if (!empty($row['mail_address']))
     439          {
     440            array_push($Bcc, format_email($row['username'], $row['mail_address']));
     441          }
    442442        }
    443       }
    444 
    445       if (count($Bcc) > 0)
    446       {
    447         switch_lang_to($elem['language']);
    448 
    449         $mail_template = get_mail_template($email_format, $elem);
    450         $mail_template->set_filename($tpl_shortname,
    451           (empty($dirname) ? '' : $dirname.'/').$tpl_shortname.'.tpl');
    452         $mail_template->assign_vars($assign_vars);
    453 
    454         $return = pwg_mail
    455         (
    456           '',
    457           array
     443
     444        if (count($Bcc) > 0)
     445        {
     446          switch_lang_to($elem['language']);
     447
     448          $mail_template = get_mail_template($email_format, $elem);
     449          $mail_template->set_filename($tpl_shortname,
     450            (empty($dirname) ? '' : $dirname.'/').$tpl_shortname.'.tpl');
     451          $mail_template->assign_vars($assign_vars);
     452
     453          $return = pwg_mail
    458454          (
    459             'Bcc' => $Bcc,
    460             'subject' => l10n_args($keyargs_subject),
    461             'email_format' => $email_format,
    462             'content' => $mail_template->parse($tpl_shortname, true),
    463             'content_format' => $email_format,
    464             'template' => $elem['template'],
    465             'theme' => $elem['theme']
    466           )
    467         ) and $return;
    468 
    469         switch_lang_back();
     455            '',
     456            array
     457            (
     458              'Bcc' => $Bcc,
     459              'subject' => l10n_args($keyargs_subject),
     460              'email_format' => $email_format,
     461              'content' => $mail_template->parse($tpl_shortname, true),
     462              'content_format' => $email_format,
     463              'template' => $elem['template'],
     464              'theme' => $elem['theme']
     465            )
     466          ) and $return;
     467
     468          switch_lang_back();
     469        }
    470470      }
    471471    }
     
    589589  $content = '';
    590590
    591   if (!isset($conf_mail[$args['email_format']][get_pwg_charset()][$args['template']][$args['theme']]))
     591  // key compose of indexes witch allow ti cache mail data
     592  $cache_key = $args['email_format'].'-'.$lang_info['code'].'-'.$args['template'].'-'.$args['theme'];
     593
     594  if (!isset($conf_mail[$cache_key]))
    592595  {
    593596    if (!isset($mail_template))
     
    650653
    651654    // what are displayed on the header of each mail ?
    652     $conf_mail[$args['email_format']]
    653       [get_pwg_charset()]
    654       [$args['template']][$args['theme']]['header'] =
    655         $mail_template->parse('mail_header', true);
     655    $conf_mail[$cache_key]['header'] =
     656      $mail_template->parse('mail_header', true);
    656657
    657658    // what are displayed on the footer of each mail ?
    658     $conf_mail[$args['email_format']]
    659       [get_pwg_charset()]
    660       [$args['template']][$args['theme']]['footer'] =
    661         $mail_template->parse('mail_footer', true);
     659    $conf_mail[$cache_key]['footer'] =
     660      $mail_template->parse('mail_footer', true);
    662661  }
    663662
    664663  // Header
    665   $content.= $conf_mail[$args['email_format']]
    666               [get_pwg_charset()]
    667               [$args['template']][$args['theme']]['header'];
     664  $content.= $conf_mail[$cache_key]['header'];
    668665
    669666  // Content
     
    683680
    684681  // Footer
    685   $content.= $conf_mail[$args['email_format']]
    686               [get_pwg_charset()]
    687               [$args['template']][$args['theme']]['footer'];
     682  $content.= $conf_mail[$cache_key]['footer'];
    688683
    689684  // Close boundary
     
    700695    global $user;
    701696    @mkdir(PHPWG_ROOT_PATH.'testmail');
    702     $filename = PHPWG_ROOT_PATH.'testmail/mail.'.$user['username'];
     697    $filename = PHPWG_ROOT_PATH.'testmail/mail.'.$user['username'].'.'.$lang_info['code'].'.'.$args['template'].'.'.$args['theme'];
    703698    if ($args['content_format'] == 'text/plain')
    704699    {
Note: See TracChangeset for help on using the changeset viewer.