From 449fee7a2cc9453da4aac03f833ccb28205d7d3a Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Fri, 26 Feb 2021 17:31:01 -0500 Subject: "Show all" option on labels (#3472) It uses the favorite option to keep a similar experience through out the application and also to limit the number of options. See #3263 --- app/Models/Context.php | 3 ++- app/Models/TagDAO.php | 13 ++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'app/Models') diff --git a/app/Models/Context.php b/app/Models/Context.php index 1ca99a26d..4f18165c0 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -292,9 +292,10 @@ class FreshRSS_Context { self::$get_unread = $tag->nbUnread(); break; case 'T': + $tagDAO = FreshRSS_Factory::createTagDao(); self::$current_get['tags'] = true; self::$name = _t('index.menu.tags'); - self::$get_unread = 0; + self::$get_unread = $tagDAO->countNotRead(); break; default: throw new FreshRSS_Context_Exception('Invalid getter: ' . $get); diff --git a/app/Models/TagDAO.php b/app/Models/TagDAO.php index 854dc07f2..a9aad519d 100644 --- a/app/Models/TagDAO.php +++ b/app/Models/TagDAO.php @@ -259,12 +259,19 @@ class FreshRSS_TagDAO extends Minz_ModelPdo implements FreshRSS_Searchable { return $res[0]['count']; } - public function countNotRead($id) { + public function countNotRead($id = null) { $sql = 'SELECT COUNT(*) AS count FROM `_entrytag` et ' . 'INNER JOIN `_entry` e ON et.id_entry=e.id ' - . 'WHERE et.id_tag=? AND e.is_read=0'; + . 'WHERE e.is_read=0'; + $values = null; + + if (null !== $id) { + $sql .= ' AND et.id_tag=?'; + $values = [$id]; + } + $stm = $this->pdo->prepare($sql); - $values = array($id); + $stm->execute($values); $res = $stm->fetchAll(PDO::FETCH_ASSOC); return $res[0]['count']; -- cgit v1.2.3