You are here

sparkpost.install in Sparkpost email 7

Same filename and directory in other branches
  1. 8.2 sparkpost.install
  2. 7.2 sparkpost.install

Install, update and uninstall functions for the sparkpost module.

File

sparkpost.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the sparkpost module.
 */

/**
 * Implements hook_requirements().
 */
function sparkpost_requirements($phase) {
  $t = get_t();
  $requirements = array();
  if (!module_exists('composer_manager') && !class_exists('\\SparkPost\\SparkPost')) {
    $requirements['sparkpost'] = array(
      'title' => $t('Sparkpost'),
      'value' => t('Make sure the Sparkpost package is installed via Composer. This can be done using the <a href="!url">composer_manager</a> module.', array(
        '!url' => 'https://drupal.org/project/composer_manager',
      )),
      'severity' => REQUIREMENT_ERROR,
    );
  }
  return $requirements;
}

/**
 * Implements hook_uninstall().
 */
function sparkpost_uninstall() {

  // Delete other variables:
  variable_del('sparkpost_api_key');
  variable_del('sparkpost_filter_format');
  variable_del('sparkpost_from');
  variable_del('sparkpost_from_name');
  variable_del('sparkpost_send_async');
  variable_del('sparkpost_skip_cron');
  variable_del('sparkpost_debug');
  variable_del('sparkpost_timeout');
}

/**
 * Implements hook_enable().
 */
function sparkpost_enable() {
  mailsystem_set(array(
    'sparkpost_test' => 'SparkpostMailSystem',
  ));
}

/**
 * Implements hook_disable().
 */
function sparkpost_disable() {

  // Tell mailsystem to remove sparkpost and restore to defaults:
  mailsystem_clear(array(
    'sparkpost_test' => 'SparkpostMailSystem',
  ));
  watchdog('sparkpost', 'Sparkpost has been disabled.');
}

/**
 * Rebuild registry.
 */
function sparkpost_update_7000() {
  registry_rebuild();
}

Functions