source: extensions/ContactForm/include/install.inc.php @ 24347

Last change on this file since 24347 was 24347, checked in by mistic100, 11 years ago

force footer contact link when the form is public

File size: 3.4 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4function contact_form_install()
5{
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);
20
21  // configuration
22  if (empty($conf['ContactForm']))
23  {
24    $contact_form_default_config = serialize(array(
25      'cf_ready' => false,
26      'cf_must_initialize' => true,
27      'cf_menu_link' => true,
28      'cf_subject_prefix' => '%gallery_title%',
29      'cf_default_subject' => 'A comment on your site',
30      'cf_allow_guest' => true,
31      'cf_mandatory_mail' => true,
32      'cf_mandatory_name' => true,
33      'cf_mail_type' => 'text/html',
34      'cf_redirect_url' => null,
35      'cf_theme' => 'dark',
36      ));
37   
38    conf_update_param('ContactForm', $contact_form_default_config);
39    conf_update_param('ContactForm_before', null);
40    conf_update_param('ContactForm_after', null);
41   
42    $conf['ContactForm'] = $contact_form_default_config;
43    $conf['ContactForm_before'] = null;
44    $conf['ContactForm_after'] = null;
45  }
46  else
47  {
48    $new_conf = is_string($conf['ContactForm']) ? unserialize($conf['ContactForm']) : $conf['ContactForm'];
49   
50    // migration 2.4 -> 2.5
51    if (!isset($new_conf['cf_must_initialize']))
52    {
53      // new params
54      $new_conf['cf_default_subject'] = 'A comment on your site';
55      $new_conf['cf_mail_type'] = 'text/html';
56      $new_conf['cf_redirect_url'] = null;
57     
58      // move emails to database
59      $emails = array();
60      foreach ($new_conf['cf_admin_mails'] as $email => $data)
61      {
62        array_push($emails, array(
63          'email' => $email,
64          'name' => $data['NAME'],
65          'active' => boolean_to_string($data['ACTIVE']),
66          ));
67      }
68     
69      $new_conf['cf_must_initialize'] = empty($emails);
70     
71      mass_inserts(
72        $prefixeTable .'contact_form',
73        array('name','email','active'),
74        $emails
75        );
76     
77      // old params
78      unset(
79        $new_conf['comment'], $new_conf['cf_redirect_delay'], 
80        $new_conf['cf_separator'], $new_conf['cf_separator_length'], 
81        $new_conf['cf_admin_mails']
82        );
83     
84      // save config
85      $conf['ContactForm_before'] = stripslashes(@$conf['persoformtop']);
86      $conf['ContactForm_after'] = stripslashes(@$conf['persoformbottom']);
87     
88      conf_update_param('ContactForm_before', $conf['ContactForm_before']);
89      conf_update_param('ContactForm_after', $conf['ContactForm_after']);
90     
91      pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param IN("persoformtop", "persoformbottom") LIMIT 2;');
92    }
93   
94    // new param 2.5.c
95    if (!isset($new_conf['cf_theme']))
96    {
97      $new_conf['cf_theme'] = 'dark';
98    }
99   
100    if (!isset($new_conf['cf_ready']))
101    {
102      $new_conf['cf_ready'] = false;
103    }
104   
105    // save config
106    $conf['ContactForm'] = serialize($new_conf);
107    conf_update_param('ContactForm', $conf['ContactForm']);
108  }
109}
110
111?>
Note: See TracBrowser for help on using the repository browser.