This repository has been archived by the owner on Mar 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27
/
commons.install
850 lines (732 loc) · 27.1 KB
/
commons.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
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
<?php
/**
* @file
* Install, update and uninstall functions for the Commons install profile.
*/
/**
* Implements hook_install_tasks().
*/
function commons_install_tasks() {
$selected_extras = variable_get('commons_selected_extras', array());
return array(
'commons_installer_palette' => array(
'display_name' => st('Choose site color palette'),
'display' => TRUE,
'type' => 'form',
'function' => 'commons_installer_palette',
),
'commons_anonymous_message_homepage' => array(
'display_name' => st('Enter Homepage welcome text'),
'display' => TRUE,
'type' => 'form',
'function' => 'commons_anonymous_welcome_text_form'
),
'commons_revert_features' => array(
'display' => FALSE,
),
'commons_install_additional_modules' => array(
'display_name' => !empty($selected_extras['example_content']) ? st('Install example content') : st('Install additional functionality'),
'display' => FALSE,
'type' => 'batch',
),
'commons_create_first_group' => array(
'display_name' => st('Create the first group'),
'display' => TRUE,
'type' => 'form',
),
'commons_rebuild_node_access' => array(
'display' => FALSE,
'type' => 'batch',
'run' => !empty($selected_extras['og_access']) ? INSTALL_TASK_RUN_IF_NOT_COMPLETED : INSTALL_TASK_SKIP,
),
'commons_admin_permissions' => array(
'display' => FALSE,
),
);
}
/**
* Implements hook_install_tasks_alter().
*/
function commons_install_tasks_alter(&$tasks, $install_state) {
global $install_state;
$tasks['install_profile_modules']['display_name'] = st('Install Drupal Commons');
// Skip profile selection step.
$tasks['install_select_profile']['display'] = FALSE;
// Skip language selection install step and default language to English.
$tasks['install_select_locale']['display'] = FALSE;
$tasks['install_select_locale']['run'] = INSTALL_TASK_SKIP;
$install_state['parameters']['locale'] = 'en';
// Override "install_finished" task to redirect people to home page.
$tasks['install_finished']['function'] = 'commons_install_finished';
}
/**
* Override of install_finished() without the useless text.
*/
function commons_install_finished(&$install_state) {
drupal_set_title(st('@drupal installation complete', array('@drupal' => drupal_install_profile_distribution_name())), PASS_THROUGH);
$messages = drupal_set_message();
// Remember the profile which was used.
variable_set('install_profile', drupal_get_profile());
variable_set('install_task', 'done');
// BEGIN copy/paste from install_finished().
// Remove the bookmarks flag
$flag = flag_get_flag('bookmarks');
if($flag) {
$flag->delete();
$flag->disable();
_flag_clear_cache();
}
// Flush all caches to ensure that any full bootstraps during the installer
// do not leave stale cached data, and that any content types or other items
// registered by the installation profile are registered correctly.
drupal_flush_all_caches();
// We make custom code for the footer here because we want people to be able to freely edit it if they wish.
$footer_body = '<p>'. st('A Commons Community, powered by <a href="@acquia">Acquia</a>', array('@acquia' => url('https://www.acquia.com/products-services/drupal-commons-social-business-software'))) . '</p>';
$footer_block_text = array(
'body' => st($footer_body),
'info' => st('Default Footer'),
'format' => 'full_html',
);
if (drupal_write_record('block_custom', $footer_block_text)) {
$footer_block = array(
'module' => 'block',
'delta' => $footer_block_text['bid'],
'theme' => 'commons_origins',
'visibility' => 0,
'region' => 'footer',
'status' => 1,
'pages' => 0,
'weight' => 1,
'title' => variable_get('site_name', 'Drupal Commons'),
);
drupal_write_record('block', $footer_block);
}
// Installation profiles are always loaded last
db_update('system')
->fields(array('weight' => 1000))
->condition('type', 'module')
->condition('name', drupal_get_profile())
->execute();
// Cache a fully-built schema.
drupal_get_schema(NULL, TRUE);
// Run cron to populate update status tables (if available) so that users
// will be warned if they've installed an out of date Drupal version.
// Will also trigger indexing of profile-supplied content or feeds.
drupal_cron_run();
variable_set('title_node', array(
'auto_attach' => array('title' => 'title'),
'hide_label' => array('page' => 0, 'entity' => 0),
));
if (isset($messages['error'])) {
$output = '<p>' . (isset($messages['error']) ? st('Review the messages above before visiting <a href="@url">your new site</a>.', array('@url' => url(''))) : st('<a href="@url">Visit your new site</a>.', array('@url' => url('')))) . '</p>';
return $output;
}
else {
// Since any module can add a drupal_set_message, this can bug the user
// when we redirect him to the front page. For a better user experience,
// remove all the message that are only "notifications" message.
drupal_get_messages('status', TRUE);
drupal_get_messages('completed', TRUE);
// Migrate adds its messages under the wrong type, see #1659150.
drupal_get_messages('ok', TRUE);
// If we don't install drupal using Drush, redirect the user to the front
// page.
if (!drupal_is_cli()) {
drupal_goto('');
}
}
}
/**
* Allow users to select from a predefined list of color palettes during the
* commons installation.
*/
function commons_installer_palette() {
$form = array();
require_once(drupal_get_path('theme', 'commons_origins') . '/commons_origins.palettes.inc');
commons_origins_palettes_form($form);
$form['commons_origins_palette_fieldset']['#collapsible'] = FALSE;
$form['commons_origins_palette_fieldset']['#collapsed'] = FALSE;
$form['submit'] = array(
'#type' => 'submit',
'#value' => st('Save color palette'),
);
drupal_add_css('profiles/commons/commons_installer.css');
return $form;
}
/**
* Configuration form to set welcome text for the anonymous site homepage.
*/
function commons_anonymous_welcome_text_form() {
$form['commons_anonymous_welcome_explanation'] = array(
'#markup' => '<h2>' . st('Homepage welcome text') . '</h2>' . st("Below, enter text that will be shown on your community's homepage to help new visitors understand what your community is about and why they should join. The image below shows an example of how this text will appear. You can always change this text later."),
'#weight' => -1,
);
$form['commons_anonymous_welcome_example'] = array(
'#markup' => theme('image', array('path' => 'profiles/commons/images/commons_homepage_text_example.png', 'alt' => 'Home page example', 'alt' => 'Home page example')),
'#weight' => 0,
);
$form['commons_anonymous_welcome_title'] = array(
'#type' => 'textfield',
'#title' => st('Welcome headline'),
'#description' => st('A short description of the community that visitors can understand at a glance.'),
'#required' => TRUE,
'#default_value' => st('Welcome to our community'),
);
$form['commons_anonymous_welcome_body'] = array(
'#type' => 'textarea',
'#title' => st('Welcome body text'),
'#description' => st('Enter a couple of sentences elaborating about your community.'),
'#required' => TRUE,
'#default_value' => st('Share your thoughts, find answers to your questions.'),
);
$form['commons_install_example_content'] = array(
'#type' => 'checkbox',
'#title' => st('Install example content'),
'#description' => st('Install Commons with example content so that you can get a sense of what your site will look like once it becomes more active. Example content includes a group, a few users and content for that group. Example content can be modified or deleted like normal content.'),
'#default_value' => TRUE
);
$form['commons_enable_og_access'] = array(
'#type' => 'checkbox',
'#title' => st('Enable private group support'),
'#description' => st('Add the ability to create private groups. Content in private groups can only be accessed by group members. <strong>Warning: Enable only if you require the ability to create private groups; this setting has performance implications.</strong>'),
'#default_value' => FALSE,
);
$form['commons_anonymous_welcome_submit'] = array(
'#type' => 'submit',
'#value' => st('Save and continue')
);
return $form;
}
/**
* Save the configuration form for set welcome text for anonymous users.
* @see commons_anonymous_welcome_text_form()
*/
function commons_anonymous_welcome_text_form_submit($form_id, &$form_state) {
$selected_extras = variable_get('commons_selected_extras', array());
if ($form_state['values']['commons_enable_og_access']) {
$selected_extras['og_access'] = TRUE;
}
if ($form_state['values']['commons_install_example_content']) {
$selected_extras['example_content'] = TRUE;
}
variable_set('commons_selected_extras', $selected_extras);
variable_set('commons_anonymous_welcome_title', $form_state['values']['commons_anonymous_welcome_title']);
variable_set('commons_anonymous_welcome_body', $form_state['values']['commons_anonymous_welcome_body']);
}
/**
* Revert Features after the installation.
*/
function commons_revert_features() {
// Revert Features components to ensure that they are in their default states.
$revert = array(
'commons_follow' => array('field_base'),
'commons_groups' => array('field_instance', 'field_base'),
'commons_trusted_contacts' => array('field_instance', 'field_base'),
'commons_wikis' => array('og_features_permission'),
'commons_wysiwyg' => array('user_permission', 'ckeditor_profile'),
'commons_events' => array('og_features_permission' , 'field_base'),
'commons_polls' => array('og_features_permission'),
'commons_q_a' => array('og_features_permission', 'field_base'),
'commons_posts' => array('og_features_permission'),
'commons_misc' => array('variable'),
);
features_revert($revert);
}
/**
* Task callback: uses Batch API to enable modules based on user selection.
*
* Creates all demo content if requested and installs optional modules that
* providing additional functionality to the base install.
*/
function commons_install_additional_modules() {
$selected_extras = variable_get('commons_selected_extras', array());
$modules = array();
if (!empty($selected_extras['acquia_agent'])) {
$modules[] = 'acquia_agent';
}
if (!empty($selected_extras['acquia_search'])) {
$modules[] = 'acquia_search';
}
if (!empty($selected_extras['acquia_spi'])) {
$modules[] = 'acquia_spi';
}
if (!empty($selected_extras['og_access'])) {
$modules[] = 'og_access';
}
// Resolve the dependencies now, so that module_enable() doesn't need
// to do it later for each individual module (which kills performance).
$files = system_rebuild_module_data();
$modules_sorted = array();
foreach ($modules as $module) {
if ($files[$module]->requires) {
// Create a list of dependencies that haven't been installed yet.
$dependencies = array_keys($files[$module]->requires);
$dependencies = array_filter($dependencies, '_commons_filter_dependencies');
// Add them to the module list.
$modules = array_merge($modules, $dependencies);
}
}
$modules = array_unique($modules);
foreach ($modules as $module) {
$modules_sorted[$module] = $files[$module]->sort;
}
arsort($modules_sorted);
$operations = array();
// Enable the selected modules.
foreach ($modules_sorted as $module => $weight) {
$operations[] = array('_commons_enable_module', array($module, $files[$module]->info['name']));
}
// Create the example content.
if (!empty($selected_extras['example_content'])) {
// Create the demo users.
$operations[] = array('_commons_create_demo_users', array(t('Created demo users.')));
// Create the demo taxonomy terms.
$operations[] = array('_commons_create_demo_taxonomy_terms', array(t('Created taxonomy terms.')));
// Create the demo groups.
$operations[] = array('_commons_create_demo_groups', array(t('Created demo groups.')));
// Create the demo content.
$operations[] = array('_commons_create_demo_content', array(t('Created demo content.')));
}
// Convert the administrator into a group.
$operations[] = array('_commons_convert_administrator_to_group', array(t('Converted administrator into a group.')));
$batch = array(
'title' => !empty($selected_extras['example_content']) ? st('Installing example content') : st('Installing additional functionality'),
'operations' => $operations,
'file' => drupal_get_path('profile', 'commons') . '/commons.install_callbacks.inc',
);
return $batch;
}
/**
* array_filter() callback used to filter out already installed dependencies.
*/
function _commons_filter_dependencies($dependency) {
return !module_exists($dependency);
}
/**
* Let the admin user create the first group as part of the installation process.
*/
function commons_create_first_group() {
$form['commons_first_group_explanation'] = array(
'#markup' => '<h2>' . st('Create the first group in your new community.') . '</h2>' . st("Commons uses groups to collect community members and content related to a particular interest, working goal or geographic area."),
'#weight' => -1,
);
$form['commons_fist_group_example'] = array(
'#markup' => theme('image', array('path' => 'profiles/commons/images/commons_group_description_sample.png', 'alt' => 'Group description page example', 'alt' => 'Group description example')),
'#weight' => 0,
);
$form['commons_first_group_title'] = array(
'#type' => 'textfield',
'#title' => st("Group name"),
'#description' => st('For example: "Boston food lovers" or "Engineering team."'),
'#required' => TRUE,
'#default_value' => st('Engineering team'),
);
$form['commons_first_group_body'] = array(
'#type' => 'textarea',
'#title' => st('Group description'),
'#description' => st("This text will appear on the group's homepage and helps new contributors to become familiar with the purpose of the group. You can always change this text or add another group later."),
'#required' => TRUE,
'#default_value' => st('The online home for our Engineering team'),
);
$form['commons_first_group_submit'] = array(
'#type' => 'submit',
'#value' => st('Save and continue')
);
return $form;
}
/**
* Save the first group form.
*
* @see commons_create_first_group().
*/
function commons_create_first_group_submit($form_id, &$form_state) {
$values = $form_state['values'];
$first_group = new stdClass();
$first_group->type = 'group';
node_object_prepare($first_group);
$first_group->title = $values['commons_first_group_title'];
$first_group->body[LANGUAGE_NONE][0]['value'] = $values['commons_first_group_body'];
$first_group->uid = 1;
$first_group->language = LANGUAGE_NONE;
$first_group->status = 1;
node_save($first_group);
}
function commons_admin_permissions() {
//get the administrator role, we set this in the install file
$admin_role = user_role_load_by_name('administrator');
user_role_grant_permissions($admin_role->rid, array_keys(module_invoke_all('permission')));
}
function commons_add_user_avatar($account) {
global $base_url;
if ($account->uid) {
$picture_directory = file_default_scheme() . '://' . variable_get('user_picture_path', 'pictures');
if(file_prepare_directory($picture_directory, FILE_CREATE_DIRECTORY)){
$picture_result = drupal_http_request($base_url . '/profiles/commons/images/avatars/avatar-' . commons_normalize_name($account->name) . '.png');
$picture_path = file_stream_wrapper_uri_normalize($picture_directory . '/picture-' . $account->uid . '-' . REQUEST_TIME . '.jpg');
$picture_file = file_save_data($picture_result->data, $picture_path, FILE_EXISTS_REPLACE);
// Check to make sure the picture isn't too large for the site settings.
$validators = array(
'file_validate_is_image' => array(),
'file_validate_image_resolution' => array(variable_get('user_picture_dimensions', '85x85')),
'file_validate_size' => array(variable_get('user_picture_file_size', '30') * 1024),
);
// attach photo to user's account.
$errors = file_validate($picture_file, $validators);
if (empty($errors)) {
// Update the user record.
$picture_file->uid = $account->uid;
$picture_file = file_save($picture_file);
file_usage_add($picture_file, 'user', 'user', $account->uid);
db_update('users')
->fields(array(
'picture' => $picture_file->fid,
))
->condition('uid', $account->uid)
->execute();
$account->picture = $picture_file->fid;
}
}
}
}
/**
* This function rebuild node access.
*/
function commons_rebuild_node_access() {
// Copied from node_access_rebuild() which sets its own batch while we need to
// return a batch which will be automatically run by the installer.
$batch = array(
'title' => t('Rebuilding content access permissions'),
'operations' => array(
array('_node_access_rebuild_batch_operation', array()),
),
'finished' => '_node_access_rebuild_batch_finished',
);
return $batch;
}
/**
* Helper function to generate a machine name similar to the user's full name.
*/
function commons_normalize_name($name) {
return drupal_strtolower(str_replace(' ','_', $name));
}
/**
* Generate some filler content.
*/
function commons_veggie_ipsum() {
$content = "Veggies sunt bona vobis, proinde vos postulo esse magis spinach kale scallion lettuce cucumber black-eyed pea onion.
Bamboo shoot green bean wattle seed okra kakadu plum peanut ricebean celtuce. Azuki bean desert raisin bush tomato turnip peanut sweet pepper courgette horseradish. Garlic kombu beet greens celery courgette carrot mung bean.";
return $content;
}
/**
* Implements hook_install().
*/
function commons_install() {
// Enable the Origins theme and set it as the default.
theme_enable(array('commons_origins'));
// 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 Commons Origins as the default theme.
variable_set('theme_default', 'commons_origins');
// Set Ember as the administration theme.
variable_set('admin_theme', 'ember');
// Do not use the administration theme when editing or creating content.
variable_set('node_admin_theme', FALSE);
// Set jQuery version to 1.7
variable_set('jquery_update_jquery_version', '1.7');
// Set a default user avatar.
commons_set_default_avatar();
// Place site blocks in the menu_bar and header regions.
$menu_block = array(
'module' => 'system',
'delta' => 'main-menu',
'theme' => 'commons_origins',
'visibility' => 0,
'region' => 'menu_bar',
'status' => 1,
'pages' => '',
'title' => '<none>',
);
drupal_write_record('block', $menu_block);
$search_block = array(
'module' => 'search',
'delta' => 'form',
'theme' => 'commons_origins',
'visibility' => 0,
'region' => 'header',
'status' => 1,
'pages' => '',
'weight' => 2,
'title' => '<none>',
);
drupal_write_record('block', $search_block);
// 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');
$form_state = form_state_defaults();
$form_state['build_info']['args'][0] = 'commons_origins';
$form_state['values'] = array();
drupal_form_submit('system_theme_settings', $form_state);
}
/**
* Set a default user avatar as a managed file object.
*/
function commons_set_default_avatar() {
global $base_url;
$picture_directory = file_default_scheme() . '://' . variable_get('user_picture_path', 'pictures');
if(file_prepare_directory($picture_directory, FILE_CREATE_DIRECTORY)){
$picture_result = drupal_http_request($base_url . '/profiles/commons/images/avatars/user-avatar.png');
$picture_path = file_stream_wrapper_uri_normalize($picture_directory . '/picture-default.jpg');
$picture_file = file_save_data($picture_result->data, $picture_path, FILE_EXISTS_REPLACE);
// Check to make sure the picture isn't too large for the site settings.
$validators = array(
'file_validate_is_image' => array(),
'file_validate_image_resolution' => array(variable_get('user_picture_dimensions', '85x85')),
'file_validate_size' => array(variable_get('user_picture_file_size', '30') * 1024),
);
// attach photo to user's account.
$errors = file_validate($picture_file, $validators);
if (empty($errors)) {
// Update the user record.
$picture_file = file_save($picture_file);
variable_set('user_picture_default', $picture_path);
}
}
}
/**
* Enable the Origins theme and set it as the default. *
*/
function commons_update_3101() {
theme_enable(array('adaptivetheme_admin'));
variable_set('theme_default', 'commons_origins');
variable_set('node_admin_theme', FALSE);
return array();
}
/**
* Reset the default avatar if the associated file doesn't exist in the file_managed table.
*/
function commons_update_3102() {
$reset_avatar = FALSE;
$file = variable_get('user_picture_default', '');
if(!$file) {
$reset_avatar = TRUE;
}
if(!$reset_avatar) {
$results = db_select('file_managed', 'f')
->fields('f', array('fid'))
->condition('filename', $file,'=')
->execute()
->fetchAll();
if(count($results) === 0) {
$reset_avatar = TRUE;
}
}
if($reset_avatar) {
commons_set_default_avatar();
}
return array();
}
/**
* Replace the Toolbar module with the Navbar module.
*/
function commons_update_3103() {
// Enable the Navbar module and its dependencies.
$module_list = array('breakpoints', 'navbar');
module_enable($module_list);
// Migrate permissions.
if (module_exists('toolbar')) {
$roles = user_roles(FALSE, 'access toolbar');
if (!empty($roles)) {
// Set permissions.
foreach ($roles as $rid => $role) {
user_role_grant_permissions($rid, array('access navbar'));
}
}
}
// Disable the Toolbar module.
$module_list = array('toolbar');
module_disable($module_list);
return array();
}
/**
* Enable the Paranoia module.
*/
function commons_update_3104() {
$module_list = array('paranoia');
module_enable($module_list);
return array();
}
/**
* Enable the Placeholder module.
*/
function commons_update_3105() {
$module_list = array('placeholder');
module_enable($module_list);
return array();
}
/**
* Enable the Addressfield and Addressfield tokens module.
*/
function commons_update_3106() {
$module_list = array('addressfield', 'addressfield_tokens');
module_enable($module_list);
return array();
}
/**
* Rebuild the registry to accommodate Commons modules merging into the profile.
*/
function commons_update_3107() {
registry_rebuild();
}
/**
* Make the OG relationship required so that browsing widget
* tabs on the site homepage show an accurate count of content in each tab.
*/
function commons_update_3108() {
$revert = array(
'commons_posts' => array('views_view'),
'commons_documents' => array('views_view'),
'commons_polls' => array('views_view'),
'commons_wikis' => array('views_view'),
'commons_q_a' => array('views_view')
);
features_revert($revert);
return array();
}
/**
* Replace the Placeholder module with the Elements module.
*/
function commons_update_3109() {
if (module_exists('placeholder')) {
module_disable(array('placeholder'));
}
module_enable(array('elements'));
return array();
}
/**
* Change the administration theme to Ember.
*/
function commons_update_3111() {
variable_set('admin_theme', 'ember');
return array();
}
/**
* Revert Message types to use the correct title field token.
*/
function commons_update_3112() {
$revert = array(
'commons_wikis' => array('message_type'),
'commons_q_a' => array('message_type'),
'commons_posts' => array('message_type'),
'commons_notify' => array('message_type'),
'commons_like' => array('message_type'),
'commons_activity_streams' => array('message_type'),
);
features_revert($revert);
return array();
}
/**
* Delete the AdvancedQueue class variable for sites that did not uninstall AdvancedQueue.
*/
function commons_update_3113() {
if (variable_get('queue_default_class', '') == 'AdvancedQueue') {
variable_del('queue_default_class');
}
return array();
}
/**
* Automatically use field_title for all nodes instead of the node base title.
*/
function commons_update_3114() {
variable_set('title_node', array(
'auto_attach' => array('title' => 'title'),
'hide_label' => array('page' => 0, 'entity' => 0),
));
foreach (node_type_get_types() as $node_type) {
// Set the title as "Replaced by title_field".
if (!title_field_replacement_enabled('node', $node_type->type, 'title')) {
title_field_replacement_toggle('node', $node_type->type, 'title');
}
// Migrate the titles to the title field.
title_field_replacement_batch_set('node', $node_type->type, 'title');
}
drupal_flush_all_caches();
}
/**
* Replace the oEmbed module with the Media: oEmbed module.
*/
function commons_update_3115() {
if (module_exists('oembed')) {
module_disable(array('oembed'));
}
module_enable(array('media_oembed'));
return array();
}
/**
* Enable the Commons: Media and Media: WYSIWYG modules.
*/
function commons_update_3116() {
module_enable(array('commons_media', 'media_wysiwyg'));
return array();
}
/**
* Flush all caches to accommodate moved files and new hooks.
*/
function commons_update_3117() {
drupal_flush_all_caches();
return array();
}
/**
* Ensure commons radioactivity is enabled upon install.
*/
function commons_update_3118() {
module_enable(array('commons_radioactivity', 'commons_radioactivity_groups'));
return array();
}
/**
* Ensure install task is set to completed.
*/
function commons_update_3119() {
variable_set('install_task', 'done');
return array();
}
/**
* Begin to use the Entity Embed module for embedded media handling if
* Media: WYSIWYG integration is currently enabled.
*/
function commons_update_3120() {
if (module_exists('media_wysiwyg')) {
module_enable(array('entity_embed'));
// Set jQuery version to 1.7
variable_set('jquery_update_jquery_version', '1.7');
$revert = array(
'commons_wysiwyg' => array('ckeditor_profile', 'filter'),
);
features_revert($revert);
}
return array();
}
/**
* Enable the Dialog module which is a requirement for Entity Embed 2.x.
*/
function commons_update_3121() {
if (module_exists('entity_embed')) {
module_enable(array('dialog'));
}
return array();
}
/**
* Replace the CKEditor module with the Editor CKEditor module.
*/
function commons_update_3122() {
if (module_exists('ckeditor')) {
module_disable(array('ckeditor'));
}
module_enable(array('editor_ckeditor'));
return array();
}