You are here

function maillog_disable in Maillog / Mail Developer 7

Same name and namespace in other branches
  1. 6 maillog.install \maillog_disable()

Implements hook_disable().

File

./maillog.install, line 43
Provides the installation routines for the maillog module.

Code

function maillog_disable() {

  // Get the current mail system config.
  $mail_system = variable_get('mail_system', array(
    'default-system' => 'DefaultMailSystem',
  ));

  // Delete any overrides that might be set for Maillog.
  unset($mail_system['maillog']);

  // Revert the default config mail config if it is currently set to use
  // Maillog, and any others that are set to Maillog can be just deleted so they
  // revert to the default.
  $default_class = 'DefaultMailSystem';
  $maillog_class = 'MaillogMailSystem';
  foreach ($mail_system as $system => $class) {

    // Look for the default mail handler.
    if ($system == 'default-system') {

      // If this is currently using Maillog, revert it to the default class.
      if ($class == $maillog_class) {
        $mail_system[$system] = $default_class;
      }
    }
    elseif ($class == $maillog_class) {
      unset($mail_system[$system]);
    }
  }

  // Update the mail config.
  variable_set('mail_system', $mail_system);
}