Ignore:
Timestamp:
Feb 1, 2006, 11:07:26 PM (18 years ago)
Author:
plg
Message:

Applying coding style guidelines to r1018 and r1019.

New function get_webmaster_mail_address used in include/page_tail.php and
include/functions_mail.inc.php.

Nothing else than functions in include/functions*, init_conf_mail() was
useless in include/functions_mail.inc.php because $conf_mail is only used in
function pwg_mail.

bug fixed: files include/functions_mail.inc.php and
include/functions_notification.inc.php had been commited in DOS format! Unix
file format is the only file format authorized.

File:
1 edited

Legend:

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

    r1019 r1021  
    2727// +-----------------------------------------------------------------------+
    2828
    29 // Extract mail fonctions of password.php
    30 // And Modify pwg_mail (add pararameters + news fonctionnalities)
    31 // And var conf_mail, function init_conf_mail, function format_email
    32 
    33 define('PHPWG_ROOT_PATH','./');
    34 include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
     29/**
     30 * - Extract mail fonctions of password.php
     31 * - Modify pwg_mail (add pararameters + news fonctionnalities)
     32 * - Var conf_mail, function init_conf_mail, function format_email
     33 */
    3534
    3635// +-----------------------------------------------------------------------+
     
    3938
    4039/*
    41  * Initialization of global variable $conf_mail
     40 * Returns an array of mail configuration parameters :
     41 *
     42 * - mail_options: see $conf['mail_options']
     43 * - send_bcc_mail_webmaster: see $conf['send_bcc_mail_webmaster']
     44 * - email_webmaster: mail corresponding to $conf['webmaster_id']
     45 * - formated_email_webmaster: the name of webmaster is $conf['gallery_title']
     46 * - text_footer: PhpWebGallery and version
     47 *
     48 * @return array
    4249 */
    43 function init_conf_mail()
     50function get_mail_configuration()
    4451{
    45   global $conf, $conf_mail;
     52  global $conf;
    4653
    47   if (count($conf_mail) == 0)
    48   {
    49     $conf_mail['mail_options'] = $conf['mail_options'];
    50     $conf_mail['send_bcc_mail_webmaster'] = ($conf['send_bcc_mail_webmaster'] == true ? true : false);
    51     list($conf_mail['email_webmaster']) = mysql_fetch_array(pwg_query('select '.$conf['user_fields']['email'].' from '.USERS_TABLE.' where '.$conf['user_fields']['id'].' = '.$conf['webmaster_id'].';'));
    52     $conf_mail['formated_email_webmaster'] = format_email($conf['gallery_title'], $conf_mail['email_webmaster']);
    53     $conf_mail['text_footer'] = "\n\n-- \nPhpWebGallery ".($conf['show_version'] ? PHPWG_VERSION : '');
    54   }
     54  $conf_mail = array(
     55    'mail_options' => $conf['mail_options'],
     56    'send_bcc_mail_webmaster' => $conf['send_bcc_mail_webmaster'],
     57    );
    5558
    56   return true;
     59  // we have webmaster id among user list, what's his email address ?
     60  $conf_mail['email_webmaster'] = get_webmaster_mail_address();
     61
     62  // name of the webmaster is the title of the gallery
     63  $conf_mail['formated_email_webmaster'] =
     64    format_email($conf['gallery_title'], $conf_mail['email_webmaster']);
     65
     66  // what to display at the bottom of each mail ?
     67  $conf_mail['text_footer'] =
     68    "\n\n-- \nPhpWebGallery ".($conf['show_version'] ? PHPWG_VERSION : '');
     69 
     70  return $conf_mail;
    5771}
    5872
     73/**
     74 * Returns an email address with an associated real name
     75 *
     76 * @param string name
     77 * @param string email
     78 */
    5979function format_email($name, $email)
    6080{
    6181  if (strpos($email, '<') === false)
     82  {
    6283    return $name.' <'.$email.'>';
     84  }
    6385  else
     86  {
    6487    return $name.$email;
     88  }
    6589}
    6690
     
    7296  global $conf, $conf_mail;
    7397
     98  if (!isset($conf_mail))
     99  {
     100    $conf_mail = get_mail_configuration();
     101  }
     102
    74103  $to = format_email('', $to);
    75104
    76   if ($from =='')
     105  if ($from == '')
     106  {
    77107    $from = $conf_mail['formated_email_webmaster'];
     108  }
    78109  else
     110  {
    79111    $from = format_email('', $from);
     112  }
    80113
    81114  $headers = 'From: '.$from."\n";
    82115  $headers.= 'Reply-To: '.$from."\n";
     116 
    83117  if ($conf_mail['send_bcc_mail_webmaster'])
     118  {
    84119    $headers.= 'Bcc: '.$conf_mail['formated_email_webmaster']."\n";
    85 
    86 
    87   $options = '-f '.$from;
    88 
     120  }
     121 
    89122  $content = $infos;
    90123  $content.= $conf_mail['text_footer'];
     
    92125  if ($conf_mail['mail_options'])
    93126  {
     127    $options = '-f '.$from;
     128   
    94129    return mail($to, $subject, $content, $headers, $options);
    95130  }
     
    99134  }
    100135}
    101 
    102 // +-----------------------------------------------------------------------+
    103 // | Global Variables
    104 // +-----------------------------------------------------------------------+
    105 $conf_mail = array();
    106 
    107 init_conf_mail();
    108 
    109136?>
Note: See TracChangeset for help on using the changeset viewer.