-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgroups.install
More file actions
435 lines (394 loc) · 11.2 KB
/
groups.install
File metadata and controls
435 lines (394 loc) · 11.2 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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
<?php
/**
* @file
* Install, update and uninstall functions for the Groups install profile.
*/
/**
* Implements hook_requirements().
* Set minimum 'max_execution_time' requirement
*/
function groups_requirements($phase) {
$requirements = array();
// Ensure translations don't break during installation.
$t = get_t();
if($phase == 'install') {
// Test PHP minimum execution time
$requirements['php_max_execution_time'] = array(
'title' => $t('PHP Max Execution Time'),
'value' => ini_get('max_execution_time'),
);
$max_execution_time = (int)ini_get('max_execution_time');
// Don't set the error when max_execution_time is 0 (Infinite).
if ($max_execution_time && $max_execution_time < DRUPAL_MINIMUM_MAX_EXECUTION_TIME) {
$requirements['php_max_execution_time']['description'] = $t('Your PHP execution time is too low, please set it greater than or equal to %time seconds.', array('%time' => DRUPAL_MINIMUM_MAX_EXECUTION_TIME));
$requirements['php_max_execution_time']['severity'] = REQUIREMENT_ERROR;
}
}
return $requirements;
}
/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*
* @see system_install()
*/
function groups_install() {
// Enable the openstack_bootstrap theme and set it as the default.
theme_enable(array('adaptivetheme', 'adaptivetheme_admin', 'openstack', 'openstack_bootstrap'));
// The Bartik theme is automatically enabled during installation. Disable it.
db_update('system')
->fields(array('status' => 0))
->condition('type', 'theme')
->condition('name', 'bartik')
->execute();
// Set the default and administration themes.
variable_set('theme_default', 'openstack_bootstrap');
// Set a default administrative theme:
variable_set('admin_theme', 'adaptivetheme_admin');
variable_set('node_admin_theme', FALSE);
// Do not use the administration theme when editing or creating content.
variable_set('node_admin_theme', '0');
// Set a default user avatar.
groups_set_default_avatar();
// Create openstack.org menu item
$item = array(
'link_title' => st('OpenStack.org'),
'link_path' => 'http://openstack.org',
'menu_name' => 'main-menu',
'weight' => -5,
);
menu_link_save($item);
_groups_enable_default_languages();
_groups_add_language_selector_block();
// Create a default role for site administrators, with all available permissions assigned.
// $admin_role = new stdClass();
// $admin_role->name = 'administrator';
// $admin_role->weight = 2;
// user_role_save($admin_role);
// Set this as the administrator role.
variable_set('user_admin_role', $admin_role->rid);
// disable automatic cron run
variable_set('cron_safe_threshold', 0);
variable_set('elysia_cron_disabled', true);
// Assign user 1 the "administrator" role.
// db_insert('users_roles')
// ->fields(array('uid' => 1, 'rid' => $admin_role->rid))
// ->execute();
// AdaptiveTheme requires that the system theme settings form
// be submitted in order for its themes' settings to be properly set
// and the resulting css files generated.
// For more background, see http://drupal.org/node/1776730.
module_load_include('inc', 'system', 'system.admin');
foreach (array('adaptivetheme') as $theme_name) {
$form_state = form_state_defaults();
$form_state['build_info']['args'][0] = $theme_name;
$form_state['values'] = array();
drupal_form_submit('system_theme_settings', $form_state);
}
// add markdown filter format
_groups_add_markdown_filter();
}
/**
* Add language selector block to header region.
*
* @see groups_install()
*/
function _groups_add_language_selector_block() {
$block = array(
'module' => 'locale',
'delta' => 'language',
'theme' => 'openstack_bootstrap',
'visibility' => 0,
'region' => 'header',
'status' => 1,
'pages' => '',
'weight' => 2,
'title' => '<none>',
);
drupal_write_record('block', $block);
}
/**
* Enable default languages.
*/
function _groups_enable_default_languages() {
include_once DRUPAL_ROOT . '/includes/locale.inc';
include_once DRUPAL_ROOT . '/includes/iso.inc';
$default_languages = variable_get('groups_default_languages', 'hu,es,de,ru,zh-hans,ja,fi');
$languages = explode(',', $default_languages);
foreach ($languages as $langcode) {
locale_add_language($langcode);
}
}
/**
* Enable markdown module if it is not already enabled.
*/
function groups_update_7100() {
module_enable(array('markdown'));
if (!module_exists('markdown')) {
throw new DrupalUpdateException('The <a href="https://drupal.org/project/markdown">Markdown module</a> must be downloaded and available for groups updates to proceed.');
}
_groups_add_markdown_filter();
}
/**
* Enable feeds_jsonpath_parser module if it is not already enabled.
*/
function groups_update_7101() {
module_enable(array('feeds_jsonpath_parser'));
}
/**
* Enable groups_events_pages module if it is not already enabled.
*/
function groups_update_7102() {
module_enable(array('groups_events_pages'));
}
/**
* Enable commons_wikis module to fix missing og_group_ref
* fields from group contents.
*/
function groups_update_7103() {
if (!module_exists('commons_wikis')) {
module_enable(array('commons_wikis'));
drupal_flush_all_caches();
}
}
/**
* Switch default theme to "openstack_bootstrap"
*/
function groups_update_7105() {
theme_enable(array('openstack_bootstrap'));
variable_set('theme_default', 'openstack_bootstrap');
}
/**
* Enable groups_pages module.
*/
function groups_update_7104() {
if (!module_exists('groups_pages')) {
module_enable(array('groups_pages'));
drupal_flush_all_caches();
}
}
/**
* Fix groups update order issue.
* groups_pages module must be enabled after update #7105.
*/
function groups_update_7106() {
groups_update_7104();
}
/**
* Enable groups_events module.
*/
function groups_update_7107() {
if (!module_exists('groups_events')) {
module_enable(array('groups_events'));
drupal_flush_all_caches();
}
}
/**
* Enable groups_oauth2 modules.
*/
function groups_update_7108() {
if ((!module_exists('groups_oauth2')) && (!module_exists('groups_oauth2_picture'))) {
module_enable(array('groups_oauth2', 'groups_oauth2_picture'));
drupal_flush_all_caches();
}
}
/**
* Enable groups_comment module.
*/
function groups_update_7109() {
if ((!module_exists('groups_comment')) && (!module_exists('groups_comment'))) {
module_enable(array('groups_comment'));
drupal_flush_all_caches();
}
}
/**
* Disable commons_wiki module.
*/
function groups_update_7110() {
if (module_exists('commons_wiki')) {
module_disable(array('groups_comment'));
drupal_flush_all_caches();
}
}
/**
* Re-enable commons_wikis and enable groups_wikis module.
*/
function groups_update_7111() {
if (!module_exists('commons_wikis')) {
module_enable(array('commons_wikis'));
}
if (!module_exists('groups_wikis')) {
module_enable(array('groups_wikis'));
}
drupal_flush_all_caches();
}
/**
* Enable smtp module.
*/
function groups_update_7112() {
if (!module_exists('smtp')) {
module_enable(array('smtp'));
drupal_flush_all_caches();
}
}
/**
* Add language selector as a block and enable locale, l10n_update modules.
*/
function groups_update_7113() {
drupal_uninstall_schema('locale');
drupal_flush_all_caches();
module_enable(array('locale', 'l10n_update'));
module_disable(array('groups_language_switcher'));
_groups_add_language_selector_block();
_groups_enable_default_languages();
_groups_set_language_negotiation();
}
/**
* Enable elysia_cron module.
*/
function groups_update_7114() {
if (!module_exists('elysia_cron')) {
module_enable(array('elysia_cron'));
}
// remove job_scheduler's jobs
db_delete('job_schedule')->execute();
// disable automatic cron run
variable_set('cron_safe_threshold', 0);
variable_set('elysia_cron_disabled', true);
drupal_flush_all_caches();
}
/**
* Enable groups_reports module.
*/
function groups_update_7115() {
if (!module_exists('groups_reports')) {
module_enable(array('groups_reports'));
}
drupal_flush_all_caches();
}
/**
* Enable chartjs module.
*/
function groups_update_7116() {
if (!module_exists('chartjs')) {
module_enable(array('chartjs'));
}
drupal_flush_all_caches();
}
/**
* Enable groups ambassador modules.
*/
function groups_update_7117() {
if (!module_exists('groups_ambassador')) {
module_enable(array('groups_ambassador'));
}
if (!module_exists('groups_ambassador_pages')) {
module_enable(array('groups_ambassador_pages'));
}
drupal_flush_all_caches();
}
/**
* Enable groups social link module.
*/
function groups_update_7118() {
if (!module_exists('groups_social_link')) {
module_enable(array('groups_social_link'));
}
drupal_flush_all_caches();
}
/**
* Enable groups user profile module.
*/
function groups_update_7119() {
if (!module_exists('groups_user_profile')) {
module_enable(array('groups_user_profile'));
}
drupal_flush_all_caches();
}
/**
* Enable groups messages and privatemsg_notify_sender contrib module.
*/
function groups_update_7120() {
if (!module_exists('groups_messages')) {
module_enable(array('groups_messages'));
}
if (!module_exists('privatemsg_notify_sender')) {
module_enable(array('privatemsg_notify_sender'));
}
drupal_flush_all_caches();
}
/**
* Disable leaflet_more_maps module.
*
* The site no longer depends on this module, disabled now, so the entire
* module should be removed in a later version.
*/
function groups_update_7121() {
if (module_exists('leaflet_more_maps')) {
module_disable(array('leaflet_more_maps'));
drupal_flush_all_caches();
}
}
/**
* Enable tzfield module related to https://review.openstack.org/#/c/341385/
*/
function groups_update_7122() {
if (!module_exists('tzfield')) {
module_enable(array('tzfield'));
}
drupal_flush_all_caches();
}
/**
* Set language negotiation to URL based.
*/
function _groups_set_language_negotiation() {
require_once DRUPAL_ROOT . '/includes/language.inc';
require_once DRUPAL_ROOT . '/includes/locale.inc';
$negotiation = array(
LOCALE_LANGUAGE_NEGOTIATION_URL => 2,
LANGUAGE_NEGOTIATION_DEFAULT => 10,
);
language_negotiation_set(LANGUAGE_TYPE_INTERFACE, $negotiation);
}
/**
* Add markdown filter with permissions.
*/
function _groups_add_markdown_filter() {
// add markdown format filter
$markdown_format = array(
'format' => 'markdown',
'name' => 'Markdown',
'weight' => 1,
'filters' => array(
// Markdown filter.
'filter_markdown' => array(
'weight' => 0,
'status' => 1,
'settings' => array(),
),
// URL filter.
'filter_url' => array(
'weight' => 0,
'status' => 1,
),
),
);
$markdown_format = (object) $markdown_format;
filter_format_save($markdown_format);
// assign default permissions to filter
if ($roles = user_roles(FALSE)) {
$permissions = array('use text format markdown');
foreach ($roles as $rid => $name) {
$module = 'filter';
foreach ($permissions as $name) {
db_merge('role_permission')->key(array(
'rid' => $rid,
'permission' => $name,
))->fields(array(
'module' => $module,
))->execute();
}
}
}
}