You are here

function mailsystem_requirements in Mail System 7.3

Same name and namespace in other branches
  1. 6.2 mailsystem.install \mailsystem_requirements()

Implements hook_requirements().

File

./mailsystem.install, line 11
Contains install and update functions for mailsytem.

Code

function mailsystem_requirements($phase) {
  $requirements = array();

  // Ensure translations don't break at install time.
  $t = get_t();
  if ($phase == 'runtime') {
    $available_classes = mailsystem_get_classes();
    $settings = mailsystem_read_settings();

    // Collect missing classes by comparing the classes used in the settings to
    // the available ones.
    $missing_classes = array();
    foreach ($settings as $key => $setting) {
      foreach ($setting as $classname) {
        if (!isset($available_classes[$classname])) {
          $missing_classes[$classname] = $classname;
        }
      }
    }
    if (!empty($missing_classes)) {
      $requirements['mailsystem_classes'] = array(
        'title' => $t('Mailsystem'),
        'value' => $t('Missing mailsystem classes'),
        'description' => '<p>' . $t('The following classes are configured in your <code>mail_system</code> variable but they seem to be missing from your system. This will prevent sending email from your site and will lead to severe PHP errors. Please install and enable the modules providing the missing classes or fix your configuration by visiting the mailsystem <a href="!mailsystem_settings_link">settings</a> page.', array(
          '!mailsystem_settings_link' => url('admin/config/system/mailsystem'),
        )) . '</p>' . '<p>Missing classes</p>' . theme('item_list', array(
          'items' => $missing_classes,
        )),
        'severity' => REQUIREMENT_ERROR,
      );
    }
  }
  return $requirements;
}