-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmasquerade.install
112 lines (102 loc) · 3.07 KB
/
masquerade.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
<?php
/**
* @file
* masquerade.install
*
* Install, uninstall and update hooks for the Masquarade module.
*/
/**
* Implements hook_schema().
*
* @return array
*/
function masquerade_schema() {
return array(
'masquerade' => array(
'description' => 'Each masquerading user has their session recorded into the masquerade table. Each record represents a masquerading user.',
'fields' => array(
'sid' => array(
'description' => 'The current session for this masquerading user corresponding to their {sessions}.sid.',
'type' => 'varchar',
'length' => '64',
'not null' => TRUE,
'default' => ''),
'uid_from' => array(
'description' => 'The {users}.uid corresponding to a session.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'disp-width' => '10'),
'uid_as' => array(
'description' => 'The {users}.uid this session is masquerading as.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'disp-width' => '10'),
),
'indexes' => array(
'sid' => array('sid', 'uid_from'),
'sid_2' => array('sid', 'uid_as'),
),
),
'masquerade_users' => array(
'description' => 'Per-user permission table granting permissions to switch as a specific user.',
'fields' => array(
'uid_from' => array(
'description' => 'The {users}.uid that can masquerade as {masquerade_users}.uid_to.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'disp-width' => 10,
),
'uid_to' => array(
'description' => 'The {users}.uid that {masquerade_users}.uid_from can masquerade as.',
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'disp-width' => 10,
),
),
'primary key' => array('uid_from', 'uid_to'),
),
);
}
/**
* Implements hook_install().
*/
function masquerade_install() {
db_update('system')
->fields(array('weight' => -10))
->condition('name', 'masquerade')
->execute();
}
/**
* Implements hook_update_last_removed().
*/
function masquerade_update_last_removed() {
return 7001;
}
/**
* @defgroup updates-7.x-to-1.x Updates from 7.x to 1.x
* @{
* Update functions from Drupal 7.x to Backdrop CMS 1.x.
*/
/**
* Move masquerade settings from variables to config.
*/
function masquerade_update_1000() {
// Migrate variables to config.
$config = config('masquerade.settings');
$config->set('test_user', update_variable_get('masquerade_test_user', ''));
$config->set('admin_roles', update_variable_get('masquerade_admin_roles', array()));
$config->set('quick_switches', update_variable_get('masquerade_quick_switches', array()));
$config->save();
// Delete variables.
update_variable_del('masquerade_test_user');
update_variable_del('masquerade_admin_roles');
update_variable_del('masquerade_quick_switches');
}
/*
* @} End of "defgroup updates-7.x-to-1.x"
* The next series of updates should start at 2000.
*/