Changeset 17483 for extensions/ContactForm/maintain.inc.php
- Timestamp:
- Aug 9, 2012, 12:10:04 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/ContactForm/maintain.inc.php
r8909 r17483 1 1 <?php 2 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 3 if (!defined('IN_ADMIN') or !IN_ADMIN) die('Hacking attempt!');4 3 5 if (!defined('CF_PATH')) { 6 define('CF_PATH', PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/'); 7 } 8 if (!defined('CF_ROOT')) { 9 define('CF_ROOT', dirname(__FILE__).'/'); 4 define('contact_form_default_config', 5 serialize(array( 6 'cf_must_initialize' => true, 7 'cf_menu_link' => true, 8 'cf_subject_prefix' => '%gallery_title%', 9 'cf_default_subject' => 'A comment on the site', 10 'cf_allow_guest' => true, 11 'cf_mandatory_mail' => true, 12 'cf_mandatory_name' => true, 13 'cf_redirect_delay' => 5, 14 'cf_mail_type' => 'text/html', 15 'cf_admin_mails' => array(), 16 )) 17 ); 18 19 20 function plugin_install() 21 { 22 conf_update_param('ContactForm', contact_form_default_config); 23 conf_update_param('ContactForm_before', null); 24 conf_update_param('ContactForm_after', null); 10 25 } 11 26 12 function plugin_install($plugin_id, $version, &$errors) { 13 include_once(CF_PATH . 'include/cf_common.inc.php'); 14 // Include language advices 15 load_language('plugin.lang', CF_PATH); 16 update_config($plugin_id, CF_CFG_DB_FACTORY); 27 function plugin_activate() 28 { 29 global $conf; 30 31 if (!isset($conf['ContactForm'])) 32 { 33 plugin_install(); 34 } 35 else 36 { 37 $new_conf = unserialize($conf['ContactForm']); 38 39 // migration 2.4 -> 2.5 40 if (!isset($new_conf['cf_must_initialize'])) 41 { 42 $new_conf['cf_must_initialize'] = false; 43 $new_conf['cf_default_subject'] = 'A comment on the site'; 44 $new_conf['cf_mail_type'] = 'text/html'; 45 unset($new_conf['comment'], $new_conf['cf_redirect_delay']); 46 unset($new_conf['cf_separator'], $new_conf['cf_separator_length']); 47 48 foreach ($new_conf['cf_admin_mails'] as $email => $data) 49 { 50 $new_conf['cf_admin_mails'][] = array( 51 'email' => $email, 52 'name' => $data['NAME'], 53 'active' => $data['ACTIVE'], 54 ); 55 unset($new_conf['cf_admin_mails'][ $email ]); 56 } 57 58 conf_update_param('ContactForm', serialize($new_conf)); 59 conf_update_param('ContactForm_before', stripslashes($conf['persoformtop'])); 60 conf_update_param('ContactForm_after', stripslashes($conf['persoformbottom'])); 61 62 pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param IN("persoformtop", "persoformbottom") LIMIT 2;'); 63 } 64 } 17 65 } 18 66 19 function plugin_activate($plugin_id, $version, &$errors) { 20 update_config($plugin_id); 67 function plugin_uninstall() 68 { 69 pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param LIKE "ContactForm%" LIMIT 3;'); 21 70 } 22 71 23 function plugin_deactivate($plugin_id) {24 // Nothing special25 }26 27 function plugin_uninstall($plugin_id) {28 include_once(CF_PATH . 'include/cf_common.inc.php');29 $uninstall = CF_Config::uninstall($plugin_id);30 }31 32 function update_config($plugin_id, $db_comment=null) {33 include_once(CF_PATH . 'include/cf_common.inc.php');34 $clean = cf_clean_obsolete_files(CF_OBSOLETE);35 if (null != $db_comment) {36 $cf_config_default[CF_CFG_COMMENT] = $db_comment;37 }38 $install = CF_Config::install($plugin_id);39 }40 72 ?>
Note: See TracChangeset
for help on using the changeset viewer.