You are here

function notifications_feed_feedapi_after_refresh in Notifications 6

Same name and namespace in other branches
  1. 5 notifications_feed/notifications_feed.module \notifications_feed_feedapi_after_refresh()

Implementation of hook_feedapi_after_refresh()

We use the is_new and is_updated for each item

File

notifications_feed/notifications_feed.module, line 196
Subscriptions to FeedAPI feeds

Code

function notifications_feed_feedapi_after_refresh($feed) {
  $updated = $new = array();
  foreach ($feed->items as $index => $item) {
    if ($item->is_new) {
      $new[$index] = $item->title;
    }
    if ($item->is_updated) {
      $updated[$index] = $item->title;
    }
  }
  if ($new || $updated) {
    $event = array(
      'module' => 'notifications_feed',
      'uid' => 0,
      'oid' => $feed->nid,
      'type' => 'feed',
      'action' => 'items',
      'feed' => $feed,
      'params' => array(
        'nid' => $feed->nid,
        'items_new' => $new,
        'items_updated' => $updated,
      ),
    );
    notifications_event($event);
  }
}