-
Notifications
You must be signed in to change notification settings - Fork 1
/
readonlymode.install
48 lines (43 loc) · 1.59 KB
/
readonlymode.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
<?php
/**
* @file
* Update hook and uninstaller for the Read Only Mode module
*/
/**
* Implements hook_install().
*/
function readonlymode_install() {
// Set our weight so that we execute last, to avoid other modules
// adding to forms after we clear them out.
module_set_weight('readonlymode', 9999);
}
/**
* Implements hook_uninstall().
*/
function readonlymode_uninstall() {
state_del('site_readonly');
}
/**
* Implements hook_update_N().
*
* Move Read Only Mode settings from variable to config.
*/
function readonlymode_update_1000() {
// Migrate site_readonly variable to state.
state_set('site_readonly', update_variable_get('site_readonly', FALSE));
// Migrate all other variables to config.
$config = config('readonlymode.settings');
$config->set('site_readonly_forms_allowed', update_variable_get('site_readonly_forms_allowed', ''));
$config->set('site_readonly_forms_viewonly', update_variable_get('site_readonly_forms_viewonly', ''));
$config->set('site_readonly_message_form_not_saved', update_variable_get('site_readonly_message_form_not_saved', ''));
$config->set('site_readonly_message', update_variable_get('site_readonly_message', ''));
$config->set('site_readonly_url', update_variable_get('site_readonly_url', ''));
$config->save();
// Delete all variables.
update_variable_del('site_readonly');
update_variable_del('site_readonly_forms_allowed');
update_variable_del('site_readonly_forms_viewonly');
update_variable_del('site_readonly_message_form_not_saved');
update_variable_del('site_readonly_message');
update_variable_del('site_readonly_url');
}