Changeset 3810


Ignore:
Timestamp:
Sep 1, 2009, 7:13:00 PM (15 years ago)
Author:
Criss
Message:

bug 0001150

Add e-mail address management

Location:
extensions/ContactForm
Files:
2 added
11 edited

Legend:

Unmodified
Added
Removed
  • extensions/ContactForm/CHANGELOG

    r3809 r3810  
    112009-08-21 1.0.6
    22                  Replace redirect page by a message on the index one
     3                  Add e-mail address management
    34
    452009-08-21 1.0.5
  • extensions/ContactForm/admin/template/cf_history.tab.tpl

    r3771 r3810  
    1010  </tr>
    1111{foreach from=$CF_HISTORY item=history_item name=history}
    12   <tr class="{if $smarty.foreach.history.index is odd}row1{else}row2{/if}">
     12  <tr class="{cycle values="row2,row1"}">
    1313    <td>
    1414    {if isset($history_item.DATE.FORMATTED)}
  • extensions/ContactForm/admin/template/contactform_admin.css

    r3753 r3810  
    2121        text-align: right;
    2222}
     23.cf-refresh {
     24        padding-top: 5px;
     25        padding-bottom: 5px;
     26}
  • extensions/ContactForm/classes/cf_log.class.php

    r3753 r3810  
    2222    $debug_text = $template->parse('contact_form_debug', true);
    2323    $template->assign('CF_DEBUG', $debug_text);
    24    
    2524    return $debug_text;
    2625  }
  • extensions/ContactForm/classes/cf_plugin.class.php

    r3809 r3810  
    311311  }
    312312 
     313  protected function get_active_admin_emails() {
     314    //$cf_emails = $cf_config->get_value(CF_CFG_ADMIN_MAILS);
     315    $all_mails = $this->config->get_value(CF_CFG_ADMIN_MAILS);
     316    $active = array('WEBMASTER' => null, 'ADMINS' => array());
     317    foreach($all_mails as $email => $values) {
     318      if (1 == $values['ACTIVE']) {
     319        if (1 == $values['WEBMASTER']) {
     320          $active['WEBMASTER'] = $values['EMAILSTR'];
     321        } else {
     322          array_push($active['ADMINS'], $values['EMAILSTR']);
     323        }
     324      }
     325    }
     326    return $active;
     327  }
     328 
    313329  protected function send_message(&$infos) {
    314330    //redirect(make_index_url());
    315331//    include(PHPWG_ROOT_PATH . 'include/functions_mail.inc.php');
    316     $webmaster_mail = get_webmaster_mail_address();
    317     if (null == $webmaster_mail) {
    318       $webmaster_mail = '';
    319     }
    320     $admin_mails = cf_get_admins_emails($webmaster_mail);
    321     if (('' == $webmaster_mail) and (0 == count($admin_mails))) {
     332
     333    $admin_mails = $this->get_active_admin_emails();
     334    if ( empty($admin_mails) or
     335        (empty($admin_mails['WEBMASTER']) and
     336         empty($admin_mails['ADMINS']))
     337        ) {
    322338      // No admin mail...
     339      array_push( $infos['infos'], l10n('cf_no_mail'));
    323340      return true;
    324341    }
     
    338355    $mail_args = array(
    339356        'from' => $from,
    340         'Bcc' => $admin_mails,
     357        'Bcc' => $admin_mails['ADMINS'],
    341358        'subject' => $subject,
    342359        'content' => $content,
     
    347364
    348365    $return = true;
    349 //    $return = @pwg_mail(
    350 //      $webmaster_mail,
    351 //      $mail_args
    352 //    );
     366    $return = @pwg_mail(
     367      $admin_mails['WEBMASTER'],
     368      $mail_args
     369    );
    353370
    354371    cf_switch_back_to_user_lang();
  • extensions/ContactForm/config.php

    r3771 r3810  
    11<?php
    2 /* $Id: config.php,v 1.4 2009/08/21 09:24:18 Criss Exp $ */
     2/* $Id: config.php,v 1.5 2009/09/01 17:10:49 Criss Exp $ */
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44check_status(ACCESS_ADMINISTRATOR);
     
    88
    99$config_tabs[]='config';
     10$config_tabs[]='emails';
    1011$config_tabs[]='language';
    1112$config_tabs[]='history';
  • extensions/ContactForm/include/cf_common.inc.php

    r3809 r3810  
    5858define('CF_CFG_DEFINE_LINK',    'cf_define_link');
    5959define('CF_CFG_CONTACT_LINK',   'cf_link');
     60define('CF_CFG_ADMIN_MAILS',    'cf_admin_mails');
    6061
    6162/* ************************** */
     
    8788$cf_config_default[CF_CFG_DEFINE_LINK] = true;
    8889$cf_config_default[CF_CFG_CONTACT_LINK] = CF_DEFAULT_LINKNAME;
     90$cf_config_default[CF_CFG_ADMIN_MAILS] = cf_get_admins_contacts();
     91$cf_config_default[CF_CFG_ADMIN_MAILS] = array();
    8992CF_Config::$default_config = $cf_config_default;
    9093
  • extensions/ContactForm/include/cf_functions.inc.php

    r3809 r3810  
    7474}
    7575
     76function cf_get_admins_contacts() {
     77  global $conf, $user;
     78  $admins = array();
     79
     80  $query = '
     81select
     82  U.'.$conf['user_fields']['username'].' as username,
     83  U.'.$conf['user_fields']['email'].' as mail_address
     84from
     85  '.USERS_TABLE.' as U,
     86  '.USER_INFOS_TABLE.' as I
     87where
     88  I.user_id =  U.'.$conf['user_fields']['id'].' and
     89  I.status in (\'webmaster\',  \'admin\') and
     90  I.adviser = \'false\' and
     91  '.$conf['user_fields']['email'].' is not null
     92order by
     93  username
     94';
     95 
     96  $webmaster_mail = get_webmaster_mail_address();
     97  $datas = pwg_query($query);
     98  if (!empty($datas)) {
     99    while ($admin = mysql_fetch_array($datas)) {
     100      if (!empty($admin['mail_address'])) {
     101        $name = $admin['username'];
     102        $webmaster = 0;
     103        if (0 == strcasecmp($webmaster_mail, $admin['mail_address'])) {
     104          $name = l10n('Webmaster');
     105          $webmaster = 1;
     106        }
     107        $admins[$admin['mail_address']] = array(
     108            'NAME'     => $name,
     109            'EMAILSTR' => format_email($name,
     110                                       $admin['mail_address']),
     111            'ACTIVE'   => 1,
     112            'WEBMASTER'=> $webmaster,
     113          );
     114      }
     115    }
     116  }
     117  return $admins;
     118 
     119}
     120
    76121/* Return template for user template/theme*/
    77122function cf_get_template($file, $dir=CF_TEMPLATE, $prefix='') {
  • extensions/ContactForm/language/en_UK/plugin.lang.php

    r3809 r3810  
    11<?php
    2 /* $Id: plugin.lang.php,v 1.10 2009/09/01 13:25:03 Criss Exp $ */
     2/* $Id: plugin.lang.php,v 1.11 2009/09/01 17:10:50 Criss Exp $ */
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44global $lang;
     
    6464$lang['cf_define_link'] = 'Define link';
    6565$lang['cf_link'] = 'Name of the template variable containing the HTML link to the contact form';
     66// Emails tab
     67$lang['cf_tab_emails'] = 'E-mails';
     68$lang['cf_emails_desc'] = 'Destination e-mails management';
     69$lang['cf_active'] = 'Active e-mail';
     70$lang['cf_no_mail'] = 'No e-mail address available';
     71$lang['cf_refresh'] = 'Regenerate e-mail list address';
    6672// Language tab
    6773$lang['cf_tab_language'] = 'Localization';
  • extensions/ContactForm/language/fr_FR/plugin.lang.php

    r3809 r3810  
    11<?php
    2 /* $Id: plugin.lang.php,v 1.10 2009/09/01 13:25:03 Criss Exp $ */
     2/* $Id: plugin.lang.php,v 1.11 2009/09/01 17:10:49 Criss Exp $ */
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44global $lang;
     
    6464$lang['cf_define_link'] = 'Définir le lien';
    6565$lang['cf_link'] = 'Nom de la variable de template contenant le lien HTML vers le formulaire de contact';
     66// Emails tab
     67$lang['cf_tab_emails'] = 'E-mails';
     68$lang['cf_emails_desc'] = 'Gestion des e-mails de destination';
     69$lang['cf_active'] = 'E-mail actif';
     70$lang['cf_no_mail'] = 'Aucune adresse e-mail disponible';
     71$lang['cf_refresh'] = 'Regénérer la liste des adresses';
    6672// Language tab
    6773$lang['cf_tab_language'] = 'Localisation';
  • extensions/ContactForm/language/it_IT/plugin.lang.php

    r3809 r3810  
    11<?php
    2 /* $Id: plugin.lang.php,v 1.10 2009/09/01 13:25:03 Criss Exp $ */
     2/* $Id: plugin.lang.php,v 1.11 2009/09/01 17:10:50 Criss Exp $ */
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44global $lang;
     
    6464$lang['cf_define_link'] = 'Definire il link';
    6565$lang['cf_link'] = 'Nome della variabile del template contenente il link HTML verso il formulario di contatto';
     66// Emails tab
     67// TODO $lang['cf_tab_emails'] = '';
     68// TODO $lang['cf_emails_desc'] = '';
     69// TODO $lang['cf_active'] = '';
     70// TODO $lang['cf_no_mail'] = '';
     71// TODO $lang['cf_refresh'] = '';
    6672// Language tab
    6773$lang['cf_tab_language'] = 'Localizzazione';
Note: See TracChangeset for help on using the changeset viewer.