function notifications_feed_notifications in Notifications 5
Same name and namespace in other branches
- 6 notifications_feed/notifications_feed.module \notifications_feed_notifications()
Implementation of hook_notifications().
File
- notifications_feed/
notifications_feed.module, line 60 - Subscriptions to FeedAPI feeds
Code
function notifications_feed_notifications($op, &$arg0, $arg1 = NULL, $arg2 = NULL) {
switch ($op) {
case 'names':
$subs =& $arg0;
if ($subs->event_type == 'feed') {
if (!empty($subs->fields['feed-nid'])) {
$feed = node_load($subs->fields['feed-nid']);
$subs->names['feed-nid'] = t('Feed: %name', array(
'%name' => $feed->title,
));
}
}
break;
case 'subscription types':
$types['feed'] = array(
'event_type' => 'feed',
'title' => t('Feed'),
'access' => 'subscribe to feeds',
'fields' => array(
'feed-nid',
),
);
return $types;
case 'query':
if ($arg0 == 'event' && $arg1 == 'feed' && ($node = $arg2->feed) || $arg0 == 'user' && $arg1 == 'feed' && ($node = $arg2)) {
$query[]['fields'] = array(
'feed-nid' => $node->nid,
);
return $query;
}
break;
case 'event types':
$types[] = array(
'type' => 'feed',
'action' => 'update',
'name' => '[type-name]: [title]',
'line' => "The feed [title] has been updated\n[feed-updated-items]",
'digest' => array(
'feed',
'nid',
),
);
return $types;
case 'event load':
$event =& $arg0;
if ($event->type == 'feed') {
if (!empty($event->params['nid'])) {
// For practical reasons like tokens we pass it as node too
$event->objects['node'] = $feed = node_load($event->params['nid']);
// Add some more data and we have the feed
$feed->items_new = $event->params['items_new'];
$feed->items_updated = $event->params['items_updated'];
$event->objects['feed'] = $feed;
}
}
break;
case 'node options':
return _notifications_feed_node_options($arg0, $arg1);
}
}