View source
<?php
function mailchimp_schema() {
$schema['mailchimp_user'] = array(
'fields' => array(
'uid' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
),
'status' => array(
'type' => 'varchar',
'length' => 15,
),
),
'primary key' => array(
'uid',
),
);
return $schema;
}
function mailchimp_install() {
drupal_install_schema('mailchimp');
mailchimp_update_6205();
}
function mailchimp_update_6200() {
$ret = array();
$ret[] = update_sql("DELETE FROM {variable} WHERE name like 'mailchimp_list\\_%'");
cache_clear_all();
return $ret;
}
function mailchimp_update_6201() {
$ret = array();
$schema = drupal_get_schema_unprocessed('mailchimp', 'mailchimp_user');
db_create_table($ret, 'mailchimp_user', $schema);
$ret[] = update_sql("INSERT INTO {mailchimp_user} (uid, status) SELECT uid, '" . MAILCHIMP_USERSTATUS_PENDING . "' FROM {users} WHERE uid > 0");
return $ret;
}
function mailchimp_update_6202() {
$ret = array();
module_load_include('php', 'mailchimp', 'MCAPI.class');
$q = new MCAPI(variable_get('mailchimp_username', ''), variable_get('mailchimp_password', ''));
$q
->setTimeout(60);
if ($q->errorCode) {
watchdog('mailchimp', $q->errorMessage, NULL, WATCHDOG_ERROR);
$ret[] = array(
'success' => FALSE,
'query' => 'MailChimp returned error: ' . check_plain($q->errorMessage),
);
return $ret;
}
variable_set('mailchimp_api_key', $q->api_key);
variable_del('mailchimp_username');
variable_del('mailchimp_password');
return $ret;
}
function mailchimp_update_6203() {
$ret = array();
$var = variable_get('mailchimp_lists', array());
if (is_array($var)) {
$ret[] = array(
'success' => TRUE,
'query' => "The 'mailchimp_lists' variable has already been fixed.",
);
}
else {
$var = unserialize($var);
variable_set('mailchimp_lists', $var);
$ret[] = array(
'success' => TRUE,
'query' => "The 'mailchimp_lists' variable has been fixed.",
);
}
return $ret;
}
function mailchimp_update_6204() {
$ret = array();
variable_del('mailchimp_unsubscription_success_message');
variable_del('mailchimp_unsubscription_failure_message');
$ret[] = array(
'success' => TRUE,
'query' => "The 'mailchimp_unsubscription' message variables have been removed.",
);
return $ret;
}
function mailchimp_update_6205() {
$ret = array();
$ret[] = update_sql("UPDATE {system} SET weight = 10 WHERE name = 'mailchimp' and type = 'module'");
return $ret;
}
function mailchimp_update_6206() {
$return = array();
$return[] = update_sql("UPDATE {blocks} SET cache = " . BLOCK_CACHE_PER_USER . " WHERE module = 'mailchimp'");
return $return;
}
function mailchimp_uninstall() {
variable_del('mailchimp_api_key');
variable_del('mailchimp_cron');
variable_del('mailchimp_interest_groups_user_forms');
variable_del('mailchimp_lists');
variable_del('mailchimp_subscription_failure_message');
variable_del('mailchimp_subscription_success_message');
variable_del('mailchimp_unsubscription_failure_message');
variable_del('mailchimp_unsubscription_success_message');
variable_del('mailchimp_user_edit');
variable_del('mailchimp_user_register');
drupal_uninstall_schema('mailchimp');
}