forked from backdrop-contrib/feeds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeeds.install
409 lines (376 loc) · 12.5 KB
/
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
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
<?php
/**
* @file
* Schema definitions install/update/uninstall hooks.
*/
/**
* Implements hook_requirements().
*/
function feeds_requirements($phase) {
$t = get_t();
$requirements = array();
module_load_include('module', 'feeds');
// Check if we have any SimplePie importers.
$needs_simplepie = FALSE;
foreach (feeds_importer_load_all() as $importer) {
if ($importer->config['parser']['plugin_key'] === 'FeedsSimplePieParser') {
$needs_simplepie = TRUE;
break;
}
}
if (!$needs_simplepie) {
return $requirements;
}
$requirements['simplepie'] = array(
'title' => $t('SimplePie'),
'value' => $t('Installed'),
'description' => $t('The SimplePie library is required for Feeds SimplePie Parser.'),
'severity' => REQUIREMENT_OK,
);
if (!feeds_simplepie_exists()) {
$requirements['simplepie']['value'] = $t('Not installed');
$folder = backdrop_get_path('module', 'feeds') . '/libraries';
if (module_exists('libraries')) {
$folder = 'sites/all/libraries/simplepie';
}
$args = array(
'!url' => 'http://simplepie.org/downloads/',
'%folder' => $folder,
'%file' => 'simplepie.compiled.php',
);
$requirements['simplepie']['description'] .= $t('<br />Download the compiled, single-file version of the library from the <a href="!url">SimplePie download page</a>, place it into %folder and rename it to %file.', $args);
$requirements['simplepie']['severity'] = REQUIREMENT_ERROR;
}
return $requirements;
}
/**
* Implements hook_schema().
*/
function feeds_schema() {
$schema = array();
$schema['feeds_importer'] = array(
'description' => 'Configuration of feeds objects.',
'export' => array(
'key' => 'id',
'identifier' => 'feeds_importer',
'default hook' => 'feeds_importer_default', // Function hook name.
'api' => array(
'owner' => 'feeds',
'api' => 'feeds_importer_default', // Base name for api include files.
'minimum_version' => 1,
'current_version' => 1,
),
),
'fields' => array(
'id' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'Id of the fields object.',
),
'config' => array(
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'description' => 'Configuration of the feeds object.',
'serialize' => TRUE,
),
),
'primary key' => array('id'),
);
$schema['feeds_source'] = array(
'description' => 'Source definitions for feeds.',
'fields' => array(
'id' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'Id of the feed configuration.',
),
'feed_nid' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'unsigned' => TRUE,
'description' => 'Node nid if this particular source is attached to a feed node.',
),
'config' => array(
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'description' => 'Configuration of the source.',
'serialize' => TRUE,
),
'source' => array(
'type' => 'text',
'not null' => TRUE,
'description' => 'Main source resource identifier. E. g. a path or a URL.',
),
'state' => array(
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'description' => 'State of import or clearing batches.',
'serialize' => TRUE,
),
'fetcher_result' => array(
'type' => 'blob',
'size' => 'big',
'not null' => FALSE,
'description' => 'Cache for fetcher result.',
'serialize' => TRUE,
),
'imported' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'unsigned' => TRUE,
'description' => 'Timestamp when this source was imported last.',
),
),
'primary key' => array('id', 'feed_nid'),
'indexes' => array(
'id' => array('id'),
'feed_nid' => array('feed_nid'),
'id_source' => array('id', array('source', 128)),
),
);
$schema['feeds_item'] = array(
'description' => 'Tracks items such as nodes, terms, users.',
'fields' => array(
'entity_type' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
'description' => 'The entity type.',
),
'entity_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'The imported entity\'s serial id.',
),
'id' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'The id of the importer that created this item.',
),
'feed_nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Node id of the source, if available.',
),
'imported' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Import date of the feed item, as a Unix timestamp.',
),
'url' => array(
'type' => 'text',
'not null' => TRUE,
'description' => 'Link to the feed item.',
),
'guid' => array(
'type' => 'text',
'not null' => TRUE,
'description' => 'Unique identifier for the feed item.'
),
'hash' => array(
'type' => 'varchar',
'length' => 32, // The length of an MD5 hash.
'not null' => TRUE,
'default' => '',
'description' => 'The hash of the source item.',
),
),
'primary key' => array('entity_type', 'entity_id'),
'indexes' => array(
'id' => array('id'),
'feed_nid' => array('feed_nid'),
'lookup_url' => array('entity_type', 'id', 'feed_nid', array('url', 128)),
'lookup_guid' => array('entity_type', 'id', 'feed_nid', array('guid', 128)),
'global_lookup_url' => array('entity_type', array('url', 128)),
'global_lookup_guid' => array('entity_type', array('guid', 128)),
'imported' => array('imported'),
),
);
$schema['feeds_push_subscriptions'] = array(
'description' => 'PubSubHubbub subscriptions.',
'fields' => array(
'domain' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'Domain of the subscriber. Corresponds to an importer id.',
),
'subscriber_id' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'unsigned' => TRUE,
'description' => 'ID of the subscriber. Corresponds to a feed nid.',
),
'timestamp' => array(
'type' => 'int',
'unsigned' => FALSE,
'default' => 0,
'not null' => TRUE,
'description' => 'Created timestamp.',
),
'hub' => array(
'type' => 'text',
'not null' => TRUE,
'description' => 'The URL of the hub endpoint of this subscription.',
),
'topic' => array(
'type' => 'text',
'not null' => TRUE,
'description' => 'The topic URL (feed URL) of this subscription.',
),
'secret' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'Shared secret for message authentication.',
),
'status' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
'description' => 'Status of subscription.',
),
'post_fields' => array(
'type' => 'text',
'not null' => FALSE,
'description' => 'Fields posted.',
'serialize' => TRUE,
),
),
'primary key' => array('domain', 'subscriber_id'),
'indexes' => array(
'timestamp' => array('timestamp'),
),
);
$schema['feeds_log'] = array(
'description' => 'Table that contains logs of feeds events.',
'fields' => array(
'flid' => array(
'type' => 'serial',
'not null' => TRUE,
'description' => 'Primary Key: Unique feeds event ID.',
),
'id' => array(
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'The id of the importer that logged the event.',
),
'feed_nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Node id of the source, if available.',
),
'log_time' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Unix timestamp of when event occurred.',
),
'request_time' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'Unix timestamp of the request when the event occurred.',
),
'type' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'default' => '',
'description' => 'Type of log message, for example "feeds_import"."',
),
'message' => array(
'type' => 'text',
'not null' => TRUE,
'size' => 'big',
'description' => 'Text of log message to be passed into the t() function.',
),
'variables' => array(
'type' => 'blob',
'not null' => TRUE,
'size' => 'big',
'description' => 'Serialized array of variables that match the message string and that is passed into the t() function.',
),
'severity' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'size' => 'tiny',
'description' => 'The severity level of the event; ranges from 0 (Emergency) to 7 (Debug)',
),
),
'primary key' => array('flid'),
'indexes' => array(
'id' => array('id'),
'id_feed_nid' => array('id', 'feed_nid'),
'request_time' => array('request_time'),
'log_time' => array('log_time'),
'type' => array('type'),
),
);
$schema['cache_feeds_http'] = backdrop_get_schema_unprocessed('system', 'cache');
$schema['cache_feeds_http']['description'] = 'Cache table for Feeds downloads.';
return $schema;
}
function feeds_update_1000() {
$config = config('feeds.settings');
$config->set('feeds_reschedule', update_variable_get('feeds_reschedule'));
$config->set('feeds_debug', update_variable_get('feeds_debug'));
$config->set('feeds_importer_class', update_variable_get('feeds_importer_class'));
$config->set('feeds_library_dir', update_variable_get('feeds_library_dir'));
$config->set('default_feeds_importer', update_variable_get('default_feeds_importer'));
$config->set('menu_rebuild_needed', update_variable_get('menu_rebuild_needed'));
$config->set('feeds_source_class', update_variable_get('feeds_source_class'));
$config->set('http_request_timeout', update_variable_get('http_request_timeout'));
$config->set('proxy_server', update_variable_get('proxy_server'));
$config->set('proxy_port', update_variable_get('proxy_port'));
$config->set('proxy_username', update_variable_get('proxy_username'));
$config->set('proxy_password', update_variable_get('proxy_password'));
$config->set('proxy_auth_method', update_variable_get('proxy_auth_method'));
$config->set('feeds_never_use_curl', update_variable_get('feeds_never_use_curl'));
$config->set('feeds_library_dir', update_variable_get('feeds_library_dir'));
$config->set('feeds_process_limit', update_variable_get('feeds_process_limit'));
$config->set('default_nodes_main', update_variable_get('default_nodes_main'));
$config->save();
// Delete variables.
update_variable_del('feeds_reschedule');
update_variable_del('feeds_debug');
update_variable_del('feeds_importer_class');
update_variable_del('feeds_library_dir');
update_variable_del('default_feeds_importer');
update_variable_del('menu_rebuild_needed');
update_variable_del('feeds_source_class');
update_variable_del('http_request_timeout');
update_variable_del('proxy_server');
update_variable_del('proxy_port');
update_variable_del('proxy_username');
update_variable_del('proxy_password');
update_variable_del('proxy_auth_method');
update_variable_del('feeds_never_use_curl');
update_variable_del('feeds_library_dir');
update_variable_del('feeds_process_limit');
update_variable_del('default_nodes_main');
}