You are here

function htmlmail_requirements in HTML Mail 6.2

Same name and namespace in other branches
  1. 7.2 htmlmail.install \htmlmail_requirements()

Implements hook_requirements().

Ensures that the autoload and mailsystem modules are available, and that HTML Mail uses its own MailSystemInterface class.

1 call to htmlmail_requirements()
htmlmail_update_6204 in ./htmlmail.install
Implements hook_update_N().

File

./htmlmail.install, line 14
Installation for HTML Mail module.

Code

function htmlmail_requirements($phase) {
  $result = array();
  if ($phase === 'install') {
    return $result;
  }
  if (module_exists('autoload') && module_load_include('inc', 'mailsystem', 'html_to_text') !== FALSE) {
    return $result;
  }
  $args = array(
    '%autoload' => 'Autoload',
    '!autoload' => 'http://drupal.org/project/autoload',
    '%htmlmail' => 'HTML Mail',
    '!htmlmail' => 'http://drupal.org/project/htmlmail',
    '%mailsystem' => 'Mail System',
    '!mailsystem' => 'http://drupal.org/project/mailsystem',
  );
  if (!module_exists('autoload')) {
    if (module_enable(array(
      'autoload',
    )) && module_load_include('module', 'autoload')) {
      autoload_boot();
      autoload_registry_rebuild();
      drupal_set_message(t('The %autoload module has been enabled because the %htmlmail module now requires it.', $args));
      return $result;
    }
    $result['htmlmail_autoload'] = array(
      'title' => t('%autoload module', $args),
      'value' => t('Not installed'),
      'description' => t('The <a href="!htmlmail">%htmlmail</a> module dependencies have changed.  Please download and install the required <a href="!autoload">%autoload</a> module, then re-enable the <a href="!htmlmail">%htmlmail</a> module.', $args),
      'severity' => REQUIREMENT_ERROR,
    );
  }
  if (!function_exists('mailsystem_html_to_text')) {
    $result['htmlmail_mailsystem'] = array(
      'title' => t('%mailsystem module', $args),
      'value' => t('6.x-1.x'),
      'description' => t('<a href="!htmlmail">%htmlmail</a> new requires <a href="!mailsystem">%mailsystem</a> 6.x-2.6 or later.  Please download and install a recent version of <a href+"!mailsystem">%mailsystem</a>, then re-enable the <a href="!htmlmail">%htmlmail</a> module.', $args),
      'severity' => REQUIREMENT_ERROR,
    );
  }
  return $result;
}