Changeset 1021 for trunk/include


Ignore:
Timestamp:
Feb 1, 2006, 11:07:26 PM (19 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.

Location:
trunk/include
Files:
5 edited

Legend:

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

    r1018 r1021  
    183183$conf['mail_options'] = false;
    184184
    185 // Send bcc mail to webmaster
    186 // Set true for debug or test
     185// send_bcc_mail_webmaster: send bcc mail to webmaster. Set true for debug
     186// or test.
    187187$conf['send_bcc_mail_webmaster'] = false;
    188188
  • trunk/include/functions.inc.php

    r1020 r1021  
    954954  return $search_clause;
    955955}
     956
     957/**
     958 * Returns webmaster mail address depending on $conf['webmaster_id']
     959 *
     960 * @return string
     961 */
     962function get_webmaster_mail_address()
     963{
     964  global $conf;
     965
     966  $query = '
     967SELECT '.$conf['user_fields']['email'].'
     968  FROM '.USERS_TABLE.'
     969  WHERE '.$conf['user_fields']['id'].' = '.$conf['webmaster_id'].'
     970;';
     971  list($email) = mysql_fetch_array(pwg_query($query));
     972
     973  return $email;
     974}
    956975?>
  • 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?>
  • trunk/include/functions_notification.inc.php

    r1019 r1021  
    2727
    2828
    29 // Extract news fonctions of feed.php
    30 
    31 define('PHPWG_ROOT_PATH','./');
    32 include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
     29/**
     30 * Extract news fonctions of feed.php
     31 */
    3332
    3433// +-----------------------------------------------------------------------+
  • trunk/include/page_tail.php

    r1012 r1021  
    3737    'L_POWERED_BY'=>$lang['powered_by']
    3838    ));
     39
     40//--------------------------------------------------------------------- contact
     41
     42if (!$user['is_the_guest'])
     43{
     44  $template->assign_block_vars(
     45    'contact',
     46    array(
     47      'MAIL' => get_webmaster_mail_address()
     48      )
     49    );
     50}
     51
    3952//------------------------------------------------------------- generation time
    4053if ($conf['show_gt'])
     
    6376}
    6477
    65 //--------------------------------------------------------------------- contact
    66 
    67 if (!$user['is_the_guest'])
    68 {
    69   $query = '
    70 SELECT '.$conf['user_fields']['email'].'
    71   FROM '.USERS_TABLE.'
    72   WHERE '.$conf['user_fields']['id'].' = '.$conf['webmaster_id'].'
    73 ;';
    74   list($email) = mysql_fetch_array(pwg_query($query));
    75  
    76   $template->assign_block_vars(
    77     'contact',
    78     array(
    79       'MAIL' => $email
    80       )
    81     );
    82 }
    83 
    8478//
    8579// Generate the page
Note: See TracChangeset for help on using the changeset viewer.