[17658] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | function contact_form_install() |
---|
| 5 | { |
---|
[17945] | 6 | global $conf, $prefixeTable; |
---|
| 7 | |
---|
| 8 | // email table |
---|
| 9 | $query = ' |
---|
| 10 | CREATE 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); |
---|
[17658] | 20 | |
---|
| 21 | // configuration |
---|
| 22 | if (empty($conf['ContactForm'])) |
---|
| 23 | { |
---|
| 24 | $contact_form_default_config = serialize(array( |
---|
| 25 | 'cf_must_initialize' => true, |
---|
| 26 | 'cf_menu_link' => true, |
---|
| 27 | 'cf_subject_prefix' => '%gallery_title%', |
---|
| 28 | 'cf_default_subject' => 'A comment on your site', |
---|
| 29 | 'cf_allow_guest' => true, |
---|
| 30 | 'cf_mandatory_mail' => true, |
---|
| 31 | 'cf_mandatory_name' => true, |
---|
| 32 | 'cf_redirect_delay' => 5, |
---|
| 33 | 'cf_mail_type' => 'text/html', |
---|
| 34 | )); |
---|
| 35 | |
---|
| 36 | conf_update_param('ContactForm', $contact_form_default_config); |
---|
| 37 | conf_update_param('ContactForm_before', null); |
---|
| 38 | conf_update_param('ContactForm_after', null); |
---|
| 39 | |
---|
| 40 | $conf['ContactForm'] = $contact_form_default_config; |
---|
| 41 | $conf['ContactForm_before'] = null; |
---|
| 42 | $conf['ContactForm_after'] = null; |
---|
| 43 | } |
---|
| 44 | else |
---|
| 45 | { |
---|
| 46 | $new_conf = is_string($conf['ContactForm']) ? unserialize($conf['ContactForm']) : $conf['ContactForm']; |
---|
| 47 | |
---|
| 48 | // migration 2.4 -> 2.5 |
---|
| 49 | if (!isset($new_conf['cf_must_initialize'])) |
---|
| 50 | { |
---|
[17945] | 51 | // new params |
---|
[17658] | 52 | $new_conf['cf_must_initialize'] = false; |
---|
| 53 | $new_conf['cf_default_subject'] = 'A comment on your site'; |
---|
| 54 | $new_conf['cf_mail_type'] = 'text/html'; |
---|
| 55 | |
---|
[17945] | 56 | // move emails to database |
---|
| 57 | $email = array(); |
---|
[17658] | 58 | foreach ($new_conf['cf_admin_mails'] as $email => $data) |
---|
| 59 | { |
---|
[17945] | 60 | array_push($emails, array( |
---|
[17658] | 61 | 'email' => $email, |
---|
| 62 | 'name' => $data['NAME'], |
---|
[17945] | 63 | 'active' => boolean_to_string($data['ACTIVE']), |
---|
| 64 | )); |
---|
[17658] | 65 | } |
---|
| 66 | |
---|
[17945] | 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 |
---|
[17658] | 81 | $conf['ContactForm'] = serialize($new_conf); |
---|
| 82 | $conf['ContactForm_before'] = stripslashes($conf['persoformtop']); |
---|
| 83 | $conf['ContactForm_after'] = stripslashes($conf['persoformbottom']); |
---|
| 84 | |
---|
| 85 | conf_update_param('ContactForm', $conf['ContactForm']); |
---|
| 86 | conf_update_param('ContactForm_before', $conf['ContactForm_before']); |
---|
| 87 | conf_update_param('ContactForm_after', $conf['ContactForm_after']); |
---|
| 88 | |
---|
| 89 | pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param IN("persoformtop", "persoformbottom") LIMIT 2;'); |
---|
| 90 | } |
---|
| 91 | } |
---|
| 92 | } |
---|
| 93 | |
---|
| 94 | ?> |
---|