summaryrefslogtreecommitdiff
path: root/classes/feeds.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-02-20 15:54:40 +0300
committerAndrew Dolgov <[email protected]>2020-02-20 15:54:40 +0300
commit5f30061c9236ac1937104df05d584c40f671c444 (patch)
tree5134ddd81906992c23e3f5deaa418b807d503a48 /classes/feeds.php
parent60288f02e8947282bf9226f63d0ce052f9c9ac61 (diff)
properly calculate marked counters for feeds in nested categories
Diffstat (limited to 'classes/feeds.php')
-rwxr-xr-xclasses/feeds.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/classes/feeds.php b/classes/feeds.php
index 8ef4f1f1c..77add790e 100755
--- a/classes/feeds.php
+++ b/classes/feeds.php
@@ -1290,6 +1290,30 @@ class Feeds extends Handler_Protected {
}
}
+ // only real cats
+ static function getCategoryMarked($cat, $owner_uid = false) {
+
+ if (!$owner_uid) $owner_uid = $_SESSION["uid"];
+
+ $pdo = Db::pdo();
+
+ if ($cat >= 0) {
+
+ $sth = $pdo->prepare("SELECT SUM(CASE WHEN marked THEN 1 ELSE 0 END) AS marked
+ FROM ttrss_user_entries
+ WHERE feed_id IN (SELECT id FROM ttrss_feeds
+ WHERE (cat_id = :cat OR (:cat IS NULL AND cat_id IS NULL))
+ AND owner_uid = :uid)
+ AND owner_uid = :uid");
+ $sth->execute(["cat" => $cat ? $cat : null, "uid" => $owner_uid]);
+ $row = $sth->fetch();
+
+ return $row["marked"];
+ } else {
+ return 0;
+ }
+ }
+
static function getCategoryUnread($cat, $owner_uid = false) {
if (!$owner_uid) $owner_uid = $_SESSION["uid"];