diff options
Diffstat (limited to 'classes/feeds.php')
-rwxr-xr-x | classes/feeds.php | 26 |
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(); |