From c8bbf355342985c83054c6c36c6538a780ab509e Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Sun, 29 Jun 2025 11:09:08 +0200 Subject: Add search operator `c:` for categories (#7696) * Add search operator `c:` for categories fix https://github.com/FreshRSS/FreshRSS/discussions/7692 Allow searching for e.g. `c:23,34` --- app/Models/EntryDAO.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'app/Models/EntryDAO.php') diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 68746c380..fecf02cf8 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -917,6 +917,25 @@ SQL; $sub_search .= ') '; } + if ($filter->getCategoryIds() !== null) { + $sub_search .= 'AND ' . $alias . 'id_feed IN (SELECT f.id FROM `_feed` f WHERE f.category IN ('; + foreach ($filter->getCategoryIds() as $category_id) { + $sub_search .= '?,'; + $values[] = $category_id; + } + $sub_search = rtrim($sub_search, ','); + $sub_search .= ')) '; + } + if ($filter->getNotCategoryIds() !== null) { + $sub_search .= 'AND ' . $alias . 'id_feed NOT IN (SELECT f.id FROM `_feed` f WHERE f.category IN ('; + foreach ($filter->getNotCategoryIds() as $category_id) { + $sub_search .= '?,'; + $values[] = $category_id; + } + $sub_search = rtrim($sub_search, ','); + $sub_search .= ')) '; + } + if ($filter->getLabelIds() !== null) { if ($filter->getLabelIds() === '*') { $sub_search .= 'AND EXISTS (SELECT et.id_tag FROM `_entrytag` et WHERE et.id_entry = ' . $alias . 'id) '; -- cgit v1.2.3