-
Notifications
You must be signed in to change notification settings - Fork 4
/
content_lock.install
103 lines (96 loc) · 3.61 KB
/
content_lock.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
<?php
/**
* @file
* Install file.
*/
/**
* Implements hook_install().
*
* Enable the 'check out documents' permission for authenticated users
* by default since this is the most common use-case.
*/
function content_lock_install() {
user_role_grant_permissions(BACKDROP_AUTHENTICATED_ROLE, array('check out documents'));
// Dynamically generated variable data was detected on the following lines.
}
/**
* Implements hook_uninstall().
*/
function content_lock_uninstall() {
config_clear('content_lock.settings', 'content_lock_clear');
config_clear('content_lock.settings', 'content_lock_unload_js');
config_clear('content_lock.settings', 'content_lock_unload_js_message');
config_clear('content_lock.settings', 'content_lock_unload_js_message_enable');
config_clear('content_lock.settings', 'content_lock_admin_cancelbutton');
config_clear('content_lock.settings', 'content_lock_admin_verbose');
config_clear('content_lock.settings', 'content_lock_allowed_node_types');
config_clear('content_lock.settings', 'content_lock_allowed_formats');
}
/**
* Implements hook_schema().
*/
function content_lock_schema() {
$schema['content_lock'] = array(
'description' => 'content lock module table.',
'fields' => array(
'nid' => array(
'description' => 'The primary identifier for a node.',
'type' => 'int',
'size' => 'normal',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'uid' => array(
'description' => 'User that holds the lock.',
'type' => 'int',
'size' => 'normal',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'timestamp' => array(
'description' => 'Time the lock occurred.',
'size' => 'normal',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'ajax_key' => array(
'description' => 'A key which AJAX requests must prevent to prevent page reloads from breaking.',
'size' => 'normal',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
),
'indexes' => array(
'user' => array('uid'),
),
'primary key' => array('nid'),
);
return $schema;
}
/**
* Migrate content_lock variables to config.
*/
function content_lock_update_1000() {
$config = config('content_lock.settings');
$config->set('content_lock_unload_js', update_variable_get('content_lock_unload_js', TRUE));
$config->set('content_lock_unload_js_message_enable', update_variable_get('content_lock_unload_js_message_enable', TRUE));
$config->set('content_lock_unload_js_message', update_variable_get('content_lock_unload_js_message', 'If you proceed, ALL of your changes will be lost.'));
$config->set('content_lock_admin_verbose', update_variable_get('content_lock_admin_verbose', TRUE));
$config->set('content_lock_admin_cancelbutton', update_variable_get('content_lock_admin_cancelbutton', TRUE));
$config->set('content_lock_allowed_node_types', update_variable_get('content_lock_allowed_node_types', array()));
$config->set('content_lock_allowed_formats', update_variable_get('content_lock_allowed_formats', array()));
$config->save();
update_variable_del('content_lock_unload_js');
update_variable_del('content_lock_unload_js_message_enable');
update_variable_del('content_lock_unload_js_message');
update_variable_del('content_lock_admin_verbose');
update_variable_del('content_lock_admin_cancelbutton');
update_variable_del('content_lock_allowed_node_types');
update_variable_del('content_lock_allowed_formats');
}