forked from easySuite/ding2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ding2.install
566 lines (491 loc) · 12.4 KB
/
ding2.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
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
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
<?php
/**
* @file
* Setup default theme, shortcuts, roles, language, search and features.
*/
/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*/
function ding2_install() {
// Set default variables.
$default_theme = 'ddbasic';
$admin_theme = 'seven';
$t = get_t();
//
// Disable all themes and only active default and admin themes.
//
db_update('system')
->fields(array('status' => 0))
->condition('type', 'theme')
->execute();
// Enable themes.
theme_enable(array($default_theme, $admin_theme));
// Enable $default_theme.
variable_set('theme_default', $default_theme);
// Enable $admin_theme.
variable_set('admin_theme', $admin_theme);
// Activate admin theme when editing a node.
variable_set('node_admin_theme', '1');
//
// Add shortcuts to the default set on install.
//
$shortcut_set = shortcut_set_load(SHORTCUT_DEFAULT_SET_NAME);
$shortcut_set->links = NULL;
$shortcut_set->links = array(
array(
'link_path' => 'admin/config/regional/translate',
'link_title' => $t('Translation'),
'weight' => -17,
),
array(
'link_path' => 'admin/appearance/settings/ddbasic',
'link_title' => $t('Theme settings'),
'weight' => -18,
),
array(
'link_path' => 'admin/config/user-interface/backgrounds',
'link_title' => $t('Backgrounds'),
'weight' => -19,
),
);
shortcut_set_save($shortcut_set);
// Set default source language for i18n module.
variable_set('i18n_string_source_language', 'en');
// Disable configurable timezones for users.
variable_set('configurable_timezones', 0);
// Select the ding_frontpage as front page.
variable_set('site_frontpage', 'ding_frontpage');
//
// Enable ting search as default.
//
$active_search = variable_get('search_active_modules', array());
$search_defaults = array(
'node' => 'node',
'ting_search' => 'ting_search',
'user' => 0,
'mkdru' => 'mkdru',
);
// Avoid overwriting other modules search settings.
// Search default has precedence
variable_set('search_active_modules', $search_defaults + $active_search);
variable_set('search_default_module', 'ting_search');
//
// Enable the panel pages for ting objects and search.
//
variable_set('ting_ting_object_disabled', FALSE);
variable_set('ting_ting_collection_disabled', FALSE);
variable_set('page_manager_search_disabled_ting_search', FALSE);
//
// Allow visitor account creation, but with administrative approval.
//
variable_set('user_register', USER_REGISTER_ADMINISTRATORS_ONLY);
// Submit theme settings.
variable_set('theme_' . $default_theme . '_settings', ding2_theme_settings());
ding_base_rewrite_color_stylesheet();
// Disable overlay.
if (module_exists('overlay')) {
module_disable(array('overlay'));
}
// Ignore any rebuild messages.
node_access_needs_rebuild(FALSE);
// Ignore any other install messages.
drupal_get_messages();
// Clear caches.
drupal_flush_all_caches();
}
/**
* Set default theme setting for ddbasic.
*
* @return array
* The default theme settings.
*/
function ding2_theme_settings() {
return array(
'toggle_logo' => 1,
'toggle_name' => 1,
'toggle_slogan' => 0,
'toggle_node_user_picture' => 0,
'toggle_comment_user_picture' => 0,
'toggle_comment_user_verification' => 1,
'toggle_favicon' => 1,
'toggle_main_menu' => 1,
'toggle_secondary_menu' => 1,
'default_logo' => 1,
'default_favicon' => 1,
'latto_classes_menu_leaf' => 1,
'latto_classes_menu_has_children' => 1,
'latto_classes_menu_items_mlid' => 1,
'main_menu_sticky' => 0,
'load_html5js' => 1,
'load_selectivizr' => 1,
'load_scalefixjs' => 1,
'load_equalize' => 1,
'libraries_check_all' => 0,
);
}
/**
* Update the database with the newest translations.
*/
function ding2_translation_update() {
// Update build-in translation group.
$file = new stdClass();
$file->uri = DRUPAL_ROOT . '/profiles/ding2/translations/da.po';
$file->filename = basename($file->uri);
_locale_import_po($file, 'da', LOCALE_IMPORT_KEEP, 'default');
// Update field translation group.
$file = new stdClass();
$file->uri = DRUPAL_ROOT . '/profiles/ding2/translations/fields_da.po';
$file->filename = basename($file->uri);
_locale_import_po($file, 'da', LOCALE_IMPORT_KEEP, 'field');
// Update metatag translation group.
$file = new stdClass();
$file->uri = DRUPAL_ROOT . '/profiles/ding2/translations/metatags_da.po';
$file->filename = basename($file->uri);
_locale_import_po($file, 'da', LOCALE_IMPORT_KEEP, 'metatag');
}
/**
* Delete {system} records for a module.
*
* This function is to be used when removing a module from the code-base. It's
* needed because uninstalling a module that don't exists in code is not
* possible.
*
* Remember to run the clean-up that the module had in it's hook_uninstall
* before calling this function.
*
* @see https://www.drupal.org/node/2487215
*/
function ding2_remove_module($module) {
db_delete('system')
->condition('name', $module)
->condition('type', 'module')
->execute();
}
/**
* Enable new shortcuts.
*/
function ding2_update_7000() {
$t = get_t();
$shortcut_set = shortcut_set_load(SHORTCUT_DEFAULT_SET_NAME);
$shortcut_set->links[] = array(
'link_path' => 'admin/appearance/settings/ddbasic',
'link_title' => $t('Theme settings'),
'weight' => -18,
);
$shortcut_set->links[] = array(
'link_path' => 'admin/config/user-interface/backgrounds',
'link_title' => $t('Backgrounds'),
'weight' => -19,
);
shortcut_set_save($shortcut_set);
return array();
}
/**
* Append default ddbasic theme settings.
*/
function ding2_update_7001() {
module_load_include('inc', 'system', 'system.admin');
$form_state = form_state_defaults();
$form_state['build_info']['args'][0] = 'ddbasic';
$form_state['values'] = array();
$form_state['values']['scheme'] = 'classic';
drupal_form_submit('system_theme_settings', $form_state);
}
/**
* Import our own translations.
*/
function ding2_update_7002() {
ding2_translation_update();
}
/**
* Enable and configure the cookie module.
*/
function ding2_update_7003() {
module_enable(array('cookiecontrol'));
ding2_set_cookie_page();
}
/**
* Update our own translations.
*/
function ding2_update_7004() {
// Fixed month translation.
ding2_translation_update();
}
/**
* Enable and configure SSL proxy variables.
*/
function ding2_update_7005() {
module_enable(array('sslproxy'), TRUE);
variable_set('sslproxy_var', 'X-FORWARDED-PROTO');
variable_set('sslproxy_var_value', 'https');
}
/**
* Add "administrators" role to admin user.
*/
function ding2_update_7006() {
ding2_add_administrators_role(1);
}
/**
* Update our own translations.
*/
function ding2_update_7007() {
// Fixed month translation.
ding2_translation_update();
}
/**
* Enable view unpublished module.
*/
function ding2_update_7008() {
module_enable(array('view_unpublished'), TRUE);
}
/**
* Enable redirect module.
*/
function ding2_update_7009() {
module_enable(array('redirect'));
}
/**
* Disable the cookiecontrol module.
* Enable and configure the eu-cookie-compliance module.
*/
function ding2_update_7010() {
if (module_exists('cookiecontrol')) {
module_disable(array('cookiecontrol'));
drupal_uninstall_modules(array('cookiecontrol'));
variable_del('cookiecontrol_privacynode');
variable_del('cookiecontrol_text');
variable_del('cookiecontrol_fulltext');
}
module_enable(array('eu_cookie_compliance'));
ding2_set_cookie_page();
if (module_exists('secure_permissions')) {
secure_permissions_build_permissions();
}
}
/**
* Enable maintenance_mode_api module.
*/
function ding2_update_7011() {
module_enable(array('maintenance_mode_api'));
}
/**
* Update the eu-cookie-compliance Danish "No thanks" text to "Læs mere".
*/
function ding2_update_7012() {
$eu_cookie_compliance_da = variable_get('eu_cookie_compliance_da');
$eu_cookie_compliance_da['popup_disagree_button_message'] = 'Læs mere';
variable_set('eu_cookie_compliance_da', $eu_cookie_compliance_da);
}
/**
* Update our own translations.
*/
function ding2_update_7013() {
ding2_translation_update();
}
/**
* Enable pagepreview module.
*/
function ding2_update_7014() {
module_enable(array('pagepreview'));
}
/**
* Enable search_api modules.
*/
function ding2_update_7015() {
module_enable(array('search_api', 'search_api_multi', 'search_api_db', 'search_api_views'));
}
/**
* Update our own translations.
*/
function ding2_update_7016() {
ding2_translation_update();
}
/**
* Update our own translations.
*/
function ding2_update_7017() {
ding2_translation_update();
}
/**
* Update our own translations.
*/
function ding2_update_7018() {
ding2_translation_update();
}
/**
* Disable overlay.
*/
function ding2_update_7019() {
if (module_exists('overlay')) {
module_disable(array('overlay'));
}
}
/**
* Enable metatag and metatag_panels modules.
*/
function ding2_update_7020() {
module_enable(array('metatag', 'metatag_panels'));
}
/**
* Disable ding_bookmark module.
*/
function ding2_update_7021() {
module_disable(array('ding_bookmark'));
}
/**
* Enable P2 installer module.
*/
function ding2_update_7022() {
module_enable(array('ding_p2_installer'));
}
/**
* Enable admin_menu modules.
*/
function ding2_update_7023() {
module_enable(array('admin_menu', 'admin_menu_toolbar'));
}
/**
* Enable htmlmail module.
*/
function ding2_update_7024() {
module_enable(array('htmlmail'));
}
/**
* Enable environment indicator panel modules.
*/
function ding2_update_7025() {
if (module_exists('ddb_cp')) {
module_enable(array('environment_indicator'));
}
}
/**
* Enable mmeu module.
*/
function ding2_update_7026() {
module_enable(array('mmeu'));
}
/**
* Enable lazy_pane module.
*/
function ding2_update_7027() {
module_enable(array('lazy_pane'));
}
/**
* Update our own translations.
*/
function ding2_update_7028() {
ding2_translation_update();
}
/**
* Update our own translations.
*/
function ding2_update_7029() {
ding2_translation_update();
}
/**
* Update our own translations.
*/
function ding2_update_7030() {
ding2_translation_update();
}
/**
* Update our own translations.
*/
function ding2_update_7031() {
ding2_translation_update();
}
/**
* Enable Campaign module.
*/
function ding2_update_7032() {
module_enable(array('ding_campaign'));
}
/**
* Enable Mobilesearch module.
*/
function ding2_update_7034() {
module_enable(array('ding_mobilesearch'));
}
/**
* Set default variables for MobileSearch.
*/
function ding2_update_7035() {
$default_mobilesearch_agencyid = variable_get('ting_agency');
$mobilesearch_rest_key = variable_get('mobilesearch_rest_key', NULL);
variable_set('mobilesearch_rest_url', 'https://cmscontent.dbc.dk/');
variable_set('mobilesearch_rest_agency_id', $default_mobilesearch_agencyid);
if (empty($mobilesearch_rest_key)) {
variable_set('mobilesearch_rest_key', $default_mobilesearch_agencyid . "DDBCMS");
}
}
/**
* Update our own translations.
*/
function ding2_update_7036() {
ding2_translation_update();
}
/**
* Update our own translations.
*/
function ding2_update_7037() {
ding2_translation_update();
}
/**
* Update our own translations.
*/
function ding2_update_7038() {
ding2_translation_update();
}
/**
* Enable E-resource module.
*/
function ding2_update_7039() {
module_enable(array('ding_eresource'));
}
/**
* Update our own translations.
*/
function ding2_update_7040() {
ding2_translation_update();
}
/**
* Delete {system} records for ting_carousel modules.
*/
function ding2_update_7041() {
ding2_remove_module('ting_carousel');
}
/**
* Enable the ding_ddbasic module.
*/
function ding2_update_7042() {
module_enable(array('ding_ddbasic', 'ding_ddbasic_opening_hours'));
}
/**
* Update our own translations.
*/
function ding2_update_7043() {
ding2_translation_update();
}
/**
* Activate toggle_name theme setting
*/
function ding2_update_7044() {
$default_theme = variable_get('theme_default', 'ddbasic');
$theme_settings = variable_get('theme_' . $default_theme . '_settings');
$theme_settings['toggle_name'] = 1;
variable_set('theme_' . $default_theme . '_settings', $theme_settings);
}
/**
* Disable toolbar module.
*/
function ding2_update_7045() {
module_disable(array('toolbar'));
}
/**
* Update our own translations.
*/
function ding2_update_7046() {
ding2_translation_update();
}