You are here

function mailsystem_set in Mail System 6.2

Same name and namespace in other branches
  1. 8 mailsystem.module \mailsystem_set()
  2. 8.2 mailsystem.module \mailsystem_set()
  3. 6 mailsystem.module \mailsystem_set()
  4. 7.3 mailsystem.module \mailsystem_set()
  5. 7 mailsystem.module \mailsystem_set()
  6. 7.2 mailsystem.module \mailsystem_set()

Helps other modules safely set their own key within mail_system. This function should be called from hook_enable() implementations.

Parameters

$setting An associative array ($id => $value) where::

  • $id is the machine-readable module name optionally followed by '_' and a key.
  • $value is one of
    • (string) The name of a class that implements MailSystemInterface.
    • (array) An associative array whose keys are the names of methods defined by MailSystemInterface and whose values are the names of the class to use for that method.

See also

drupal_mail(), mailsystem_default_methods()

File

./mailsystem.module, line 205
Provide UI for controlling the mail_system variable.

Code

function mailsystem_set(array $setting) {
  $mail_system = mailsystem_get();
  foreach ($setting as $key => $class) {
    if (is_array($class)) {
      unset($setting[$key]);
      if ($new_class = mailsystem_create_class($class)) {
        $setting[$key] = $new_class;
      }
    }
  }
  variable_set('mail_system', array_merge(mailsystem_get(), $setting));
}