mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-24 05:51:28 +00:00
api: rewrite getCounters to use getAllCounters()
This commit is contained in:
@@ -104,73 +104,11 @@
|
|||||||
|
|
||||||
/* Method added for ttrss-reader for Android */
|
/* Method added for ttrss-reader for Android */
|
||||||
case "getCounters":
|
case "getCounters":
|
||||||
$counters = array();
|
|
||||||
|
|
||||||
$result = db_query($link, "SELECT
|
/* flct (flc is the default) FIXME: document */
|
||||||
id FROM ttrss_feed_categories
|
$output_mode = db_escape_string($_REQUEST["output_mode"]);
|
||||||
WHERE owner_uid = " .
|
|
||||||
$_SESSION["uid"]);
|
|
||||||
|
|
||||||
$cats = array();
|
print json_encode(getAllCounters($link, $output_mode));
|
||||||
|
|
||||||
while ($line = db_fetch_assoc($result)) {
|
|
||||||
array_push($cats, $line["id"]);
|
|
||||||
}
|
|
||||||
array_push($cats, "0");
|
|
||||||
array_push($cats, "-1");
|
|
||||||
array_push($cats, "-2");
|
|
||||||
array_push($cats, "-3");
|
|
||||||
array_push($cats, "-4");
|
|
||||||
|
|
||||||
foreach ($cats as $cat) {
|
|
||||||
|
|
||||||
$cat_part = "cat_id = '$cat'";
|
|
||||||
if ($cat == 0) {
|
|
||||||
$cat_part = "cat_id IS null";
|
|
||||||
}
|
|
||||||
|
|
||||||
$result = db_query($link, "SELECT
|
|
||||||
id FROM ttrss_feeds WHERE ".
|
|
||||||
$cat_part." AND owner_uid = " . $_SESSION["uid"]);
|
|
||||||
|
|
||||||
$feeds = array();
|
|
||||||
|
|
||||||
while ($line = db_fetch_assoc($result)) {
|
|
||||||
|
|
||||||
$unread = getFeedArticles($link, $line["id"], false, true, $_SESSION["uid"]);
|
|
||||||
|
|
||||||
if ($unread) {
|
|
||||||
$row = array(
|
|
||||||
"feed_id" => (int)$line["id"],
|
|
||||||
"unread" => (int)$unread
|
|
||||||
);
|
|
||||||
array_push($feeds, $row);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$is_cat = true;
|
|
||||||
if ($cat < 0) {
|
|
||||||
$is_cat = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$unread_cat = getFeedArticles($link, $cat, $is_cat, true, $_SESSION["uid"]);
|
|
||||||
|
|
||||||
if ($feeds) {
|
|
||||||
$count = array(
|
|
||||||
"cat_id" => $cat,
|
|
||||||
"unread" => $unread_cat,
|
|
||||||
"feeds" => $feeds
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$count = array(
|
|
||||||
"cat_id" => $cat,
|
|
||||||
"unread" => $unread_cat
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
array_push($counters, $count);
|
|
||||||
}
|
|
||||||
print json_encode($counters);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "getFeeds":
|
case "getFeeds":
|
||||||
|
|||||||
@@ -2480,7 +2480,7 @@
|
|||||||
|
|
||||||
/* Special case: NULL category doesn't actually exist in the DB */
|
/* Special case: NULL category doesn't actually exist in the DB */
|
||||||
|
|
||||||
$cv = array("id" => 0, "cat" => true,
|
$cv = array("id" => 0, "kind" => "cat",
|
||||||
"counter" => ccache_find($link, 0, $_SESSION["uid"], true));
|
"counter" => ccache_find($link, 0, $_SESSION["uid"], true));
|
||||||
|
|
||||||
array_push($ret_arr, $cv);
|
array_push($ret_arr, $cv);
|
||||||
|
|||||||
Reference in New Issue
Block a user