while (($subscriber = fof_db_get_row($sub_statement, 'user_id')) !== false) { echo '<li>' . $users[$subscriber]['user_name'] . ' (' . $subscriber . ')</li>' . "\n"; } echo '</ul>' . "\n"; echo '</div>' . "\n"; } elseif (fof_db_is_subscribed_id(fof_current_user(), $feed_id)) { echo '<h1>Feed Details</h1>' . "\n"; } else { echo '<div class="error"><h1>Not Subscribed</h1>You don\'t know anything about that feed.</div>' . "\n"; die; } if (fof_is_admin() && !fof_db_is_subscribed_id(fof_current_user(), $feed_id)) { /* fof_get_feed expects a subscription, so shirk that and just populate overall stats */ $feed_row = fof_db_get_feed_by_id($feed_id); fof_db_subscription_feed_fix($feed_row); list($feed_row['feed_items'], $feed_row['feed_tagged'], $counts) = fof_db_feed_counts(fof_current_user(), $feed_id); $feed_row = array_merge(array('tags' => array(), 'feed_unread' => 0, 'feed_read' => 0, 'feed_starred' => 0, 'feed_age' => $feed_row['feed_cache_date']), $feed_row); list($feed_row['agestr'], $feed_row['agestrabbr']) = fof_nice_time_stamp($feed_row['feed_cache_date']); $max_stmt = fof_db_get_latest_item_age(fof_current_user(), $feed_id); $feed_row['max_date'] = fof_db_get_row($max_stmt, 'max_date', TRUE); list($feed_row['lateststr'], $feed_row['lateststrabbr']) = fof_nice_time_stamp($feed_row['max_date']); /* not subscribed, so no subscription preferences to change.. */ $admin_view = true; } else { $feed_row = fof_get_feed(fof_current_user(), $feed_id); $admin_view = false; } /* only include the update scripts if subscribed */ if (!$admin_view || fof_db_is_subscribed_id(fof_current_user(), $feed_id)) { $feed_id_js = json_encode($feed_id); ?>
function fof_get_feed($user_id, $feed_id) { $feed = fof_db_subscription_feed_get($user_id, $feed_id); /* turn array of tag ids from prefs into array of tag names */ $feed['tags'] = array(); $tagmap = fof_db_get_tag_id_map(); foreach ($feed['subscription_prefs']['tags'] as $tagid) { $feed['tags'][] = $tagmap[$tagid]; } /* fetch counts, and pick the ones we're interested in */ list($feed['feed_items'], $feed['feed_tagged'], $counts) = fof_db_feed_counts($user_id, $feed_id); $feed['feed_unread'] = $counts['unread']; $feed['feed_read'] = $feed['feed_items'] - $feed['feed_unread']; $feed['feed_starred'] = $counts['star']; // note not same! $feed['feed_age'] = $feed['feed_cache_date']; list($feed['agestr'], $feed['agestrabbr']) = fof_nice_time_stamp($feed['feed_cache_date']); $feed['max_date'] = 0; $feed['lateststr'] = ''; $feed['lateststrabbr'] = ''; $statement = fof_db_get_latest_item_age($user_id, $feed_id); $feed['max_date'] = fof_db_get_row($statement, 'max_date', TRUE); list($feed['lateststr'], $feed['lateststrabbr']) = fof_nice_time_stamp($feed['max_date']); return $feed; }