-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathrte_mis.install
More file actions
319 lines (289 loc) · 7.6 KB
/
rte_mis.install
File metadata and controls
319 lines (289 loc) · 7.6 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
<?php
/**
* @file
* Provide hook_install() / hook_uninstall() and hook_update_N() functions.
*/
use Drupal\Core\Form\FormState;
use Drupal\rte_mis_core\Helper\ConfigManager;
use Drupal\user\Entity\Role;
/**
* Implements hook_install().
*/
function rte_mis_install() {
// Import the menus when the site is installed.
// For menu export, importing the menu is required.
$form_state = (new FormState())->setValues([]);
// Calling the submit handler and submitting the form.
\Drupal::formBuilder()->submitForm('Drupal\menu_export\Form\MenuImportForm', $form_state);
$role_id = 'state_admin';
$permissions = [
'view users with role school',
'view users with role school_admin',
];
// Load the role entity.
$role = Role::load($role_id);
if ($role) {
// Grant each permission to the role.
foreach ($permissions as $permission) {
$role->grantPermission($permission);
}
// Save the role entity to apply the changes.
$role->save();
}
else {
\Drupal::logger('my_profile')->error('The role @role_id does not exist.', ['@role_id' => $role_id]);
}
}
/**
* Implements hook_update_N().
*
* Updated the about us page URL for the two column block.
*/
function rte_mis_update_10001() {
$manager = \Drupal::service('rte_mis_core.manager');
$manager->updateConfigs(
['block.block.gin_twocolumnblock'],
'rte_mis',
'install',
ConfigManager::MODE_REPLACE,
);
}
/**
* Implements hook_update_N().
*
* This hook is used to install the rte_mis_logs module and it's related config.
*/
function rte_mis_update_10002() {
// The name of the module to install.
$module_name = 'rte_mis_logs';
// Check if the module is already installed.
if (!\Drupal::moduleHandler()->moduleExists($module_name)) {
// Enable the module.
\Drupal::service('module_installer')->install([$module_name]);
\Drupal::messenger()->addStatus(t('The %module module has been installed.', ['%module' => $module_name]));
}
else {
\Drupal::messenger()->addWarning(t('The %module module is already installed.', ['%module' => $module_name]));
}
$manager = \Drupal::service('rte_mis_core.manager');
$manager->updateConfigs(
[
'gin_toolbar_custom_menu.settings',
'user.role.state_admin',
],
'rte_mis',
'install',
ConfigManager::MODE_REPLACE,
);
}
/**
* Implements hook_update_N().
*
* This update hook will update the student tracking dashboard view.
*/
function rte_mis_update_10003() {
$manager = \Drupal::service('rte_mis_core.manager');
$manager->updateConfigs(
['views.view.student_tracking_dashboard'],
'rte_mis',
'install',
ConfigManager::MODE_REPLACE,
);
}
/**
* Implements hook_update_N().
*
* Add student tracking related configs.
*/
function rte_mis_update_10004() {
$manager = \Drupal::service('rte_mis_core.manager');
$manager->updateConfigs(
[
'user.role.anonymous',
'user.role.authenticated',
'user.role.block_admin',
'user.role.district_admin',
'user.role.school',
'user.role.school_admin',
'user.role.state_admin',
],
'rte_mis',
'install',
ConfigManager::MODE_REPLACE,
);
}
/**
* Implements hook_update_N().
*
* Add student name field in student tracking dashboard view.
*/
function rte_mis_update_10005() {
$manager = \Drupal::service('rte_mis_core.manager');
$manager->updateConfigs(
[
'views.view.student_tracking_dashboard',
],
'rte_mis',
'install',
ConfigManager::MODE_REPLACE,
);
}
/**
* Implements hook_update_N().
*
* This hook is used to install the rte_mis_reimbursement module.
*/
function rte_mis_update_10006() {
// The name of the module to install.
$module_name = 'rte_mis_reimbursement';
// Check if the module is already installed.
if (!\Drupal::moduleHandler()->moduleExists($module_name)) {
// Enable the module.
\Drupal::service('module_installer')->install([$module_name]);
\Drupal::messenger()->addStatus(t('The %module module has been installed.', ['%module' => $module_name]));
}
else {
\Drupal::messenger()->addWarning(t('The %module module is already installed.', ['%module' => $module_name]));
}
}
/**
* Deleted the allotted student and mapped habitation views.
*/
function rte_mis_update_10007() {
$views_config = ['views.view.allotted_student', 'views.view.mapped_habitation'];
foreach ($views_config as $config) {
\Drupal::configFactory()->getEditable($config)->delete();
}
}
/**
* Add student name field in student tracking dashboard view.
*/
function rte_mis_update_10008() {
$manager = \Drupal::service('rte_mis_core.manager');
$manager->updateConfigs(
[
'views.view.lottery_results',
],
'rte_mis',
'install',
ConfigManager::MODE_REPLACE,
);
}
/**
* Add student name field in student tracking dashboard view.
*/
function rte_mis_update_10009() {
$manager = \Drupal::service('rte_mis_core.manager');
$manager->updateConfigs(
[
'views.view.student_applications',
],
'rte_mis',
'install',
ConfigManager::MODE_REPLACE,
);
}
/**
* Implements hook_update_N().
*
* Add administer reimbursement permission to state admin role.
*/
function rte_mis_update_10010() {
$manager = \Drupal::service('rte_mis_core.manager');
$manager->updateConfigs(
[
'user.role.state_admin',
],
'rte_mis',
'install',
ConfigManager::MODE_REPLACE,
);
}
/**
* Implements hook_update_N().
*
* Add administer reimbursement permission to state admin role.
*/
function rte_mis_update_10011() {
$manager = \Drupal::service('rte_mis_core.manager');
$manager->updateConfigs(
[
'user.role.anonymous',
'user.role.authenticated',
'user.role.block_admin',
'user.role.district_admin',
'user.role.school',
'user.role.school_admin',
'user.role.state_admin',
'views.view.reimbursement_claim',
],
'rte_mis',
'install',
ConfigManager::MODE_REPLACE,
);
}
/**
* Implements hook_update_N().
*
* Add URL alias pattern for reimbursement mini node.
*/
function rte_mis_update_10012() {
$manager = \Drupal::service('rte_mis_core.manager');
$manager->updateConfigs(
['pathauto.pattern.school_claim_alias'],
'rte_mis',
'install',
ConfigManager::MODE_REPLACE,
);
}
/**
* Implements hook_update_N().
*
* Update student tracking dashboard view.
*/
function rte_mis_update_10013() {
$manager = \Drupal::service('rte_mis_core.manager');
$manager->updateConfigs(
['views.view.student_tracking_dashboard'],
'rte_mis',
'install',
ConfigManager::MODE_REPLACE,
);
}
/**
* Implements hook_update_N().
*
* Add access school information reports permission to state,district
* and blocks admins.
*/
function rte_mis_update_10014() {
$manager = \Drupal::service('rte_mis_core.manager');
$manager->updateConfigs(
[
'user.role.state_admin',
'user.role.district_admin',
'user.role.block_admin',
],
'rte_mis',
'install',
ConfigManager::MODE_REPLACE,
);
}
/**
* Implements hook_update_N().
*
* This hook is used to install the rte_mis_reimbursement module.
*/
function rte_mis_update_10015() {
// The name of the module to install.
$module_name = 'views_ajax_history';
// Check if the module is already installed.
if (!\Drupal::moduleHandler()->moduleExists($module_name)) {
// Enable the module.
\Drupal::service('module_installer')->install([$module_name]);
\Drupal::messenger()->addStatus(t('The %module module has been installed.', ['%module' => $module_name]));
}
else {
\Drupal::messenger()->addWarning(t('The %module module is already installed.', ['%module' => $module_name]));
}
}