Changeset 1818


Ignore:
Timestamp:
02/14/07 23:53:04 (13 years ago)
Author:
rub
Message:

My last improvements before 1.7.0RC1.

Can include Cc & Bcc on mail.
Send mail to all administrators on new comment or new users.
Add validate link on new comment mail.
Try to detect if the NBM complementary content is HTML or plain text. With plain text, this content is convert to readable HTML.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/notification_by_mail.php

    r1809 r1818  
    227227    $is_action_send = ($action == 'send'); 
    228228 
    229     if (!isset($customize_mail_content)) 
    230     { 
    231       $customize_mail_content = $conf['nbm_complementary_mail_content']; 
    232     } 
    233  
    234229    // disabled and null mail_address are not selected in the list 
    235230    $data_users = get_user_notifications('send', $check_key_list); 
     
    244239      { 
    245240        $datas = array(); 
     241 
     242        if (!isset($customize_mail_content)) 
     243        { 
     244          $customize_mail_content = $conf['nbm_complementary_mail_content']; 
     245        } 
     246 
     247        if ($conf['nbm_send_html_mail'] and !(strpos($customize_mail_content, '<') === 0)) 
     248        { 
     249          // On HTML mail, detects if the content are HTML format. 
     250          // If it's plain text format, convert content to readable HTML 
     251          $customize_mail_content = nl2br(htmlentities($customize_mail_content)); 
     252        } 
    246253 
    247254        // Prepare message after change language 
  • trunk/include/functions_mail.inc.php

    r1809 r1818  
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | 
    55// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net | 
    6 // | Copyright (C) 2006 Ruben ARNAUD - team@phpwebgallery.net              | 
     6// | Copyright (C) 2006-2007 Ruben ARNAUD - team@phpwebgallery.net         | 
    77// +-----------------------------------------------------------------------+ 
    88// | branch        : BSF (Best So Far) 
     
    2727// +-----------------------------------------------------------------------+ 
    2828 
    29 /** 
    30  * - Extract mail fonctions of password.php 
    31  * - Modify pwg_mail (add pararameters + news fonctionnalities) 
    32  * - Var conf_mail, function get_mail_configuration, format_email, pwg_mail 
    33  */ 
    34  
    3529// +-----------------------------------------------------------------------+ 
    3630// |                               functions                               | 
     
    10094 
    10195/** 
    102  * Return an completed array template/theme 
     96 * Returns an completed array template/theme 
    10397 * completed with $conf['default_template'] 
    10498 * 
     
    162156 
    163157/** 
     158 * Returns email of all administrator 
     159 * 
     160 * @return string 
     161 */ 
     162function get_administrators_email() 
     163{ 
     164  global $conf; 
     165 
     166  $result = array(); 
     167 
     168  $query = ' 
     169select 
     170  U.'.$conf['user_fields']['username'].' as username, 
     171  U.'.$conf['user_fields']['email'].' as mail_address 
     172from 
     173  '.USERS_TABLE.' as U, 
     174  '.USER_INFOS_TABLE.' as I 
     175where 
     176  I.user_id =  U.'.$conf['user_fields']['id'].' and 
     177  I.status in (\'webmaster\',  \'admin\') and 
     178  '.$conf['user_fields']['email'].' is not null 
     179order by 
     180  username 
     181'; 
     182 
     183  $datas = pwg_query($query); 
     184  if (!empty($datas)) 
     185  { 
     186    while ($admin = mysql_fetch_array($datas)) 
     187    { 
     188      if (!empty($admin['mail_address'])) 
     189      { 
     190        array_push($result, format_email($admin['username'], $admin['mail_address'])); 
     191      } 
     192    } 
     193  } 
     194 
     195  return $result; 
     196} 
     197 
     198/** 
    164199 * sends an email, using PhpWebGallery specific informations 
    165200 * 
     
    168203 *   - args: function params of mail function: 
    169204 *       o from: sender [default value webmaster email] 
     205 *       o Cc: array of carbon copy receivers of the mail. [default value empty] 
     206 *       o Bcc: array of blind carbon copy receivers of the mail. [default value empty] 
    170207 *       o subject  [default value 'PhpWebGallery'] 
    171208 *       o content: content of mail    [default value ''] 
     
    175212 *       o theme: template to use [default $conf['default_template']] 
    176213 */ 
    177 //function pwg_mail($to, $from = '', $subject = 'PhpWebGallery', $infos = '', $infos_format = 'text/plain', $email_format = null) 
    178214function pwg_mail($to, $args = array()) 
    179215{ 
     
    223259  } 
    224260 
     261  if ($conf_mail['send_bcc_mail_webmaster']) 
     262  { 
     263    $args['Bcc'][] = $conf_mail['formated_email_webmaster']; 
     264  } 
     265 
    225266  if (($args['content_format'] == 'text/html') and ($args['email_format'] == 'text/plain')) 
    226267  { 
     
    233274  $headers = 'From: '.$args['from']."\n"; 
    234275  $headers.= 'Reply-To: '.$args['from']."\n"; 
     276 
     277  if (!empty($args['Cc'])) 
     278  { 
     279    $headers.= 'Cc: '.implode(',', $args['Cc'])."\n"; 
     280  } 
     281 
     282  if (!empty($args['Bcc'])) 
     283  { 
     284    $headers.= 'Bcc: '.implode(',', $args['Bcc'])."\n"; 
     285  } 
     286 
    235287  $headers.= 'Content-Type: multipart/alternative;'."\n"; 
    236288  $headers.= '  boundary="---='.$conf_mail['boundary_key'].'";'."\n"; 
    237289  $headers.= '  reply-type=original'."\n"; 
    238290  $headers.= 'MIME-Version: 1.0'."\n"; 
    239  
    240   if ($conf_mail['send_bcc_mail_webmaster']) 
    241   { 
    242     $headers.= 'Bcc: '.$conf_mail['formated_email_webmaster']."\n"; 
    243   } 
    244291 
    245292  $content = ''; 
  • trunk/include/picture_comment.inc.php

    r1809 r1818  
    210210      include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 
    211211 
     212      $val_url = get_absolute_root_url().'comments.php?validate='.$comm['id']; 
    212213      $del_url = get_absolute_root_url().'comments.php?delete='.$comm['id']; 
    213214 
     
    217218        .'IP: '.$comm['ip']."\n" 
    218219        .'Browser: '.$comm['agent']."\n\n" 
     220        .'Validate: '.$val_url."\n" 
    219221        .'Delete: '.$del_url."\n"; 
    220222      if ($comment_action!='validate') 
     
    224226          .'comments.php?validate='.$comm['id']; 
    225227      } 
    226       pwg_mail(get_webmaster_mail_address(), 
    227         array('subject' => 'PWG comment by '.$comm['author'], 'content' => $content)); 
     228      pwg_mail 
     229      ( 
     230        format_email('administrators', get_webmaster_mail_address()), 
     231        array 
     232        ( 
     233          'subject' => 'PWG comment by '.$comm['author'],  
     234          'content' => $content, 
     235          'Bcc' => get_administrators_email() 
     236        ) 
     237      ); 
    228238    } 
    229239  } 
  • trunk/register.php

    r1809 r1818  
    7171        .l10n('admin').': '.$admin_url; 
    7272 
    73       pwg_mail(get_webmaster_mail_address(), 
     73      pwg_mail 
     74      ( 
     75        format_email('administrators', get_webmaster_mail_address()), 
    7476        array 
    7577        ( 
    7678          'subject' => 'PWG '.l10n('register_title').' '.$username, 
    77           'content' => $content 
     79          'content' => $content, 
     80          'Bcc' => get_administrators_email() 
    7881        ) 
    7982      ); 
Note: See TracChangeset for help on using the changeset viewer.