Ignore:
Timestamp:
Feb 6, 2007, 11:55:12 PM (17 years ago)
Author:
rub
Message:

Issue 0000598: NBM: Add new informations

Notification by mail:
Add new informations about last categories and last images like new feature of RSS notification.

2 parts:

  • Possibility to send HTML mail
  • Include last categories and last images on HTML format into notification mail

ccs & HTML experts! Please! Check, fix, improve and enhance HTML mail content!

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        22gal2
        33feed.xml
         4testmail
  • trunk/include/functions_mail.inc.php

    r1726 r1784  
    6565    format_email($conf['gallery_title'], $conf_mail['email_webmaster']);
    6666
    67   // what to display at the bottom of each mail ?
    68   $conf_mail['text_footer'] =
    69     "\n\n-- \nPhpWebGallery ".($conf['show_version'] ? PHPWG_VERSION : '');
    70  
    7167  return $conf_mail;
    7268}
     
    106102 * @param none
    107103 */
    108 function get_mail_template()
     104function get_mail_template($email_format)
    109105{
    110106  global $conf;
     
    113109  list($tmpl, $thm) = explode('/', $conf['default_template']);
    114110  $mail_template = new Template(PHPWG_ROOT_PATH.'template/'.$tmpl, $thm);
     111  $mail_template->set_rootdir(PHPWG_ROOT_PATH.'template/'.$tmpl.'/mail/'.$email_format);
    115112
    116113  return $mail_template;
     
    118115
    119116/**
     117 * Return string email format (html or not)
     118 *
     119 * @param string format
     120 */
     121function get_str_email_format($is_html)
     122{
     123  return ($is_html ? 'text/html' : 'text/plain');
     124}
     125
     126/**
    120127 * sends an email, using PhpWebGallery specific informations
    121128 */
    122129function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '', $format_infos = 'text/plain', $email_format = null)
    123130{
    124   global $conf, $conf_mail, $lang_info, $user, $page;
     131  global $conf, $conf_mail, $lang_info, $page;
    125132
    126133  $cvt7b_subject = str_translate_to_ascii7bits($subject);
     
    171178  $content = '';
    172179
    173   if (!isset($conf_mail[$email_format][$lang_info['charset']]['header']))
    174   {
    175     if ($email_format == 'text/html')
    176     {
    177       $mail_template = get_mail_template();
    178 
    179       $mail_template->set_filenames(array('mail_header'=>'mail/header.tpl'));
    180 
    181       $mail_template->assign_vars(
    182         array(
    183           'BODY_ID' =>
    184             isset($page['body_id']) ?
    185               $page['body_id'] : '',
    186 
    187           'CONTENT_ENCODING' => $lang_info['charset'],
    188           'LANG' => $lang_info['code'],
    189           'DIR' => $lang_info['direction']
    190           ));
    191 
    192       $conf_mail[$email_format][$lang_info['charset']]['header'] =
    193         $mail_template->parse('mail_header', true);
    194     }
    195     else
    196     {
    197       $conf_mail[$email_format][$lang_info['charset']]['header'] = '';
    198     }
     180  if (!isset($conf_mail[$email_format][$lang_info['charset']]))
     181  {
     182    if (!isset($mail_template))
     183    {
     184      $mail_template = get_mail_template($email_format);
     185    }
     186
     187    $mail_template->set_filename('mail_header', 'header.tpl');
     188    $mail_template->set_filename('mail_footer', 'footer.tpl');
     189
     190    $mail_template->assign_vars(
     191      array(
     192        //Header
     193        'BODY_ID' =>
     194          isset($page['body_id']) ?
     195            $page['body_id'] : '',
     196
     197        'CONTENT_ENCODING' => $lang_info['charset'],
     198        'LANG' => $lang_info['code'],
     199        'DIR' => $lang_info['direction'],
     200       
     201        // Footer
     202        'GALLERY_URL' =>
     203          isset($page['gallery_url']) ?
     204                $page['gallery_url'] : $conf['gallery_url'],
     205        'GALLERY_TITLE' =>
     206          isset($page['gallery_title']) ?
     207                $page['gallery_title'] : $conf['gallery_title'],
     208        'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '',
     209        'PHPWG_URL' => PHPWG_URL,
     210
     211        'TITLE_MAIL' => urlencode(l10n('title_send_mail')),
     212        'MAIL' => get_webmaster_mail_address()
     213        ));
     214
     215    // what are displayed on the header of each mail ?
     216    $conf_mail[$email_format][$lang_info['charset']]['header'] =
     217      $mail_template->parse('mail_header', true);
     218
     219    // what are displayed on the footer of each mail ?
     220    $conf_mail[$email_format][$lang_info['charset']]['footer'] =
     221      $mail_template->parse('mail_footer', true);
    199222  }
    200223
     
    208231  {
    209232    $content.= $infos;
    210   }
    211 
    212   if (!isset($conf_mail[$email_format][$lang_info['charset']]['footer']))
    213   {
    214     if ($email_format == 'text/html')
    215     {
    216       $mail_template->set_filenames(array('mail_footer'=>'mail/footer.tpl'));
    217 
    218       $mail_template->assign_vars(
    219         array(
    220           'GALLERY_URL' =>
    221             isset($page['gallery_url']) ?
    222                   $page['gallery_url'] : $conf['gallery_url'],
    223           'GALLERY_TITLE' =>
    224             isset($page['gallery_title']) ?
    225                   $page['gallery_title'] : $conf['gallery_title'],
    226           'VERSION' => $conf['show_version'] ? PHPWG_VERSION : '',
    227           'PHPWG_URL' => PHPWG_URL,
    228 
    229           'TITLE_MAIL' => urlencode(l10n('title_send_mail')),
    230           'MAIL' => get_webmaster_mail_address()
    231           ));
    232 
    233       $conf_mail[$email_format][$lang_info['charset']]['footer'] =
    234         $mail_template->parse('mail_footer', true);
    235     }
    236     else
    237     {
    238       $conf_mail[$email_format][$lang_info['charset']]['footer'] = $conf_mail['text_footer'];
    239     }
    240233  }
    241234
     
    248241  }
    249242
     243  /*Testing block
     244  {
     245    global $user;
     246    @mkdir(PHPWG_ROOT_PATH.'testmail');
     247    $filename = PHPWG_ROOT_PATH.'testmail/mail.'.$user['username'];
     248    if ($format_infos == 'text/plain')
     249    {
     250      $filename .= '.txt';
     251    }
     252    else
     253    {
     254      $filename .= '.html';
     255    }
     256    $file = fopen($filename, 'w+');
     257    fwrite($file, $content);
     258    fclose($file);
     259    return true;
     260  }
     261  */
     262
    250263  if ($conf_mail['mail_options'])
    251264  {
Note: See TracChangeset for help on using the changeset viewer.