Ignore:
Timestamp:
Sep 16, 2012, 5:20:39 PM (12 years ago)
Author:
mistic100
Message:
  • stores emails in database (/!\ update only from published version, not from trunk)
  • allow emails to be categorized
File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/ContactForm/include/install.inc.php

    r17658 r17945  
    44function contact_form_install()
    55{
    6   global $conf;
     6  global $conf, $prefixeTable;
     7 
     8  // email table
     9  $query = '
     10CREATE TABLE IF NOT EXISTS `'. $prefixeTable .'contact_form` (
     11  `id` smallint(5) NOT NULL AUTO_INCREMENT,
     12  `name` varchar(128) NOT NULL,
     13  `email` varchar(128) NOT NULL,
     14  `active` enum("true","false") NOT NULL DEFAULT "true",
     15  `group_name` varchar(128) DEFAULT NULL,
     16  PRIMARY KEY (`id`),
     17  UNIQUE KEY `UNIQUE` (`email`,`group_name`)
     18) ENGINE=MyISAM DEFAULT CHARSET=utf8;';
     19  pwg_query($query);
    720
    821  // configuration
     
    1932      'cf_redirect_delay' => 5,
    2033      'cf_mail_type' => 'text/html',
    21       'cf_admin_mails' => array(),
    2234      ));
    2335   
     
    3749    if (!isset($new_conf['cf_must_initialize']))
    3850    {
     51      // new params
    3952      $new_conf['cf_must_initialize'] = false;
    4053      $new_conf['cf_default_subject'] = 'A comment on your site';
    4154      $new_conf['cf_mail_type'] = 'text/html';
    42       unset($new_conf['comment'], $new_conf['cf_redirect_delay'], $new_conf['cf_separator'], $new_conf['cf_separator_length']);
    4355     
     56      // move emails to database
     57      $email = array();
    4458      foreach ($new_conf['cf_admin_mails'] as $email => $data)
    4559      {
    46         $new_conf['cf_admin_mails'][] = array(
     60        array_push($emails, array(
    4761          'email' => $email,
    4862          'name' => $data['NAME'],
    49           'active' => $data['ACTIVE'],
    50           );
    51         unset($new_conf['cf_admin_mails'][ $email ]);
     63          'active' => boolean_to_string($data['ACTIVE']),
     64          ));
    5265      }
    5366     
     67      mass_inserts(
     68        $prefixeTable .'contact_form',
     69        array('name','email','active'),
     70        $emails
     71        );
     72     
     73      // old params
     74      unset(
     75        $new_conf['comment'], $new_conf['cf_redirect_delay'],
     76        $new_conf['cf_separator'], $new_conf['cf_separator_length'],
     77        $new_conf['cf_admin_mails']
     78        );
     79     
     80      // save config
    5481      $conf['ContactForm'] = serialize($new_conf);
    5582      $conf['ContactForm_before'] = stripslashes($conf['persoformtop']);
Note: See TracChangeset for help on using the changeset viewer.