You are here

function subscriptions_feed in Subscriptions 5

generates rss feed for subscriptions @account is $user object

1 string reference to 'subscriptions_feed'
subscriptions_menu in ./subscriptions.module
Implementation of hook_menu().

File

./subscriptions.module, line 1489

Code

function subscriptions_feed($account = NULL) {
  if (is_null($account)) {
    global $user;
    $account = $user;
  }
  $subs = subscriptions_get_user($account);
  if ($nodes = $subs['blog']) {
    $uids = implode(',', array_keys($nodes));
    $cond[] = "(n.type = 'blog' AND n.uid IN ({$uids}))";
  }
  if ($nodes = $subs['node']) {
    $nids = implode(',', array_keys($nodes));
    $cond[] = "(n.nid IN ({$nids}))";
  }
  if ($taxas = $subs['taxa']) {
    $tids = implode(',', array_keys($taxas));
    $cond[] = "(tn.tid IN ({$tids}))";
  }

  // content types link differently and will be excluded from this list
  $sql = "SELECT n.nid, max( n.created ) AS nc FROM {node} n LEFT JOIN {term_node} tn ON n.nid=tn.nid WHERE n.status=1";
  if ($cond) {
    $sql .= " AND ( " . implode(' OR ', $cond) . " )";
  }
  $sql .= " GROUP BY n.nid ORDER BY nc DESC";
  $result = db_query($sql);

  //$result = db_query_range(db_rewrite_sql($sql), 0, variable_get('feed_default_items', 10));
  $channel['title'] = t("!name Subscriptions", array(
    '!name' => $account->name,
  ));
  $channel['link'] = url("subscriptions/feed", NULL, NULL, TRUE);

  // $channel['description'] = ;
  node_feed($result, $channel);
}