-
Notifications
You must be signed in to change notification settings - Fork 7
/
nexteuropa_newsroom.install
659 lines (590 loc) · 24.7 KB
/
nexteuropa_newsroom.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
<?php
/**
* @file
* Install, update and uninstall functions for the nexteuropa_newsroom module.
*
* @see https://webgate.ec.europa.eu
* /CITnet/confluence/display/nexteuropa/Custom+features
*/
include_once 'nexteuropa_newsroom.install.inc';
/**
* Implements hook_enable().
*/
function nexteuropa_newsroom_enable() {
drupal_set_message(t('Newsroom feature is now active on your site.'));
if (!db_table_exists(NEXTEUROPA_NEWSROOM_CACHE_TABLE)) {
db_create_table(NEXTEUROPA_NEWSROOM_CACHE_TABLE, drupal_get_schema_unprocessed('system', 'cache'));
}
if (module_exists('multisite_drupal_toolbox')) {
// Add to solR.
multisite_drupal_toolbox_config_solr_bundle(NEXTEUROPA_NEWSROOM_CONTENT_TYPE, 'add');
}
}
/**
* Implements hook_disable().
*/
function nexteuropa_newsroom_disable() {
drupal_set_message(t('Newsroom feature is now inactive on your site.'));
if (db_table_exists(NEXTEUROPA_NEWSROOM_CACHE_TABLE)) {
db_drop_table(NEXTEUROPA_NEWSROOM_CACHE_TABLE);
}
if (module_exists('multisite_drupal_toolbox')) {
// Delete from solR.
multisite_drupal_toolbox_config_solr_bundle(NEXTEUROPA_NEWSROOM_CONTENT_TYPE, 'delete');
}
}
/**
* Implements hook_install().
*/
function nexteuropa_newsroom_install() {
$t = get_t();
variable_set('nexteuropa_newsroom_agenda_after_highlights', 1);
variable_set('nexteuropa_newsroom_display_highlights_begin', 1);
variable_set('nexteuropa_newsroom_base_url', NEXTEUROPA_NEWSROOM_BASE_URL);
variable_set('nexteuropa_newsroom_item_import_script', NEXTEUROPA_NEWSROOM_ITEM_SCRIPT);
variable_set('nexteuropa_newsroom_newsletter_import_script', NEXTEUROPA_NEWSROOM_NEWSLETTER_SCRIPT);
variable_set('nexteuropa_newsroom_single_item_import_segment', NEXTEUROPA_NEWSROOM_ITEM_SEGMENT);
variable_set('nexteuropa_newsroom_topic_import_script', NEXTEUROPA_NEWSROOM_TOPIC_SCRIPT);
variable_set('nexteuropa_newsroom_single_topic_import_segment', NEXTEUROPA_NEWSROOM_TOPIC_SEGMENT);
variable_set('nexteuropa_newsroom_type_import_script', NEXTEUROPA_NEWSROOM_TYPE_SCRIPT);
variable_set('nexteuropa_newsroom_single_type_import_segment', NEXTEUROPA_NEWSROOM_TYPE_SEGMENT);
variable_set('nexteuropa_newsroom_service_import_script', NEXTEUROPA_NEWSROOM_TOPIC_SCRIPT);
variable_set('nexteuropa_newsroom_single_service_import_segment', NEXTEUROPA_NEWSROOM_SERVICE_SEGMENT);
variable_set('nexteuropa_newsroom_summary_block_num_items', 3);
variable_set('nexteuropa_newsroom_summary_block_num_highlighted_items', 3);
variable_set('nexteuropa_newsroom_summary_home_block_num_agenda', 3);
variable_set('nexteuropa_newsroom_summary_home_block_num_items', 3);
variable_set('nexteuropa_newsroom_summary_home_block_num_highlighted_items', 3);
variable_set('nexteuropa_newsroom_display_agenda', 1);
variable_set('nexteuropa_newsroom_agenda_after_highlights', 1);
variable_set('nexteuropa_newsroom_display_highlights_begin', 1);
variable_set('nexteuropa_newsroom_order_by_last_update', 1);
variable_set('nexteuropa_newsroom_proposal_script', NEXTEUROPA_NEWSROOM_PROPOSAL_SCRIPT);
variable_set('nexteuropa_newsroom_docsroom_url', 'https://ec.europa.eu/docsroom/documents/');
variable_set('nexteuropa_newsroom_central_newsletter_title', $t('Central newsletters'));
variable_set('nexteuropa_newsroom_other_newsletter_title', $t('Other newsletters'));
variable_set('nexteuropa_newsroom_days_number_for_new_user', 14);
variable_set('nexteuropa_newsroom_allowed_ips', '127.0.0.1,158.167.165.192,158.167.165.191,158.167.209.222,158.167.210.159,158.167.210.158,158.167.239.142,158.167.236.249');
variable_set('nexteuropa_newsroom_use_css', 1);
variable_set('nexteuropa_newsroom_patterns', FALSE);
// Cache time variables in seconds.
variable_set('nexteuropa_newsroom_ct_agenda_result', 3000);
variable_set('nexteuropa_newsroom_ct_agenda_block', 180);
variable_set('nexteuropa_newsroom_ct_agenda_build', 3600);
variable_set('nexteuropa_newsroom_ct_current_items', 3600);
variable_set('nexteuropa_newsroom_ct_result_topics', 86400);
variable_set('nexteuropa_newsroom_ct_upcoming_date', 3600);
variable_set('nexteuropa_newsroom_ct_previous_date', 3600);
variable_set('nexteuropa_newsroom_ct_summary_block', 3600);
variable_set('nexteuropa_newsroom_ct_get_menu_by_path', 86400);
variable_set('nexteuropa_newsroom_ct_get_topic_entities', 3600);
variable_set('nexteuropa_newsroom_ct_fetch_active_menu', 3600);
variable_set('nexteuropa_newsroom_ct_term_from_request', 864000);
variable_set('nexteuropa_newsroom_ct_node_related_to_topic', 3600);
variable_set('nexteuropa_newsroom_ct_page_result_topics', 3600);
variable_set('nexteuropa_newsroom_ct_type_featured_item', 300);
variable_set('nexteuropa_newsroom_ct_summary_filter', 3600);
variable_set('nexteuropa_newsroom_ct_node_relative_items', 86400);
variable_set('nexteuropa_newsroom_agenda_page_items_number', 10);
variable_set('nexteuropa_newsroom_page_items_number', 10);
// Set node options for newsroom_item.
variable_set('node_preview_newsroom_item', 0);
variable_set('node_submitted_newsroom_item', 0);
variable_set('comment_newsroom_item', COMMENT_NODE_CLOSED);
variable_set('node_preview_newsroom_newsletter_item', 0);
variable_set('node_submitted_newsroom_newsletter_item', 0);
variable_set('comment_newsroom_newsletter_item', COMMENT_NODE_CLOSED);
variable_set('nexteuropa_newsroom_use_default_view_mode', 0);
variable_set('nexteuropa_newsroom_redirect_short_items', 0);
// Body field is locked and an instance is always created, we want
// to remove it.
if ($instance = field_info_instance('node', 'body', 'newsroom_newsletter_issue')) {
field_delete_instance($instance, TRUE);
}
// Enable some settings regarding multilingualism.
_nexteuropa_newsroom_enable_translations();
}
/**
* Implements hook_uninstall().
*/
function nexteuropa_newsroom_uninstall() {
variable_del('nexteuropa_newsroom_agenda_after_highlights');
variable_del('nexteuropa_newsroom_display_highlights_begin');
variable_del('nexteuropa_newsroom_base_url');
variable_del('nexteuropa_newsroom_item_import_script');
variable_del('nexteuropa_newsroom_single_item_import_segment');
variable_del('nexteuropa_newsroom_topic_import_script');
variable_del('nexteuropa_newsroom_single_topic_import_segment');
variable_del('nexteuropa_newsroom_type_import_script');
variable_del('nexteuropa_newsroom_single_type_import_segment');
variable_del('nexteuropa_newsroom_service_import_script');
variable_del('nexteuropa_newsroom_single_service_import_segment');
variable_del('nexteuropa_newsroom_single_item_edit_segment');
variable_del('nexteuropa_newsroom_summary_block_num_items');
variable_del('nexteuropa_newsroom_summary_block_num_highlighted_items');
variable_del('nexteuropa_newsroom_summary_home_block_num_agenda');
variable_del('nexteuropa_newsroom_summary_home_block_num_items');
variable_del('nexteuropa_newsroom_summary_home_block_num_highlighted_items');
variable_del('nexteuropa_node_preview_newsroom_item');
variable_del('nexteuropa_node_submitted_newsroom_item');
variable_del('nexteuropa_comment_newsroom_item');
variable_del('nexteuropa_newsroom_universe_id');
variable_del('nexteuropa_newsroom_proposal_script');
variable_del('nexteuropa_newsroom_app');
variable_del('nexteuropa_newsroom_app_key');
variable_del('nexteuropa_newsroom_subscription_url');
variable_del('nexteuropa_newsroom_subsite');
variable_del('nexteuropa_newsroom_docsroom_url');
variable_del('nexteuropa_newsroom_central_newsletter_title');
variable_del('nexteuropa_newsroom_other_newsletter_title');
variable_del('nexteuropa_newsroom_days_number_for_new_user');
variable_del('nexteuropa_newsroom_allowed_ips');
variable_del('nexteuropa_newsroom_ct_agenda_result');
variable_del('nexteuropa_newsroom_ct_agenda_result');
variable_del('nexteuropa_newsroom_ct_agenda_block');
variable_del('nexteuropa_newsroom_ct_agenda_build');
variable_del('nexteuropa_newsroom_ct_current_items');
variable_del('nexteuropa_newsroom_ct_result_topics');
variable_del('nexteuropa_newsroom_ct_upcoming_date');
variable_del('nexteuropa_newsroom_ct_previous_date');
variable_del('nexteuropa_newsroom_ct_summary_block');
variable_del('nexteuropa_newsroom_ct_get_menu_by_path');
variable_del('nexteuropa_newsroom_ct_get_topic_entities');
variable_del('nexteuropa_newsroom_ct_fetch_active_menu');
variable_del('nexteuropa_newsroom_ct_term_from_request');
variable_del('nexteuropa_newsroom_ct_node_related_to_topic');
variable_del('nexteuropa_newsroom_ct_page_result_topics');
variable_del('nexteuropa_newsroom_ct_type_featured_item');
variable_del('nexteuropa_newsroom_ct_summary_filter');
variable_del('nexteuropa_newsroom_ct_node_relative_items');
variable_del('nexteuropa_newsroom_agenda_page_items_number');
variable_del('nexteuropa_newsroom_page_items_number');
variable_del('nexteuropa_newsroom_use_default_view_mode');
variable_del('nexteuropa_newsroom_redirect_short_items');
}
/**
* Set universe ID from previous variable.
*/
function nexteuropa_newsroom_update_7101() {
if ($newsroom_universe_root = variable_get('newsroom_universe_root', FALSE)) {
$universe_id = array_pop(explode('/', trim($newsroom_universe_root, '/')));
variable_set('nexteuropa_newsroom_universe_id', $universe_id);
variable_del('newsroom_universe_root');
}
}
/**
* Remove obsolete importer content types and nodes.
*/
function nexteuropa_newsroom_update_7102() {
$types = [
'newsroom_type_importer',
'newsroom_service_importer',
'newsroom_topic_importer',
'newsroom_delete_item_importer',
'newsroom_item_importer',
];
// Delete types.
foreach ($types as $type) {
// Release content type previously featurized.
db_update('field_config')->fields(['custom' => 1, 'locked' => 0])->condition('type', $type)->execute();
// Delete content type.
node_type_delete($type);
}
// Update feeds_item table to avoid import of the items again
// Drop ID of the importer content types.
db_update('feeds_item')
->fields(['feed_nid' => 0])
->condition('id', [
'newsroom_items',
'newsroom_services',
'newsroom_topics',
'newsroom_type',
], 'IN')->execute();
}
/**
* Fix imported term GUIDs to avoid "wrong parents".
*/
function nexteuropa_newsroom_update_7103() {
db_update('feeds_item')
->expression('guid', 'CONCAT(:newstring, guid)', [':newstring' => 'newsroom_topic-'])
->condition('id', 'newsroom_topics')
->execute();
db_update('feeds_item')
->expression('guid', 'CONCAT(:newstring, guid)', [':newstring' => 'newsroom_type-'])
->condition('id', 'newsroom_type')
->execute();
}
/**
* Migrate data from shared teaser to newsroom teaser.
*/
function nexteuropa_newsroom_update_7104() {
_nexteuropa_newsroom_rename_field('field_shared_teaser', 'field_newsroom_teaser');
if ($instance = field_info_instance('node', 'field_shared_teaser', 'newsroom_item')) {
field_delete_instance($instance);
}
}
/**
* Remove obsolete from newsroom selection content type.
*/
function nexteuropa_newsroom_update_7105() {
field_delete_field('field_bp_newsroom_country');
field_delete_field('field_bp_newsroom_co_operator');
field_delete_field('field_bp_newsroom_actions');
field_delete_field('field_bp_newsroom_ac_operator');
field_purge_batch(1000);
return t('The following fields have been deleted from your db:
field_bp_newsroom_country,
field_bp_newsroom_co_operator,
field_bp_newsroom_actions,
field_bp_newsroom_ac_operator
');
}
/**
* Remove obsolete from newsroom selection content type.
*/
function nexteuropa_newsroom_update_7106() {
field_delete_field('field_selected_categories');
field_delete_field('field_newsroom_category');
field_purge_batch(1000);
return t('The following fields have been deleted from your db:
field_newsroom_category,
field_selected_categories');
}
/**
* Change the datetime to timestamp.
*/
function nexteuropa_newsroom_update_7107() {
$module_name = 'nexteuropa_newsroom';
// Get db fields instances of content type.
$fields_instances = field_info_instances('node', NEXTEUROPA_NEWSROOM_CONTENT_TYPE);
// Get feature fields config&instance.
module_load_include('inc', $module_name, $module_name . '.features.field_base');
if (function_exists($module_name . '_field_default_field_bases')) {
$fields_features_info = call_user_func($module_name . '_field_default_field_bases');
}
// Migration.
foreach ($fields_instances as $field_name => $field_instance) {
// Get db field config.
$field_info = field_info_field($field_name);
// Get feature field config.
$field_features_info = NULL;
if (!empty($fields_features_info['node-' . NEXTEUROPA_NEWSROOM_CONTENT_TYPE . '-' . $field_name])) {
$field_features_info = $fields_features_info['node-' . NEXTEUROPA_NEWSROOM_CONTENT_TYPE . '-' . $field_name]['field_config'];
}
// Update only our fields defines to 'datestamp' in feature.field.
if (in_array($field_info['type'], ['datetime', 'date']) && $fields_features_info[$field_name]['type'] == 'datestamp') {
foreach ($field_info['storage']['details']['sql'] as $info_sql) {
$table_name = array_shift(array_keys($info_sql));
foreach ($info_sql[$table_name] as $column_name) {
if (field_has_data($field_info)) {
// There is data: migrate data and update column to int.
watchdog('system', sprintf('Update the column %s of table %s : migrate datas and update to datestamp.', $column_name, $table_name), NULL, WATCHDOG_WARNING);
// Create a temporary date field.
$param = ['type' => 'int', 'not null' => FALSE, 'default' => 0];
db_add_field($table_name, $column_name . '_temp', $param);
db_update($table_name)
->expression($column_name . '_temp', "UNIX_TIMESTAMP($column_name)")
->execute();
// Delete old column.
db_drop_field($table_name, $column_name);
db_change_field($table_name, $column_name . '_temp', $column_name, ['type' => 'int']);
}
else {
// If there is no data: just update column to int.
watchdog('system', sprintf('Update the column %s of table %s : update to datestamp.', $column_name, $table_name), NULL, WATCHDOG_WARNING);
db_change_field($table_name, $column_name, $column_name, ['type' => 'int']);
}
}
}
watchdog('system', sprintf('Saving field config of %s', $field_name), NULL, WATCHDOG_INFO);
db_update('field_config')->fields(['type' => 'datestamp'])->condition('id', $field_info['id'])->execute();
// Error logs.
}
elseif ($field_info['type'] == 'datestamp') {
watchdog('system', sprintf('Field %s has been already converted to UNIX timestamp""', $field_name), NULL, WATCHDOG_WARNING);
}
elseif ($field_info['type'] == 'datetime') {
$filename = $module_name . '.features.features.field_base.inc';
if (!$field_features_info) {
watchdog('system', sprintf('Field %s not found in %s', $field_name, $filename), NULL, WATCHDOG_WARNING);
}
elseif ($field_features_info['type'] != 'datestamp') {
watchdog('system', sprintf('Field %s is not a datestamp in %s', $field_name, $filename), NULL, WATCHDOG_WARNING);
}
}
}
field_cache_clear();
}
/**
* Rename the fields to the same standards.
*/
function nexteuropa_newsroom_update_7108() {
$fields = [];
$fields['field_associated_newsroom_select'] = 'field_newsroom_associated_select';
$fields['field_associated_newsroom_topic'] = 'field_newsroom_associated_topic';
$fields['field_eur_lex_link'] = 'field_newsroom_eur_lex_link';
$fields['field_highlighted_newsroom_topic'] = 'field_newsroom_highlighted_topic';
$fields['field_illustrative_image'] = 'field_newsroom_illustrative_img';
$fields['field_newsletter_only'] = 'field_newsroom_newsletter_only';
$fields['field_nr_project_coordinator'] = 'field_newsroom_prj_coordinator';
$fields['field_primary_topic'] = 'field_newsroom_primary_topic';
$fields['field_related_content'] = 'field_newsroom_related_content';
$fields['field_teaser'] = 'field_newsroom_teaser';
$fields['field_ted_link'] = 'field_newsroom_ted_link';
$fields['field_featured_item'] = 'field_newsroom_featured_item';
$fields['field_responsible_person_label'] = 'field_newsroom_resp_person_label';
$fields['field_read_more_text'] = 'field_newsroom_read_more_text';
$fields['field_display_date'] = 'field_newsroom_display_date';
$fields['field_direct_link_if_teaser_only'] = 'field_newsroom_direct_link';
$fields['field_date_label'] = 'field_newsroom_date_label';
$fields['field_service_active'] = 'field_newsroom_service_active';
$fields['field_service_type'] = 'field_newsroom_service_type';
$fields['field_selected_types'] = 'field_newsroom_selected_types';
$fields['field_selected_topics'] = 'field_newsroom_selected_topics';
foreach ($fields as $old_field => $new_field) {
_nexteuropa_newsroom_rename_field($old_field, $new_field);
}
}
/**
* Delete old fieldgroups.
*/
function nexteuropa_newsroom_update_7109() {
$fieldgroups = [
'group_event_info',
'group_lead',
'group_recommended_reading',
];
foreach ($fieldgroups as $group_name) {
if ($group = field_group_load_field_group($group_name, 'node', NEXTEUROPA_NEWSROOM_CONTENT_TYPE, 'default')) {
ctools_include('export');
field_group_group_export_delete($group, FALSE);
}
}
}
/**
* Remove body from newsroom_newsletter_issue bundle.
*/
function nexteuropa_newsroom_update_7110() {
variable_set('nexteuropa_newsroom_newsletter_import_script', NEXTEUROPA_NEWSROOM_NEWSLETTER_SCRIPT);
variable_set('node_preview_newsroom_newsletter_item', 0);
variable_set('node_submitted_newsroom_newsletter_item', 0);
variable_set('comment_newsroom_newsletter_item', COMMENT_NODE_CLOSED);
// Body field is locked and an instance is always created,
// we want to remove it.
if ($instance = field_info_instance('node', 'body', 'newsroom_newsletter_issue')) {
field_delete_instance($instance, TRUE);
}
}
/**
* Clean up after replacing newsroom page.
*/
function nexteuropa_newsroom_update_7111() {
variable_del('newsroom_url_prefix');
ctools_include('export');
$views = [
'newsroom_type_featured_item',
'newsroom',
'newsroom_term_selection',
'newsroom_navigation',
];
foreach ($views as $view_name) {
$view = ctools_export_crud_load('views_view', $view_name);
if ($view) {
$view->delete();
}
}
}
/**
* Update a single item chunck.
*/
function nexteuropa_newsroom_update_7112() {
variable_set('newsroom_single_item_import_segment', NEXTEUROPA_NEWSROOM_ITEM_SEGMENT);
}
/**
* Rename variables.
*/
function nexteuropa_newsroom_update_7113() {
$vars = [
'newsroom_universe_id',
'newsroom_subsite',
'newsroom_legacy',
'newsroom_use_css',
'newsroom_content_types_topic',
'newsroom_use_default_view_mode',
'newsroom_consultations_type_id',
'newsroom_fundings_type_id',
'newsroom_events_type_id',
'newsroom_days_number_for_new_user',
'newsroom_summary_home_block_num_highlighted_items',
'newsroom_summary_home_block_num_items',
'newsroom_summary_home_block_num_agenda',
'newsroom_summary_block_num_highlighted_items',
'newsroom_summary_block_num_items',
'newsroom_agenda_after_highlights',
'newsroom_display_highlights_begin',
'newsroom_order_by_last_update',
'newsroom_featured_type',
'newsroom_newsletter_privacy',
'newsroom_docsroom_url',
'newsroom_proposal_script',
'newsroom_single_item_edit_segment',
'newsroom_single_service_import_segment',
'newsroom_service_import_script',
'newsroom_single_type_import_segment',
'newsroom_type_import_script',
'newsroom_single_topic_import_segment',
'newsroom_topic_import_script',
'newsroom_single_item_import_segment',
'newsroom_item_import_script',
'newsroom_allowed_ips',
'newsroom_base_url',
'newsroom_subscription_url',
'newsroom_app_key',
'newsroom_app',
'newsroom_content_types_delete_select',
'newsroom_content_types_select',
'newsroom_content_types_delete_topic',
'newsroom_patterns',
'newsroom_ct_agenda_result',
'newsroom_ct_agenda_block',
'newsroom_ct_agenda_build',
'newsroom_ct_current_items',
'newsroom_ct_result_topics',
'newsroom_ct_upcoming_date',
'newsroom_ct_previous_date',
'newsroom_ct_summary_block',
'newsroom_ct_get_menu_by_path',
'newsroom_ct_get_topic_entities',
'newsroom_ct_fetch_active_menu',
'newsroom_ct_term_from_request',
'newsroom_ct_node_related_to_topic',
'newsroom_ct_page_result_topics',
'newsroom_ct_type_featured_item',
'newsroom_ct_summary_filter',
'newsroom_ct_node_relative_items',
'newsroom_agenda_page_items_number',
'newsroom_page_items_number',
'newsroom_central_newsletter_title',
'newsroom_other_newsletter_title',
'newsroom_days_number_for_new_user',
'newsroom_allowed_ips',
'newsroom_ct_agenda_result',
'newsroom_newsletter_import_script',
];
foreach ($vars as $var) {
variable_set('nexteuropa_' . $var, variable_get($var));
variable_del($var);
}
variable_del('newsroom_display_agenda');
variable_del('newsroom_summary_block_columns');
}
/**
* Remove field_tags.
*/
function nexteuropa_newsroom_update_7114() {
if ($instance = field_info_instance('node', 'field_tags', 'newsroom_item')) {
field_delete_instance($instance, TRUE);
}
}
/**
* Remove field group section.
*/
function nexteuropa_newsroom_update_7115() {
_nexteuropa_newsroom_remove_group(['group_newsroom_item_form_section|node|newsroom_item|form']);
}
/**
* Update ips range.
*/
function nexteuropa_newsroom_update_7116() {
variable_set('nexteuropa_newsroom_allowed_ips', '127.0.0.1,158.167.165.192,158.167.165.191,158.167.209.222,158.167.210.159,158.167.210.158,158.167.239.142,158.167.236.249');
variable_get('nexteuropa_newsroom_base_url', NEXTEUROPA_NEWSROOM_BASE_URL);
}
/**
* Remove newsroom selection content type.
*/
function nexteuropa_newsroom_update_7117() {
$type = 'newsroom_selection';
// Remove nodes.
$nids = db_select('node', 'n')
->fields('n', array('nid'))
->fields('n', array('type'))
->condition('n.type', $type)
->execute()
->fetchCol();
foreach ($nids as $nid) {
node_delete($nid);
}
// Remove variables.
$vars = [
'comment_anonymous_newsroom_selection',
'comment_default_mode_newsroom_selection',
'comment_default_per_page_newsroom_selection',
'comment_form_location_newsroom_selection',
'comment_newsroom_selection',
'comment_preview_newsroom_selection',
'comment_subject_field_newsroom_selection',
'field_bundle_settings_node__newsroom_selection',
'i18n_sync_node_type_newsroom_selection',
'language_content_type_newsroom_selection',
'menu_options_newsroom_selection',
'menu_parent_newsroom_selection',
'node_options_newsroom_selection',
'node_preview_newsroom_selection',
'node_submitted_newsroom_selection',
'field_bundle_settings_node__newsroom_selection',
'pathauto_node_newsroom_selection_en_pattern',
'pathauto_node_newsroom_selection_pattern',
'pathauto_node_newsroom_selection_und_pattern',
];
foreach ($vars as $var) {
variable_del($var);
}
if ($instance = field_info_instance('node', 'body', $type)) {
field_delete_instance($instance, TRUE);
}
// Remove fields.
$fields = [
'field_newsroom_selected_topic',
'field_newsroom_selected_types',
'field_newsroom_topic_operator',
'field_selected_topic_highlights',
'field_newsroom_associated_select',
'field_data_field_shared_newsroom_selection',
];
foreach ($fields as $field) {
field_delete_field($field);
}
field_purge_batch(1000);
node_type_delete($type);
}
/**
* Set author as translatable.
*/
function nexteuropa_newsroom_update_7118() {
$info = field_info_field('field_newsroom_author');
$info['translatable'] = 1;
field_update_field($info);
}
/**
* Update feed rss urls.
*/
function nexteuropa_newsroom_update_7119() {
variable_set('nexteuropa_newsroom_item_import_script', NEXTEUROPA_NEWSROOM_ITEM_SCRIPT);
variable_set('nexteuropa_newsroom_newsletter_import_script', NEXTEUROPA_NEWSROOM_NEWSLETTER_SCRIPT);
variable_set('nexteuropa_newsroom_topic_import_script', NEXTEUROPA_NEWSROOM_TOPIC_SCRIPT);
variable_set('nexteuropa_newsroom_type_import_script', NEXTEUROPA_NEWSROOM_TYPE_SCRIPT);
variable_set('nexteuropa_newsroom_service_import_script', NEXTEUROPA_NEWSROOM_TOPIC_SCRIPT);
NexteuropaNewsroomImporterHelper::rebuildImporters();
}
/**
* Rebuild importers to add support of different image formats.
*/
function nexteuropa_newsroom_update_7120() {
NexteuropaNewsroomImporterHelper::rebuildImporters();
}
/**
* Rebuild importers to fix topics importers.
*/
function nexteuropa_newsroom_update_7121() {
NexteuropaNewsroomImporterHelper::rebuildImporters();
}