From 39cc1c11ec596176e842cc98e6a54337e3c04d7e Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 26 Feb 2024 09:01:03 +0100 Subject: New feature: shareable user query (#6052) * New feature: shareable user query Share the output of a user query by RSS / HTML / OPML with other people through unique URLs. Replaces the global admin token, which was the only option (but unsafe) to share RSS outputs with other people. Also add a new HTML output for people without an RSS reader. fix https://github.com/FreshRSS/FreshRSS/issues/3066#issuecomment-648977890 fix https://github.com/FreshRSS/FreshRSS/issues/3178#issuecomment-769435504 * Remove unused method * Fix token saving * Implement HTML view * Update i18n for master token * Revert i18n get_favorite * Fix missing i18n for user queries from before this PR * Remove irrelevant tests * Add link to RSS version * Fix getGet * Fix getState * Fix getSearch * Alternative getSearch * Default getOrder * Explicit default state * Fix test * Add OPML sharing * Remove many redundant SQL queries from original implementation of user queries * Fix article tags * Use default user settings * Prepare public search * Fixes * Allow user search on article tags * Implement user search * Revert filter bug * Revert wrong SQL left outer join change * Implement checkboxes * Safe check of OPML * Fix label * Remove RSS button to favour new sharing method That sharing button was using a global admin token * First version of HTTP 304 * Disallow some recusrivity fix https://github.com/FreshRSS/FreshRSS/issues/6086 * Draft of nav * Minor httpConditional * Add support for offset for pagination * Fix offset pagination * Fix explicit order ASC * Add documentation * Help links i18n * Note about deprecated master token * Typo * Doc about format --- app/Models/FeedDAO.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'app/Models/FeedDAO.php') diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.php index 0744970de..417c59da1 100644 --- a/app/Models/FeedDAO.php +++ b/app/Models/FeedDAO.php @@ -322,7 +322,7 @@ SQL; } /** @var array $res */ - $feeds = self::daoToFeed($res); + $feeds = self::daoToFeeds($res); return $feeds[$id] ?? null; } @@ -331,7 +331,7 @@ SQL; $res = $this->fetchAssoc($sql, [':url' => $url]); /** @var array $res */ - return empty($res[0]) ? null : (current(self::daoToFeed($res)) ?: null); + return empty($res[0]) ? null : (current(self::daoToFeeds($res)) ?: null); } /** @return array */ @@ -343,14 +343,14 @@ SQL; } /** - * @return array + * @return array */ public function listFeeds(): array { $sql = 'SELECT * FROM `_feed` ORDER BY name'; $res = $this->fetchAssoc($sql); /** @var array|null $res */ - return $res == null ? [] : self::daoToFeed($res); + return $res == null ? [] : self::daoToFeeds($res); } /** @return array */ @@ -375,7 +375,7 @@ SQL; /** * @param int $defaultCacheDuration Use -1 to return all feeds, without filtering them by TTL. - * @return array + * @return array */ public function listFeedsOrderUpdate(int $defaultCacheDuration = 3600, int $limit = 0): array { $sql = 'SELECT id, url, kind, category, name, website, `lastUpdate`, `pathEntries`, `httpAuth`, ttl, attributes, `cache_nbEntries`, `cache_nbUnreads` ' @@ -387,7 +387,7 @@ SQL; . ($limit < 1 ? '' : 'LIMIT ' . intval($limit)); $stm = $this->pdo->query($sql); if ($stm !== false) { - return self::daoToFeed($stm->fetchAll(PDO::FETCH_ASSOC)); + return self::daoToFeeds($stm->fetchAll(PDO::FETCH_ASSOC)); } else { $info = $this->pdo->errorInfo(); if ($this->autoUpdateDb($info)) { @@ -409,7 +409,7 @@ SQL; /** * @param bool|null $muted to include only muted feeds - * @return array + * @return array */ public function listByCategory(int $cat, ?bool $muted = null): array { $sql = 'SELECT * FROM `_feed` WHERE category=:category'; @@ -425,9 +425,9 @@ SQL; * @var array $res */ - $feeds = self::daoToFeed($res); + $feeds = self::daoToFeeds($res); - usort($feeds, static function (FreshRSS_Feed $a, FreshRSS_Feed $b) { + uasort($feeds, static function (FreshRSS_Feed $a, FreshRSS_Feed $b) { return strnatcasecmp($a->name(), $b->name()); }); @@ -585,7 +585,7 @@ SQL; * 'pathEntries'?:string,'httpAuth'?:string,'error'?:int|bool,'ttl'?:int,'attributes'?:string,'cache_nbUnreads'?:int,'cache_nbEntries'?:int}> $listDAO * @return array */ - public static function daoToFeed(array $listDAO, ?int $catID = null): array { + public static function daoToFeeds(array $listDAO, ?int $catID = null): array { $list = []; foreach ($listDAO as $key => $dao) { -- cgit v1.2.3