diff --git a/mailsystem.module b/mailsystem.module index c8a02c7..c87a0ef 100644 --- a/mailsystem.module +++ b/mailsystem.module @@ -426,3 +426,21 @@ function mailsystem_get_mail_theme() { } return $theme; } + +/** + * Implements hook_system_info_alter(). + * + * Prevent the module from being disabled while the mail_system variable is + * still using the MailsystemDelegateMailSystem class. + */ +function mailsystem_system_info_alter(&$info, $file, $type) { + if ($type == 'module' && $file->name == 'mailsystem') { + $mail_system = mailsystem_get(); + foreach ($mail_system as $key => $class) { + if ($class == 'MailsystemDelegateMailSystem') { + $info['required'] = TRUE; + $info['explanation'] = t('Mail System cannot be disabled until each custom setting on its configure page is either removed, or uses the same class for both its formatting and delivery class.', array('@url' => url('admin/config/system/mailsystem'))); + } + } + } +}