View source
<?php
function feedback_install() {
switch ($GLOBALS['db_type']) {
case 'mysqli':
case 'mysql':
$result = db_query("\n CREATE TABLE IF NOT EXISTS {feedback_pages} (\n name VARCHAR(32) NOT NULL PRIMARY KEY,\n data LONGTEXT\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
case 'pgsql':
$result = db_query("\n CREATE TABLE {feedback_pages} (\n name VARCHAR(32) NOT NULL PRIMARY KEY,\n data TEXT\n )");
default:
break;
}
require_once drupal_get_path('module', 'feedback') . '/feedback.module';
_feedback_add_page('default');
}
function feedback_uninstall() {
db_query("DROP TABLE {feedback_pages}");
db_query("DELETE FROM {variable} WHERE name LIKE 'feedback_%%'");
}
function feedback_update_1() {
feedback_install();
}
function feedback_update_2() {
global $conf;
$defaults = array();
$defaults['email'] = variable_get('feedback_email', variable_get('site_mail', ini_get('sendmail_from')));
$defaults['title'] = variable_get('feedback_nav_link', t('feedback'));
$defaults['instructions'] = variable_get('feedback_instructions', '');
$defaults['subject_prefix'] = variable_get('feedback_subject_prefix', '');
$defaults["field_subject"] = variable_get('feedback_field_subject', '1');
$defaults["field_name"] = variable_get('feedback_field_name', '1');
$defaults["field_postal"] = variable_get('feedback_field_postal', '0');
$defaults["field_phone"] = variable_get('feedback_field_phone', '0');
$defaults["field_body"] = variable_get('feedback_field_body', '1');
$defaults["logging"] = variable_get('feedback_logging', '1');
$defaults['hourly_threshold'] = 3;
$result = db_query("UPDATE {feedback_pages} SET data = '%s' WHERE name = '%s'", serialize($defaults), 'default');
if ($result) {
foreach ($conf as $key => $variable) {
if (strpos($key, 'feedback') === 0) {
variable_del($key);
}
}
}
else {
drupal_set_message('Failed to transfer old feedback configuration to new feedback configuration table', 'error');
}
return array();
}