aboutsummaryrefslogtreecommitdiff
path: root/app/Models/EntryDAO.php
diff options
context:
space:
mode:
authorGravatar Alexis Degrugillier <aledeg@users.noreply.github.com> 2018-01-01 20:34:06 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2018-01-01 20:34:06 +0100
commit8c2113f9e6eb86b630a4e861513229d7abf219b8 (patch)
tree6e9ca68cf291a21d573f82ff7818c66e40a7ec30 /app/Models/EntryDAO.php
parente73fae159168b1ed9c0469e1d5bce55a3ef1f911 (diff)
Add mute strategy configuration (#1750)
Diffstat (limited to 'app/Models/EntryDAO.php')
-rw-r--r--app/Models/EntryDAO.php40
1 files changed, 28 insertions, 12 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index e8b6dcdae..9e291f4ed 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -726,23 +726,23 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
$values = array();
switch ($type) {
case 'a':
- $where .= 'f.priority > 0 ';
- $joinFeed = true;
+ $where .= 'f.priority > ' . FreshRSS_Feed::PRIORITY_NORMAL . ' ';
break;
case 's': //Deprecated: use $state instead
- $where .= 'e.is_favorite=1 ';
+ $where .= 'f.priority >= ' . FreshRSS_Feed::PRIORITY_NORMAL . ' ';
+ $where .= 'AND e.is_favorite=1 ';
break;
case 'c':
- $where .= 'f.category=? ';
+ $where .= 'f.priority >= ' . FreshRSS_Feed::PRIORITY_NORMAL . ' ';
+ $where .= 'AND f.category=? ';
$values[] = intval($id);
- $joinFeed = true;
break;
case 'f':
$where .= 'e.id_feed=? ';
$values[] = intval($id);
break;
case 'A':
- $where .= '1=1 ';
+ $where .= 'f.priority >= ' . FreshRSS_Feed::PRIORITY_NORMAL . ' ';
break;
default:
throw new FreshRSS_EntriesGetter_Exception('Bad type in Entry->listByType: [' . $type . ']!');
@@ -752,7 +752,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
return array(array_merge($values, $searchValues),
'SELECT e.id FROM `' . $this->prefix . 'entry` e '
- . ($joinFeed ? 'INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed=f.id ' : '')
+ . 'INNER JOIN `' . $this->prefix . 'feed` f ON e.id_feed = f.id '
. 'WHERE ' . $where
. $search
. 'ORDER BY e.id ' . $order
@@ -873,12 +873,28 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo implements FreshRSS_Searchable {
}
public function countUnreadReadFavorites() {
- $sql = 'SELECT c FROM ('
- . 'SELECT COUNT(id) AS c, 1 as o FROM `' . $this->prefix . 'entry` WHERE is_favorite=1 '
- . 'UNION SELECT COUNT(id) AS c, 2 AS o FROM `' . $this->prefix . 'entry` WHERE is_favorite=1 AND is_read=0'
- . ') u ORDER BY o';
+ $sql = <<<SQL
+ SELECT c
+ FROM (
+ SELECT COUNT(e1.id) AS c
+ , 1 AS o
+ FROM `{$this->prefix}entry` AS e1
+ JOIN `{$this->prefix}feed` AS f1 ON e1.id_feed = f1.id
+ WHERE e1.is_favorite = 1
+ AND f1.priority >= :priority_normal
+ UNION
+ SELECT COUNT(e2.id) AS c
+ , 2 AS o
+ FROM `{$this->prefix}entry` AS e2
+ JOIN `{$this->prefix}feed` AS f2 ON e2.id_feed = f2.id
+ WHERE e2.is_favorite = 1
+ AND e2.is_read = 0
+ AND f2.priority >= :priority_normal
+ ) u
+ORDER BY o
+SQL;
$stm = $this->bd->prepare($sql);
- $stm->execute();
+ $stm->execute(array(':priority_normal' => FreshRSS_Feed::PRIORITY_NORMAL));
$res = $stm->fetchAll(PDO::FETCH_COLUMN, 0);
$all = empty($res[0]) ? 0 : $res[0];
$unread = empty($res[1]) ? 0 : $res[1];