-
Notifications
You must be signed in to change notification settings - Fork 4
/
openatrium.install
318 lines (285 loc) · 7.58 KB
/
openatrium.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
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
<?php
/**
* @file
* Perform actions to set up the site for this profile.
*/
/**
* Implements hook_install_tasks()
*/
function openatrium_install_tasks(&$install_state) {
$tasks = array();
// Add our custom CSS file for the installation process.
drupal_add_css(drupal_get_path('profile', 'openatrium') . '/openatrium.css');
require_once drupal_get_path('module', 'apps') . '/apps.profile.inc';
$server = array(
'machine name' => 'openatrium',
'default apps' => array(
// built-in apps.
'oa_discussion',
'oa_events',
'oa_wiki',
'oa_worktracker',
// Core addon apps.
'oa_admin',
'oa_appearance',
'oa_archive',
'oa_brand',
'oa_clone',
'oa_comment',
'oa_contextual_tabs',
'oa_events_import',
'oa_export',
'oa_favorites',
'oa_files',
'oa_home',
'oa_htmlmail',
'oa_media',
'oa_messages_digest',
'oa_notifications',
// Currently having problems with oa_project enabling during install
// So leave this off for now
// 'oa_project',.
'oa_related',
'oa_sandbox',
'oa_search',
'oa_sitemap',
'oa_site_layout',
'oa_site_layout_defaults',
'oa_styles',
'oa_subspaces',
'oa_toolbar',
'oa_tour',
'oa_tour_defaults',
'oa_wizard',
),
);
$tasks = apps_profile_install_tasks($install_state, $server);
$tasks['openatrium_features_revert_all'] = array(
'type' => 'normal',
);
// Set default permissions.
$tasks['openatrium_set_permissions'] = array(
'type' => 'normal',
);
// Need to rebuild search index tables since oa_search changes panopoly_search.
$tasks['openatrium_rebuild_search'] = array(
'type' => 'normal',
);
// Rebuild node access..
$tasks['openatrium_node_access_rebuild'] = array(
'type' => 'normal',
);
// Skip tasks if using quickstart.
if (!empty($install_state['parameters']['quickstart']) && $install_state['parameters']['quickstart'] == 'quick') {
foreach ($tasks as $task_name => $task) {
$tasks[$task_name]['run'] = INSTALL_TASK_SKIP;
}
}
/*** TASKS BELOW RUN EVEN WITH QUICKSTART ***/
// Revert bootstrap tour defaults.
$tasks['openatrium_revert_tours'] = array(
'type' => 'normal',
);
return $tasks;
}
/**
* Revert all features.
*/
function openatrium_features_revert_all() {
global $install_state;
drupal_set_time_limit(0);
features_revert(array(
'oa_core' => array('field_base'),
'oa_sections' => array('field_base', 'field_instance'),
'oa_users' => array('field_instance'),
));
features_revert();
}
/**
* Revert oa_tour_default feature.
*/
function openatrium_revert_tours() {
features_revert(array(
'oa_tour_defaults' => array('bootstrap_tour'),
));
}
/**
* Update permissions.
*/
function openatrium_set_permissions() {
// Update admin and member permissions.
oa_adminrole_update_roles();
}
/**
* Rebuild search index.
*/
function openatrium_rebuild_search() {
global $install_state;
require_once drupal_get_path('module', 'oa_search') . '/oa_search.install';
features_revert(array(
'oa_search' => array('search_api_index'),
));
oa_search_rebuild_index();
}
/**
* Wrapper around node access rebuild, as didn't work till I wrapped it.
*/
function openatrium_node_access_rebuild() {
node_access_rebuild();
openatrium_remove_message('Content permissions have been rebuilt');
}
/**
* Implements hook_install_tasks_alter()
*/
function openatrium_install_tasks_alter(&$tasks, $install_state) {
require_once drupal_get_path('module', 'oa_core') . '/oa_core.profile.inc';
$tasks['install_load_profile']['function'] = 'oa_core_install_load_profile';
// Add option for importing from db.
install_from_db_install_tasks_alter($tasks, $install_state);
}
/**
* Implements hook_form_FORM_ID_alter() for apps_profile_apps_select.
*/
function openatrium_form_apps_profile_apps_select_form_alter(&$form, $form_state) {
// Disabling showing of these for now.
$form['apps_message']['#access'] = FALSE;
unset($form['apps_fieldset']['apps']['#title']);
// Remove the demo content selection option since this is handled through the Panopoly demo module.
$form['default_content_fieldset']['#access'] = FALSE;
}
/**
* Implements hook_install().
*/
function openatrium_install() {
// Set the default theme.
_openatrium_set_up_theme();
// Put modules into contrib.
variable_set('apps_install_path', 'sites/all/modules/contrib');
}
/**
* Set the default theme.
*/
function _openatrium_set_up_theme() {
$theme = 'oa_theme';
theme_enable(array($theme));
variable_set('theme_default', $theme);
theme_disable(array('responsive_bartik', 'bartik', 'oa_radix'));
}
/**
* Implements hook_requirements().
*/
function openatrium_requirements($phase) {
// Cannot test during install time because menu is how test and can't use that.
$requirements = array();
// Ensure translations don't break during installation.
$t = get_t();
// Report Drupal version.
if ($phase == 'runtime') {
$available = FALSE;
if (strpos(request_uri(), '?q=') === FALSE && strpos(request_uri(), '&q=') === FALSE) {
$available = TRUE;
}
else {
$request = drupal_http_request($GLOBALS['base_url'] . '/admin/config/search/clean-urls/check');
// If the request returns HTTP 200, clean URLs are available.
if (isset($request->code) && $request->code == 200 && ($data = drupal_json_decode($request->data)) && !empty($data['status'])) {
$available = TRUE;
}
}
if (!$available) {
$requirements['clean_urls_available'] = array(
'title' => $t('Clean Urls Available'),
'value' => $t('Clean Urls is not available, but OpenAtrium requires it to function properly.'),
'severity' => REQUIREMENT_ERROR,
);
}
if ($phase == 'runtime' && !variable_get('clean_url', 0)) {
$requirements['clean_urls_enabled'] = array(
'title' => $t('Clean Urls Enabled'),
'value' => $t('Clean Urls are not enabled, but OpenAtrium requires it to function properly.'),
'severity' => REQUIREMENT_ERROR,
);
}
}
return $requirements;
}
/**
* Enable oa_variables module.
*/
function openatrium_update_7002() {
if (!module_exists('oa_variables') && !module_enable(array('oa_variables'))) {
trigger_error('Unable to enable oa_variables module. Please check for any missing dependencies.');
}
// This may be missing from older installs.
$missing = array(
'backports',
'date_popup_authored',
'simplified_menu_admin',
);
module_enable($missing);
// Ensure the install profile is enabled.
module_enable(array('openatrium'));
}
/**
* Enable oa_buttons.
*/
function openatrium_update_7003() {
$enable = array(
'oa_buttons',
);
module_enable($enable);
}
/**
* Enable trash_flag.
*/
function openatrium_update_7004() {
$enable = array(
'trash_flag',
);
module_enable($enable);
}
/**
* Enable command_buttons.
*/
function openatrium_update_7005() {
$enable = array(
'command_buttons',
);
module_enable($enable);
}
/**
* Enable date_all_day.
*/
function openatrium_update_7006() {
$enable = array(
'date_all_day',
);
module_enable($enable);
}
/**
* Enable panels_customerror.
*/
function openatrium_update_7007() {
$enable = array(
'panels_customerror',
);
module_enable($enable);
}
/**
* Enable oa_contextual_tabs.
*/
function openatrium_update_7008() {
$enable = array(
'oa_contextual_tabs',
);
module_enable($enable);
}
/**
* Enable oa_export.
*/
function openatrium_update_7009() {
$enable = array(
'oa_export',
);
module_enable($enable);
}