mailsystem.module in Mail System 7
Same filename and directory in other branches
Provide UI for controlling the mail_system variable.
File
mailsystem.moduleView source
<?php
/**
* @file
* Provide UI for controlling the mail_system variable.
*/
/**
* Implements hook_menu().
*/
function mailsystem_menu() {
$items['admin/config/system/mailsystem'] = array(
'title' => 'Mail System',
'description' => 'Configure per-module Mail System settings.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'mailsystem_admin_settings',
),
'access arguments' => array(
'administer site configuration',
),
'file' => 'mailsystem.admin.inc',
);
return $items;
}
/**
* Returns the id for the default mail_system setting.
*/
function mailsystem_default_id() {
// @todo: Is there a way to get this from core?
return 'default-system';
}
/**
* Returns the value for the default mail_system setting.
*/
function mailsystem_default_value() {
// @todo: Is there a way to get this from core?
return 'DefaultMailSystem';
}
/**
* Returns the default settings for the mail_system variable.
*/
function mailsystem_defaults() {
return array(
mailsystem_default_id() => mailsystem_default_value(),
);
}
/**
* Returns the current mail_system settings.
*
* @return The contents of the mail_system variable merged with its defaults.
*/
function mailsystem_get() {
return array_merge(mailsystem_defaults(), variable_get('mail_system', mailsystem_defaults()));
}
/**
* Helps other modules safely set their own key within mail_system. This
* function should be called from hook_enable() implementations.
*
* @param $setting An associative array ($module => $classname) where $module
* will be using $classname to send its mail, and:
* - $module is the machine-readable module name.
* - $classname is a class that implements MailSystemInterface.
*/
function mailsystem_set(array $setting) {
variable_set('mail_system', array_merge(mailsystem_get(), $setting));
}
/**
* Helps other modules safely remove their settings from mail_system. This
* function should be called from the other module's hook_disable() function.
*
* @param $setting An associative array ($module => $classname) describing
* a module and associated MailSystemInterface class that are being disabled.
* - $module is the machine-readable module name.
* - $classname is a class that implements MailSystemInterface.
*
* If $classname is empty, only the $module entry is removed.
*
* @param $class
* The name of the class to be removed, if any.
*/
function mailsystem_clear(array $setting) {
variable_set('mail_system', array_merge(mailsystem_defaults(), array_diff_key(array_diff(mailsystem_get(), $setting), $setting)));
}
Functions
Name | Description |
---|---|
mailsystem_clear | Helps other modules safely remove their settings from mail_system. This function should be called from the other module's hook_disable() function. |
mailsystem_defaults | Returns the default settings for the mail_system variable. |
mailsystem_default_id | Returns the id for the default mail_system setting. |
mailsystem_default_value | Returns the value for the default mail_system setting. |
mailsystem_get | Returns the current mail_system settings. |
mailsystem_menu | Implements hook_menu(). |
mailsystem_set | Helps other modules safely set their own key within mail_system. This function should be called from hook_enable() implementations. |