summaryrefslogtreecommitdiff
path: root/classes/feeds.php
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-24 09:47:26 +0300
committerAndrew Dolgov <[email protected]>2021-02-24 09:47:26 +0300
commitd6203bf3508ba77e3943ddc412eb562edb327f22 (patch)
treeeb0e56ff62add4705c200903d559fa7d3f412acb /classes/feeds.php
parenta42e8aad97b66fd4964263e37a1b40164e495b4c (diff)
try to calculate counters conditionally based on feed ids
Diffstat (limited to 'classes/feeds.php')
-rwxr-xr-xclasses/feeds.php26
1 files changed, 25 insertions, 1 deletions
diff --git a/classes/feeds.php b/classes/feeds.php
index a38cbae97..453c8aa0f 100755
--- a/classes/feeds.php
+++ b/classes/feeds.php
@@ -1765,7 +1765,7 @@ class Feeds extends Handler_Protected {
$sth->execute([$cat, $owner_uid]);
while ($line = $sth->fetch()) {
- array_push($rv, $line["parent_cat"]);
+ array_push($rv, (int)$line["parent_cat"]);
$rv = array_merge($rv, self::_get_parent_cats($line["parent_cat"], $owner_uid));
}
@@ -1789,6 +1789,30 @@ class Feeds extends Handler_Protected {
return $rv;
}
+ static function _cats_of(array $feeds, int $owner_uid, bool $with_parents = false) {
+ $pdo = Db::pdo();
+
+ $feeds_qmarks = arr_qmarks($feeds);
+
+ $sth = $pdo->prepare("SELECT DISTINCT cat_id FROM ttrss_feeds
+ WHERE id IN ($feeds_qmarks)");
+ $sth->execute($feeds);
+
+ $rv = [];
+
+ if ($row = $sth->fetch()) {
+ array_push($rv, (int)$row["cat_id"]);
+
+ if ($with_parents)
+ $rv = array_merge($rv,
+ self::_get_parent_cats($row["cat_id"], $owner_uid));
+ }
+
+ $rv = array_unique($rv);
+
+ return $rv;
+ }
+
static function _cat_of_feed($feed) {
$pdo = Db::pdo();