-
Notifications
You must be signed in to change notification settings - Fork 0
/
email_verify.install
142 lines (124 loc) · 5.15 KB
/
email_verify.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<?php
/**
* @file
* Install, update and uninstall functions for this module.
*/
/**
* Implements hook_install().
*/
function email_verify_install() {
db_update('system')
->fields(array('weight' => 100))
->condition('name', 'email_verify', '=')
->execute();
$t = get_t();
$link = l($t('settings page'), 'admin/config/system/email_verify');
$message = $t('The Email Verify module has been installed. Before it can be used, it must be activated and configured on the !adminpage.', array('!adminpage' => $link));
backdrop_set_message($message);
}
/**
* Implements hook_disable().
*/
function email_verify_disable() {
$active = config_get('email_verify.settings', 'email_verify_active');
if ($active) {
config_set('email_verify.settings', 'email_verify_active', FALSE);
}
}
/**
* Implements hook_update_last_removed().
*/
function email_verify_update_last_removed() {
// Only require latest 1.x update.
return 7100;
}
/**
* Repeat D7's 2.x updates for sites coming from 1.x.
*/
function email_verify_update_1000() {
/*******************************************************************************
* The following updates were included in the 2.x branch of the Drupal module.
* Because the majority of sites were runing 1.x we also include them here.
******************************************************************************/
$config = config('email_verify.settings');
// Set the weight of this module as high as reasonable, so that its form_alter
// hook gets called after other modules.
db_update('system')
->fields(array('weight' => 100))
->condition('name', 'email_verify', '=')
->execute();
// Pull the old variable, if available.
$forms = explode(', mail\n', update_variable_get('email_verify_forms'));
// Pull the new config, if available.
$forms_config = config_get('email_verify.settings', 'email_verify_forms');
// Combine all forms. if empty, check for individual form variables.
if ($forms_config != NULL) {
$forms = array_merge($forms_config, $forms);
}
if (empty($forms)) {
// The user registration form.
$user_registration = update_variable_get('email_verify_user_registration');
if (!empty($user_registration)) {
$forms[] = "user_register_form, mail\n";
update_variable_del('email_verify_user_registration');
}
// The user profile form.
$user_profile = update_variable_get('email_verify_user_profile');
if (!empty($user_profile)) {
$forms[] = "user_profile_form, mail\n";
update_variable_del('email_verify_user_profile');
}
// The site-wide contact form.
$site_contact = update_variable_get('email_verify_site_contact');
if (!empty($site_contact)) {
$forms[] = "contact_site_form, mail\n";
update_variable_del('email_verify_site_contact');
}
// The personal contact form.
$personal_contact = update_variable_get('email_verify_personal_contact');
if (!empty($personal_contact)) {
$forms[] = "contact_personal_form, mail\n";
update_variable_del('email_verify_personal_contact');
}
$forms_config = implode($forms, "\n");
config_set('email_verify.settings', 'email_verify_forms', $forms_config);
update_variable_del('email_verify_forms');
}
}
/**
* Convert variables to config.
*/
function email_verify_update_1001() {
// Convert all other variables to config.
$config = config('email_verify.settings');
// Skip 'email_verify_forms' since we handled that in the previous update.
$config->set('email_verify_active', update_variable_get('email_verify_active', FALSE));
$config->set('users_to_display', update_variable_get('email_verify_users_to_display', array()));
$config->set('skip_mailbox', update_variable_get('email_verify_active', FALSE));
// Methods.
$config->set('methods_checkdnsrr', update_variable_get('email_verify_methods_checkdnsrr', 1));
$config->set('methods_gethostbyname', update_variable_get('email_verify_methods_gethostbyname', 1));
$config->set('methods_add_dot', update_variable_get('email_verify_methods_add_dot', 1));
$config->set('methods_extra_chars', update_variable_get('email_verify_methods_extra_chars', 1));
// Test options.
$config->set('test_options_host_name',
update_variable_get('email_verify_test_options_host_name', 'backdropcms.org'));
$config->set('test_options_port_number',
update_variable_get('email_verify_test_options_port_number', 25));
$config->set('test_options_timeout',
update_variable_get('email_verify_test_options_timeout', 15));
// Debug mode.
$config->set('debug_mode',
update_variable_get('email_verify_debug_mode', FALSE));
$config->set('debug_mode_date_format',
update_variable_get('email_verify_debug_mode_date_format', 'long'));
$config->set('debug_mode_record_log',
update_variable_get('email_verify_debug_mode_record_log', FALSE));
$config->set('debug_mode_display_page',
update_variable_get('email_verify_debug_mode_display_page', FALSE));
$config->save();
update_variable_del('email_verify_forms');
update_variable_del('email_verify_test_options_host_name');
update_variable_del('email_verify_debug_mode_record_log');
update_variable_del('email_verify_debug_mode_display_page');
}