You are here

function mailsystem_set_module_weight in Mail System 6.2

Ensure that mailsystem has a higher module weight than any other module implementing hook_mail_alter().

1 call to mailsystem_set_module_weight()
mailsystem_requirements in ./mailsystem.install
Implements hook_requirements(). Ensures that the newly-required autoload module is available, or else disables the mailsystem module and returns an informative error message.

File

./mailsystem.install, line 14
Sets/deletes the 'smtp_library' variable as mailsystem is enabled/disabled.

Code

function mailsystem_set_module_weight() {
  $modules = array_diff(module_implements('mail_alter'), array(
    'mailsystem',
  ));
  $query = db_query("SELECT MAX(weight) FROM {system} WHERE name IN ('" . implode("', '", $modules) . "') AND type = 'module'");
  $max = db_result($query);
  $max = $max + 1;
  $query = db_query("UPDATE {system} SET weight = {$max} WHERE name = 'mailsystem' AND type = 'module' and weight < {$max}");
}