5 * Install file for FeedAPI module.
9 * Implementation of hook_schema().
11 function feedapi_schema() {
12 $schema['feedapi'] = array(
13 'description' => 'Stores feed-related info for each feed',
16 'description' => 'The node identifier where the feed belongs.',
21 'description' => 'The primary identifier for the feed.',
26 'description' => 'The URL of the feed',
30 'description' => 'Type of feed',
33 'default' => 'XML feed',
35 'processors' => array(
36 'description' => 'List of enabled processors',
42 'description' => 'List of enabled parsers',
47 'next_refresh_time' => array(
48 'description' => 'Timestamp of the earliest possible next refresh time',
54 'description' => 'Hash of the feed content',
58 'description' => 'URL of the source site of the feed',
61 'description' => 'Various settings of the feed',
65 'description' => 'Indicates if not all of the feed items were processed at the last cron run',
69 'primary key' => array('vid', 'nid'),
71 'vid' => array('vid'),
72 'next_refresh_time' => array('next_refresh_time')),
74 $schema['feedapi_stat'] = array(
75 'description' => 'Statistics values over the time about the feeds',
78 'description' => 'Unique identifier for statistics data',
83 'description' => 'Type of the data',
88 'description' => 'Timestamp of the data',
92 'description' => 'Time of the data',
97 'description' => 'Value of the data',
101 'feedapi_stat_id' => array('id'),
102 'feedapi_stat_type' => array('type')),
103 'feedapi_stat_timestamp' => array('timestamp'),
104 'feedapi_stat_time' => array('time'),
110 * Implementation of hook_install().
112 function feedapi_install() {
113 drupal_install_schema('feedapi');
114 // This value warrants that og, taxonomy and similar modules does their job before feedapi. This is important
115 // because of for example feedapi_inherit or whatever processor which needs a 3rd-party processed data.
116 db_query("UPDATE {system} SET weight = 5 WHERE name = 'feedapi'");
120 * Implementation of hook_uninstall().
122 function feedapi_uninstall() {
123 drupal_uninstall_schema('feedapi');
125 // Delete variables site-wide
126 variable_del('feedapi_allowed_html_tags');
127 variable_del('feedapi_allow_html_all');
128 variable_del('feedapi_cron_percentage');
130 // Delete variables per-content-type
131 $types = array_keys(node_get_types());
132 foreach ($types as
$type) {
133 variable_del('feedapi_settings_'.
$type);
137 function feedapi_update_6101() {
139 db_add_field($ret, 'feedapi', 'skip', array('type' => 'int', 'size' => 'tiny', 'default' => 0));
140 db_add_index($ret, 'feedapi', 'skip_id', array('skip'));
144 function feedapi_update_6102() {
146 db_change_field($ret, 'feedapi', 'url', 'url', array('description' => 'The URL of the feed', 'type' => 'text'));
147 db_change_field($ret, 'feedapi', 'link', 'link', array('type' => 'text'));
152 * feedapi_access_op() was renamed to _feedapi_op_access().
155 function feedapi_update_6103() {
162 * Check out if the built-in content-type has an enabled parser.
164 function feedapi_update_6104() {
165 $default_processor = 'feed';
166 // Determine if the installation is affected
168 $settings = variable_get('feedapi_settings_'.
$default_processor, FALSE
);
169 if (!isset($settings['parsers'])) {
173 foreach ($settings['parsers'] as
$parser => $setting) {
174 if (!module_exists($parser) && $setting['enabled']) {
181 // Set the parser of defaultly shipped processors if it's not done previously
182 $parsers = module_implements('feedapi_feed');
183 if (count($parsers) > 0) {
184 $set_processor = array("parsers" => array(array_pop($parsers) => array("enabled" => TRUE
, "weight" => 0)));
185 $settings = is_array($settings) ?
array_merge($settings, $set_processor) : $set_processor;
186 variable_set('feedapi_settings_'.
$default_processor, $settings);
193 * Adds vid to feedapi table
195 function feedapi_update_6105() {
198 db_add_field($ret, 'feedapi', 'vid',
200 'description' => 'The primary identifier for the feed.',
207 db_drop_primary_key($ret, 'feedapi');
208 if ($db_type == 'mysql' || $db_type == 'mysqli') {
209 $ret[] = update_sql("UPDATE {feedapi} f, {node} n SET f.vid = n.vid WHERE n.nid = f.nid");
212 $ret[] = update_sql("UPDATE {feedapi} SET vid = n.vid FROM (SELECT vid, nid FROM {node} n) n WHERE n.nid = feedapi.nid");
214 $ret[] = update_sql("UPDATE {feedapi} SET vid = nid WHERE vid = 0");
215 db_add_primary_key($ret, 'feedapi', array('vid', 'nid'));
216 db_add_index($ret, 'feedapi', 'vid', array('vid'));
221 * Convert checked to next_refresh_time and consolidate skip and
222 * next_refresh_time, add an index on next_refresh_time, make next_refresh_time
225 function feedapi_update_6106() {
232 db_change_field($ret, 'feedapi', 'checked', 'next_refresh_time', $spec);
234 // Convert the value in next_refresh_time from the last time a feed has been
235 // to the next time it should be checked.
236 $ret[] = update_sql('UPDATE {feedapi} SET next_refresh_time = (next_refresh_time + '. FEEDAPI_CRON_DEFAULT_REFRESH_TIME .
')');
238 // Set next_refresh_time to FEEDAPI_CRON_NEVER_REFRESH where skip = 1.
239 $ret[] = update_sql('UPDATE {feedapi} SET next_refresh_time = '. FEEDAPI_CRON_NEVER_REFRESH .
' WHERE skip = 1');
242 db_drop_field($ret, 'feedapi', 'skip');
244 // Update all settings.
245 $node_types = node_get_types('types');
247 // Update all node type settings.
248 foreach ($node_types as
$node_type) {
249 if (feedapi_enabled_type($node_type)) {
250 if ($settings = feedapi_get_settings($node_type)) {
251 $settings['refresh_time'] = $settings['skip'] ? FEEDAPI_CRON_NEVER_REFRESH
: FEEDAPI_CRON_DEFAULT_REFRESH_TIME
;
252 unset($settings['skip']);
253 _feedapi_store_settings(array('node_type' => $node_type), $settings);
258 // Update all node settings.
259 $result = db_query('SELECT n.type, f.vid FROM {node} n JOIN {feedapi} f ON f.nid = n.nid');
260 while ($node = db_fetch_object($result)) {
261 if ($settings = feedapi_get_settings($node->type
, $node->vid
)) {
262 $settings['refresh_time'] = $settings['skip'] ? FEEDAPI_CRON_NEVER_REFRESH
: FEEDAPI_CRON_DEFAULT_REFRESH_TIME
;
263 unset($settings['skip']);
264 _feedapi_store_settings(array('node_type' => $node->type
, 'vid' => $node->vid
), $settings);
272 * Convert refresh_time values to new constants
273 * FEEDAPI_CRON_NEVER_REFRESH and FEEDAPI_CRON_ALWAYS_REFRESH.
275 function feedapi_update_6107() {
277 // next_refresh_time can contain negative values now.
284 db_change_field($ret, 'feedapi', 'next_refresh_time', 'next_refresh_time', $spec);
286 // Update all node type settings.
287 $node_types = node_get_types('types');
288 foreach ($node_types as
$node_type) {
289 if (feedapi_enabled_type($node_type)) {
290 if ($settings = feedapi_get_settings($node_type)) {
291 if ($settings['refresh_time'] == 0 || $settings['refresh_time'] == 1) {
292 $settings['refresh_time'] = ($settings['refresh_time'] == 0) ? FEEDAPI_CRON_NEVER_REFRESH
: FEEDAPI_CRON_ALWAYS_REFRESH
;
293 _feedapi_store_settings(array('node_type' => $node_type), $settings);
299 // Update all node settings.
300 $result = db_query('SELECT n.type, f.vid FROM {node} n JOIN {feedapi} f ON f.nid = n.nid');
301 while ($node = db_fetch_object($result)) {
302 if ($settings = feedapi_get_settings($node->type
, $node->vid
)) {
303 if ($settings['refresh_time'] == 0 || $settings['refresh_time'] == 1) {
304 $settings['refresh_time'] = ($settings['refresh_time'] == 0) ? FEEDAPI_CRON_NEVER_REFRESH
: FEEDAPI_CRON_ALWAYS_REFRESH
;
305 _feedapi_store_settings(array('node_type' => $node->type
, 'vid' => $node->vid
), $settings);