Beispiel #1
0
$feeds = array();
$p =& FoF_Prefs::instance();
$admin_prefs = $p->admin_prefs;
if ($feed) {
    $feed = fof_db_get_feed_by_id($feed);
    $feeds[] = $feed;
} else {
    if ($fof_user_id == 1) {
        $result = fof_db_get_feeds();
    } else {
        $result = fof_db_get_subscriptions(fof_current_user());
    }
    while ($feed = fof_db_get_row($result)) {
        if (time() - $feed["feed_cache_date"] < $admin_prefs["manualtimeout"] * 60) {
            $title = $feed['feed_title'];
            list($timestamp, ) = fof_nice_time_stamp($feed['feed_cache_date']);
            print "{$title} was just updated {$timestamp}!<br>";
        } else {
            $feeds[] = $feed;
        }
    }
}
$feeds = fof_multi_sort($feeds, 'feed_cache_attempt_date', false);
print "<script>\nwindow.onload = ajaxupdate;\nfeedslist = [";
foreach ($feeds as $feed) {
    $title = $feed['feed_title'];
    $id = $feed['feed_id'];
    $feedjson[] = "{'id': {$id}, 'title': '" . addslashes($title) . "'}";
}
print join($feedjson, ", ");
print "];\n</script>";
Beispiel #2
0
        $feed_status = " is waiting to update...";
    }
    echo '<div id="feed_id_' . $feed['feed_id'] . '">' . fof_render_feed_link($feed) . ' ' . $feed_status . "</div>\n";
} else {
    if ($fof_user_id == 1) {
        $result = fof_db_get_feeds_needing_attempt();
    } else {
        $result = fof_db_get_subscriptions(fof_current_user(), true);
    }
    while (($feed = fof_db_get_row($result)) !== false) {
        if (time() - $feed['feed_cache_date'] < $admin_prefs['manualtimeout'] * 60) {
            list($timestamp) = fof_nice_time_stamp($feed['feed_cache_date']);
            $feed_status = " was just updated {$timestamp}!";
        } else {
            if (time() < $feed['feed_cache_next_attempt']) {
                list($timestamp) = fof_nice_time_stamp($feed['feed_cache_next_attempt']);
                $feed_status = " isn't due for an update for {$timestamp}.";
            } else {
                $feeds[] = $feed;
                $feed_status = " is waiting to update...";
            }
        }
        echo '<div id="feed_id_' . $feed['feed_id'] . '">' . fof_render_feed_link($feed) . ' ' . $feed_status . "</div>\n";
    }
}
$feeds = fof_multi_sort($feeds, 'feed_cache_attempt_date', false);
$feedjson = array();
foreach ($feeds as $feed) {
    $feedjson[] = json_encode(array('id' => $feed['feed_id'], 'title' => $feed['feed_title']));
}
echo "<script>\nwindow.onload = ajaxupdate;\nfeedslist = [ " . implode(', ', $feedjson) . " ];\n</script>\n";
Beispiel #3
0
function fof_get_feeds($user_id, $order = 'feed_title', $direction = 'asc')
{
    $feeds = array();
    $result = fof_db_get_subscriptions($user_id);
    $i = 0;
    while ($row = fof_db_get_row($result)) {
        $id = $row['feed_id'];
        $age = $row['feed_cache_date'];
        $feeds[$i]['feed_id'] = $id;
        $feeds[$i]['feed_url'] = $row['feed_url'];
        $feeds[$i]['feed_title'] = $row['feed_title'];
        $feeds[$i]['feed_link'] = $row['feed_link'];
        $feeds[$i]['feed_description'] = $row['feed_description'];
        $feeds[$i]['feed_image'] = $row['feed_image'];
        $feeds[$i]['prefs'] = unserialize($row['subscription_prefs']);
        $feeds[$i]['feed_age'] = $age;
        list($agestr, $agestrabbr) = fof_nice_time_stamp($age);
        $feeds[$i]['agestr'] = $agestr;
        $feeds[$i]['agestrabbr'] = $agestrabbr;
        $i++;
    }
    $tags = fof_db_get_tag_id_map();
    for ($i = 0; $i < count($feeds); $i++) {
        $feeds[$i]['tags'] = array();
        if (is_array($feeds[$i]['prefs']['tags'])) {
            foreach ($feeds[$i]['prefs']['tags'] as $tag) {
                $feeds[$i]['tags'][] = $tags[$tag];
            }
        }
    }
    $result = fof_db_get_item_count($user_id);
    while ($row = fof_db_get_row($result)) {
        for ($i = 0; $i < count($feeds); $i++) {
            if ($feeds[$i]['feed_id'] == $row['id']) {
                $feeds[$i]['feed_items'] = $row['count'];
                $feeds[$i]['feed_read'] = $row['count'];
                $feeds[$i]['feed_unread'] = 0;
            }
        }
    }
    $result = fof_db_get_unread_item_count($user_id);
    while ($row = fof_db_get_row($result)) {
        for ($i = 0; $i < count($feeds); $i++) {
            if ($feeds[$i]['feed_id'] == $row['id']) {
                $feeds[$i]['feed_unread'] = $row['count'];
            }
        }
    }
    foreach ($feeds as $feed) {
        $feed['feed_starred'] = 0;
    }
    $result = fof_db_get_starred_item_count($user_id);
    while ($row = fof_db_get_row($result)) {
        for ($i = 0; $i < count($feeds); $i++) {
            if ($feeds[$i]['feed_id'] == $row['id']) {
                $feeds[$i]['feed_starred'] = $row['count'];
            }
        }
    }
    $result = fof_db_get_latest_item_age($user_id);
    while ($row = fof_db_get_row($result)) {
        for ($i = 0; $i < count($feeds); $i++) {
            if ($feeds[$i]['feed_id'] == $row['id']) {
                $feeds[$i]['max_date'] = $row['max_date'];
                list($agestr, $agestrabbr) = fof_nice_time_stamp($row['max_date']);
                $feeds[$i]['lateststr'] = $agestr;
                $feeds[$i]['lateststrabbr'] = $agestrabbr;
            }
        }
    }
    $feeds = fof_multi_sort($feeds, $order, $direction != "asc");
    return $feeds;
}
} 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);
    ?>
<script>
function subscription_tags_refresh(feed) {
	var params = { subscription_tag_list: feed };
	new Ajax.Updater($("feedtags").down("ul"), "feed-action.php", { method: "post", parameters: params });
}
Beispiel #5
0
function fof_get_feeds($user_id, $order = 'feed_title', $direction = 'asc')
{
    $feeds = array();
    $tagmap = fof_db_get_tag_id_map();
    $result = fof_db_get_subscriptions($user_id);
    $i = 0;
    $feeds_index = array();
    while (($row = fof_db_get_row($result)) !== false) {
        /* remember where we are */
        $feeds_index[$row['feed_id']] = $i;
        /* fix user prefs */
        fof_db_subscription_feed_fix($row);
        /* initialize some values.. these will be populated later */
        $row['feed_items'] = 0;
        $row['feed_read'] = 0;
        $row['feed_unread'] = 0;
        $row['feed_starred'] = 0;
        $row['feed_tagged'] = 0;
        $row['max_date'] = 0;
        $row['lateststr'] = '';
        $row['lateststrabbr'] = '';
        /* we can set these now, though */
        $row['feed_age'] = $row['feed_cache_date'];
        list($row['agestr'], $row['agestrabbr']) = fof_nice_time_stamp($row['feed_cache_date']);
        $row['tags'] = array();
        foreach ($row['subscription_prefs']['tags'] as $tagid) {
            $row['tags'][] = $tagmap[$tagid];
        }
        $feeds[$i] = $row;
        $i++;
    }
    /* tally up all items */
    $result = fof_db_get_item_count($user_id);
    while (($row = fof_db_get_row($result)) !== false) {
        $i = $feeds_index[$row['feed_id']];
        $feeds[$i]['feed_items'] += $row['count'];
        $feeds[$i]['feed_read'] += $row['count'];
    }
    /* tally up unread items */
    $result = fof_db_get_item_count($user_id, 'unread');
    while (($row = fof_db_get_row($result)) !== false) {
        $i = $feeds_index[$row['feed_id']];
        $feeds[$i]['feed_unread'] += $row['count'];
        $feeds[$i]['feed_read'] -= $row['count'];
    }
    /* tally up starred items */
    $result = fof_db_get_item_count($user_id, 'starred');
    while (($row = fof_db_get_row($result)) !== false) {
        $i = $feeds_index[$row['feed_id']];
        $feeds[$i]['feed_starred'] += $row['count'];
    }
    /* tally up tags which aren't system-tags */
    $result = fof_db_get_item_count($user_id, 'tagged');
    while (($row = fof_db_get_row($result)) !== false) {
        $i = $feeds_index[$row['feed_id']];
        $feeds[$i]['feed_tagged'] += $row['count'];
    }
    /* find most recent item for each feed */
    $result = fof_db_get_latest_item_age($user_id);
    while (($row = fof_db_get_row($result)) !== false) {
        $i = $feeds_index[$row['feed_id']];
        $feeds[$i]['max_date'] = $row['max_date'];
        list($feeds[$i]['lateststr'], $feeds[$i]['lateststrabbr']) = fof_nice_time_stamp($row['max_date']);
    }
    return fof_multi_sort($feeds, $order, $direction != 'asc');
}