You are here

mimemail.install in Mime Mail 6

Same filename and directory in other branches
  1. 7 mimemail.install

Install, update and uninstall functions for the Mime Mail module.

File

mimemail.install
View source
<?php

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

/**
 * Implements hook_requirements().
 */
function mimemail_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break at install time
  $t = get_t();

  // Report Drupal version
  if (!function_exists('drupal_random_key')) {
    $requirements['drupal'] = array(
      'title' => $t('Drupal'),
      'value' => VERSION,
      'description' => $t('Mime Mail requires Drupal version 6.29 or higher.'),
      'severity' => REQUIREMENT_ERROR,
    );
  }
  return $requirements;
}

/**
 * Implements hook_install().
 */
function mimemail_install() {
  $perm = explode(', ', db_result(db_query("SELECT perm FROM {permission} WHERE rid=%d", DRUPAL_AUTHENTICATED_RID)));
  $perm = implode(', ', array_merge($perm, array(
    'edit mimemail user settings',
  )));
  $record = array(
    'rid' => DRUPAL_AUTHENTICATED_RID,
    'perm' => $perm,
  );
  drupal_write_record('permission', $record, 'rid');
}

/**
 * Implements hook_disable().
 */
function mimemail_disable() {
  if (strpos(variable_get('smtp_library', ''), 'mimemail') !== FALSE) {
    variable_del('smtp_library');
  }
}

/**
 * Implements hook_uninstall().
 */
function mimemail_uninstall() {
  $variables = array(
    'mimemail_alter',
    'mimemail_crlf',
    'mimemail_engine',
    'mimemail_incoming',
    'mimemail_key',
    'mimemail_textonly',
    'mimemail_sitestyle',
    'mimemail_linkonly',
    'mimemail_preserve_class',
  );
  foreach ($variables as $variable) {
    variable_del($variable);
  }
}

/**
 * Implements hook_update_N().
 */
function mimemail_update_6100(&$sandbox) {
  $ret = array();
  $perm = explode(', ', db_result(db_query("SELECT perm FROM {permission} WHERE rid=%d", DRUPAL_AUTHENTICATED_RID)));
  $perm = implode(', ', array_merge($perm, array(
    'access profile settings',
  )));
  $record = array(
    'rid' => DRUPAL_AUTHENTICATED_RID,
    'perm' => $perm,
  );
  drupal_write_record('permission', $record, 'rid');
  return $ret;
}

/**
 * Generate new key for authenticating incoming messages.
 */
function mimemail_update_6101() {
  $ret = array();
  if (function_exists('drupal_random_key')) {
    variable_set('mimemail_key', drupal_random_key());
  }
  return $ret;
}

Functions

Namesort descending Description
mimemail_disable Implements hook_disable().
mimemail_install Implements hook_install().
mimemail_requirements Implements hook_requirements().
mimemail_uninstall Implements hook_uninstall().
mimemail_update_6100 Implements hook_update_N().
mimemail_update_6101 Generate new key for authenticating incoming messages.