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

Last change on this file since 17658 was 17658, checked in by mistic100, 12 years ago

consolidate upgrade process

File size: 2.3 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4function contact_form_install()
5{
6  global $conf;
7
8  // configuration
9  if (empty($conf['ContactForm']))
10  {
11    $contact_form_default_config = serialize(array(
12      'cf_must_initialize' => true,
13      'cf_menu_link' => true,
14      'cf_subject_prefix' => '%gallery_title%',
15      'cf_default_subject' => 'A comment on your site',
16      'cf_allow_guest' => true,
17      'cf_mandatory_mail' => true,
18      'cf_mandatory_name' => true,
19      'cf_redirect_delay' => 5,
20      'cf_mail_type' => 'text/html',
21      'cf_admin_mails' => array(),
22      ));
23   
24    conf_update_param('ContactForm', $contact_form_default_config);
25    conf_update_param('ContactForm_before', null);
26    conf_update_param('ContactForm_after', null);
27   
28    $conf['ContactForm'] = $contact_form_default_config;
29    $conf['ContactForm_before'] = null;
30    $conf['ContactForm_after'] = null;
31  }
32  else
33  {
34    $new_conf = is_string($conf['ContactForm']) ? unserialize($conf['ContactForm']) : $conf['ContactForm'];
35   
36    // migration 2.4 -> 2.5
37    if (!isset($new_conf['cf_must_initialize']))
38    {
39      $new_conf['cf_must_initialize'] = false;
40      $new_conf['cf_default_subject'] = 'A comment on your site';
41      $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']);
43     
44      foreach ($new_conf['cf_admin_mails'] as $email => $data)
45      {
46        $new_conf['cf_admin_mails'][] = array(
47          'email' => $email,
48          'name' => $data['NAME'],
49          'active' => $data['ACTIVE'],
50          );
51        unset($new_conf['cf_admin_mails'][ $email ]);
52      }
53     
54      $conf['ContactForm'] = serialize($new_conf);
55      $conf['ContactForm_before'] = stripslashes($conf['persoformtop']);
56      $conf['ContactForm_after'] = stripslashes($conf['persoformbottom']);
57     
58      conf_update_param('ContactForm', $conf['ContactForm']);
59      conf_update_param('ContactForm_before', $conf['ContactForm_before']);
60      conf_update_param('ContactForm_after', $conf['ContactForm_after']);
61     
62      pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param IN("persoformtop", "persoformbottom") LIMIT 2;');
63    }
64  }
65}
66
67?>
Note: See TracBrowser for help on using the repository browser.