From f13ef3b102e2724367572f37a1fc57400b443280 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Fri, 31 Dec 2021 13:13:03 +0100 Subject: Fix article filter (#4092) #fix https://github.com/FreshRSS/FreshRSS/issues/4057 Several search filters where missing for the automatic article actions --- app/Models/Entry.php | 44 +++++++++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 13 deletions(-) (limited to 'app/Models/Entry.php') diff --git a/app/Models/Entry.php b/app/Models/Entry.php index f75c0d704..d3aa13327 100644 --- a/app/Models/Entry.php +++ b/app/Models/Entry.php @@ -260,27 +260,35 @@ class FreshRSS_Entry extends Minz_Model { } foreach ($booleanSearch->searches() as $filter) { $ok = true; + if ($ok && $filter->getMinDate()) { + $ok &= strnatcmp($this->id, $filter->getMinDate() . '000000') >= 0; + } + if ($ok && $filter->getNotMinDate()) { + $ok &= strnatcmp($this->id, $filter->getNotMinDate() . '000000') < 0; + } + if ($ok && $filter->getMaxDate()) { + $ok &= strnatcmp($this->id, $filter->getMaxDate() . '000000') <= 0; + } + if ($ok && $filter->getNotMaxDate()) { + $ok &= strnatcmp($this->id, $filter->getNotMaxDate() . '000000') > 0; + } if ($ok && $filter->getMinPubdate()) { $ok &= $this->date >= $filter->getMinPubdate(); } + if ($ok && $filter->getNotMinPubdate()) { + $ok &= $this->date < $filter->getNotMinPubdate(); + } if ($ok && $filter->getMaxPubdate()) { $ok &= $this->date <= $filter->getMaxPubdate(); } - if ($ok && $filter->getMinDate()) { - $ok &= strnatcmp($this->id, $filter->getMinDate() . '000000') >= 0; - } - if ($ok && $filter->getMaxDate()) { - $ok &= strnatcmp($this->id, $filter->getMaxDate() . '000000') <= 0; + if ($ok && $filter->getNotMaxPubdate()) { + $ok &= $this->date > $filter->getNotMaxPubdate(); } - if ($ok && $filter->getInurl()) { - foreach ($filter->getInurl() as $url) { - $ok &= stripos($this->link, $url) !== false; - } + if ($ok && $filter->getFeedIds()) { + $ok &= in_array($this->feedId, $filter->getFeedIds()); } - if ($ok && $filter->getNotInurl()) { - foreach ($filter->getNotInurl() as $url) { - $ok &= stripos($this->link, $url) === false; - } + if ($ok && $filter->getNotFeedIds()) { + $ok &= !in_array($this->feedId, $filter->getFeedIds()); } if ($ok && $filter->getAuthor()) { foreach ($filter->getAuthor() as $author) { @@ -324,6 +332,16 @@ class FreshRSS_Entry extends Minz_Model { $ok &= !$found; } } + if ($ok && $filter->getInurl()) { + foreach ($filter->getInurl() as $url) { + $ok &= stripos($this->link, $url) !== false; + } + } + if ($ok && $filter->getNotInurl()) { + foreach ($filter->getNotInurl() as $url) { + $ok &= stripos($this->link, $url) === false; + } + } if ($ok && $filter->getSearch()) { foreach ($filter->getSearch() as $needle) { $ok &= (stripos($this->title, $needle) !== false || stripos($this->content, $needle) !== false); -- cgit v1.2.3