forked from Roomify/rooms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrooms.install
More file actions
100 lines (92 loc) · 2.54 KB
/
Copy pathrooms.install
File metadata and controls
100 lines (92 loc) · 2.54 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
<?php
/**
* @file
* Install, update and uninstall functions for the rooms module.
*/
/**
* Implements hook_field_schema().
*/
function rooms_field_schema($field) {
if ($field['type'] == 'rooms_options') {
return array(
'columns' => array(
'name' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'quantity' => array(
'type' => 'int',
'not null' => FALSE,
),
'operation' => array(
'type' => 'varchar',
'length' => 255,
'not null' => FALSE,
),
'value' => array(
'type' => 'int',
'not null' => FALSE,
),
),
);
}
}
/**
* Implements hook_requirements().
*/
function rooms_requirements($phase) {
$requirements = array();
$t = get_t();
switch ($phase) {
case 'runtime':
if (!rooms_fullcalendar_loaded()) {
$requirements['Rooms FullCalendar Library'] = array(
'title' => $t('Rooms FullCalendar'),
'description' => $t('Could not load the FullCalendar Library'),
'value' => 'FullCalendar Missing',
'severity' => REQUIREMENT_ERROR,
);
}
else {
$requirements['Rooms FullCalendar Library'] = array(
'title' => $t('Rooms FullCalendar'),
'description' => $t('The FullCalendar Library is installed'),
'value' => 'FullCalendar Installed',
'severity' => REQUIREMENT_OK,
);
}
}
return $requirements;
}
/**
* Utility function: rename a set of permissions.
*/
function rooms_update_rename_permissions($map) {
// Easy part: rename the permissions in {role_permission}.
foreach ($map as $old_name => $new_name) {
db_update('role_permission')
->fields(array('permission' => $new_name))
->condition('permission', $old_name)
->execute();
}
// Trickier: rename the permission for the in-database Views.
foreach (views_get_all_views() as $view) {
if ($view->type == t('Default')) {
continue;
}
$save_view = FALSE;
foreach ($view->display as $display_name => $display) {
if (!empty($display->display_options['access']['type']) && $display->display_options['access']['type'] == 'perm') {
$permission_name = $display->display_options['access']['perm'];
if (isset($map[$permission_name])) {
$display->display_options['access']['perm'] = $map[$permission_name];
$save_view = TRUE;
}
}
}
if ($save_view) {
$view->save();
}
}
}