mailchimp.install in Mailchimp 7.4
Same filename and directory in other branches
Install, update and uninstall functions for the mailchimp module.
File
mailchimp.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the mailchimp module.
*/
/**
* Implements hook_schema().
*/
function mailchimp_schema() {
$schema['cache_mailchimp'] = drupal_get_schema_unprocessed('system', 'cache');
$schema['cache_mailchimp']['description'] = 'Cache table for the Mailchimp module to store a list of subscribers member info.';
return $schema;
}
/**
* Implements hook_requirements().
*/
function mailchimp_requirements($phase) {
$requirements = array();
// Ensure translations don't break at install time:
$t = get_t();
// Report Drupal version:
if (in_array($phase, array(
'runtime',
'update',
))) {
// Check to see if Libraries module is being used.
if (module_exists('libraries')) {
$library = libraries_detect('mailchimp');
}
else {
$library = FALSE;
}
$requirements['mailchimp'] = array(
'title' => $t('Mailchimp'),
);
if ($library['installed']) {
$requirements['mailchimp'] += array(
'value' => $library['version'],
'description' => $t('The Mailchimp MCAPI wrapper library is installed correctly.'),
'severity' => REQUIREMENT_OK,
);
}
elseif (class_exists('Mailchimp\\Mailchimp')) {
$requirements['mailchimp'] += array(
'value' => Mailchimp\Mailchimp::VERSION,
'description' => $t('The Mailchimp MCAPI wrapper library is installed correctly.'),
'severity' => REQUIREMENT_OK,
);
}
else {
$requirements['mailchimp'] += array(
'value' => $library['error'],
'description' => $library['error message'],
'severity' => REQUIREMENT_ERROR,
);
}
// Notify user to update MailChimp library if using version 1.0.7 or lower.
if (empty($library['error'])) {
$version_int = (int) str_replace('.', '', $library['version']);
if ($version_int <= 107) {
$requirements['mailchimp']['value'] = $library['version'];
$requirements['mailchimp']['description'] = $t('Please update the <a href="https://github.com/thinkshout/mailchimp-api-php/releases">MailChimp library</a> to at least version 1.0.8 to ensure continued stability.');
$requirements['mailchimp']['severity'] = REQUIREMENT_WARNING;
}
}
}
return $requirements;
}
/**
* Implements hook_uninstall().
*/
function mailchimp_uninstall() {
variable_del('mailchimp_api_key');
variable_del('mailchimp_batch_limit');
$queue = DrupalQueue::get(MAILCHIMP_QUEUE_CRON);
$queue
->deleteQueue();
$queue = DrupalQueue::get(MAILCHIMP_BATCH_QUEUE_CRON);
$queue
->deleteQueue();
}
Functions
Name | Description |
---|---|
mailchimp_requirements | Implements hook_requirements(). |
mailchimp_schema | Implements hook_schema(). |
mailchimp_uninstall | Implements hook_uninstall(). |