forked from backdrop-contrib/mailsystem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mailsystem.install
64 lines (56 loc) · 2.19 KB
/
mailsystem.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* @file
* Mailsystem module install/schema hooks.
*/
/**
* Implements hook_requirements().
*/
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()['labels'];
$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;
}
/**
* Implements hook_uninstall().
*/
function mailsystem_uninstall() {
// Set mail system back to the default.
config_set('system.mail', 'default-system', 'DefaultMailSystem');
}
/**
* Migrate variables from Drupal 7 to Backdrop.
*/
function mailsystem_update_1000() {
// migrate variables
config_set('system.mail', 'default-system', update_variable_get('mail_system'), 'DefaultMailSystem');
config_set('mailsystem.settings', 'mailsystem_theme', update_variable_get('mailsystem_theme'), 'current');
// Delete variables.
update_variable_del('mail_system');
update_variable_del('mailsystem_theme');
}