-
Notifications
You must be signed in to change notification settings - Fork 2
/
ding_news.install
112 lines (105 loc) · 3.01 KB
/
ding_news.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
<?php
/**
* @file
* Handles update tasks for the module.
*/
/**
* Remove old ting reference field table from news.
*/
function ding_news_update_7000() {
// The tables are left over after change to virtual field, hence we have to
// remove them the hard way without deleting the field.
db_drop_table('field_data_field_ding_news_materials');
db_drop_table('field_revision_field_ding_news_materials');
}
/**
* Move group information into new field.
*/
function ding_news_update_7001() {
$rows = db_select('field_data_field_ding_news_library', 'fdel')
->fields('fdel')
->execute();
foreach ($rows as $row) {
db_insert('field_data_og_group_ref')
->fields(array(
'entity_type' => $row->entity_type,
'bundle' => $row->bundle,
'deleted' => $row->deleted,
'entity_id' => $row->entity_id,
'revision_id' => $row->revision_id,
'language' => $row->language,
'delta' => $row->delta,
'og_group_ref_target_id' => $row->field_ding_news_library_gid,
))
->execute();
}
}
/**
* Move group information revision into new field.
*/
function ding_news_update_7002() {
$rows = db_select('field_revision_field_ding_news_library', 'fdel')
->fields('fdel')
->execute();
foreach ($rows as $row) {
db_insert('field_revision_og_group_ref')
->fields(array(
'entity_type' => $row->entity_type,
'bundle' => $row->bundle,
'deleted' => $row->deleted,
'entity_id' => $row->entity_id,
'revision_id' => $row->revision_id,
'language' => $row->language,
'delta' => $row->delta,
'og_group_ref_target_id' => $row->field_ding_news_library_gid,
))
->execute();
}
}
/**
* Remove old library reference field.
*/
function ding_news_update_7003() {
field_delete_field('field_ding_news_library');
field_purge_batch(1000);
}
/**
* Move content into the OG library groups.
*/
function ding_news_update_7004() {
$query = db_select('field_data_og_group_ref', 'group_ref');
$query->join('og', 'og', 'group_ref.og_group_ref_target_id = og.gid');
$query->fields('group_ref', array('entity_id', 'og_group_ref_target_id'))
->condition('bundle', 'ding_news');
$query->addField('og', 'etid');
$rows = $query->execute();
foreach ($rows as $row) {
db_insert('og_membership')
->fields(array(
'type' => 'og_membership_type_default',
'etid' => $row->entity_id,
'entity_type' => 'node',
'gid' => $row->etid,
'state' => 1,
'created' => time(),
'group_type' => 'node',
'field_name' => 'og_group_ref',
'language' => 'und',
))
->execute();
}
}
/**
* Install menu position rule.
*/
function ding_news_update_7005() {
ding_news_install_menu_position();
}
/**
* Remove old news path auto patterns.
*/
function ding_news_update_7006() {
variable_del('pathauto_node_ding_news_da_pattern');
variable_del('pathauto_node_ding_news_en_pattern');
variable_del('pathauto_node_ding_news_und_pattern');
}