This repository has been archived by the owner on Oct 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindico_feeds.install
123 lines (115 loc) · 3.81 KB
/
indico_feeds.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
<?php
function indico_feeds_install() {
if(function_exists('field_features_rebuild')) {
// Ensure our fields are up to date
field_features_rebuild('indico_feeds');
}
}
/**
* Add feature field: field_indico_ical to provide calendar info to indico_feeds.
* Please after running upgrade do:
* - Clear caches and rebuild registry.
* - You may need to add a mapping on your indico feed processor in case you want to use field_indico_ical.
* So under admin/modules go to configure indico feeds -> Processor
* -> Mapping -> Source:ical <=> Target:Indico iCal
*/
function indico_feeds_update_7200() {
if (!field_info_field('field_indico_ical')) {
watchdog('Indico feeds','update being called');
$field = array(
'active' => '1',
'cardinality' => '1',
'deleted' => '0',
'entity_types' => array(),
'field_name' => 'field_indico_ical',
'foreign keys' => array(
'format' => array(
'columns' => array(
'format' => 'format',
),
'table' => 'filter_format',
),
),
'indexes' => array(
'format' => array(
0 => 'format',
),
),
'module' => 'text',
'settings' => array(
'max_length' => '255',
),
'translatable' => '0',
'type' => 'text',
);
field_create_field($field);
// Create the instance on the bundle.
$instance = array(
'bundle' => 'indico_event',
'default_value' => NULL,
'deleted' => '0',
'description' => 'This field contains the link to the iCal Indico event.',
'display' => array(
'default' => array(
'label' => 'inline',
'module' => 'text',
'settings' => array(),
'type' => 'text_default',
'weight' => '10',
),
'teaser' => array(
'label' => 'above',
'settings' => array(),
'type' => 'hidden',
'weight' => 0,
),
),
'entity_type' => 'node',
'field_name' => 'field_indico_ical',
'label' => 'Indico iCal',
'required' => 1,
'settings' => array(
'text_processing' => '0',
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 1,
'module' => 'text',
'settings' => array(
'size' => '60',
),
'type' => 'text_textfield',
'weight' => '12',
),
);
field_create_instance($instance);
}
watchdog('Indico feeds','Update was run');
}
function indico_feeds_uninstall() {
drupal_load('module', 'indico_feeds');
// Delete all indico importers
foreach(feeds_importer_load_all(true) as $importer) {
if(_indico_feeds_is_indico_importer($importer)) {
$importer->delete();
}
}
feeds_cache_clear();
// Delete all nodes created by us
$res = db_select('node')
->fields('node', array('nid'))
->condition('type', array('indico_feed', 'indico_event'))
->execute()
->fetchAll();
$nids = array();
foreach($res as $row) {
$nids[] = $row->nid;
}
node_delete_multiple($nids);
// Delete out content types
foreach(array('indico_event', 'indico_feed') as $type) {
node_type_delete($type);
variable_del('node_preview_' . $type);
}
node_types_rebuild();
}