diff options
| author | 2014-04-15 12:16:31 +0200 | |
|---|---|---|
| committer | 2014-04-15 12:16:31 +0200 | |
| commit | f25783ef5de2c4b7f9746eb7ad92fb0b018738b1 (patch) | |
| tree | 2dfc4271bc36d774adc88ef24cb8290842283f13 /app/Models/EntryDAO.php | |
| parent | 339a12698c07eb466c6a1ab8ffa856d8a8e1f506 (diff) | |
Minor syntax changes for: New toggle buttons to filter articles
See
http://programmers.stackexchange.com/questions/23852/bitwise-or-vs-adding-flags
https://github.com/marienfressinaud/FreshRSS/pull/486
https://github.com/marienfressinaud/FreshRSS/issues/376
Diffstat (limited to 'app/Models/EntryDAO.php')
| -rw-r--r-- | app/Models/EntryDAO.php | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php index 285ad431f..73893a88d 100644 --- a/app/Models/EntryDAO.php +++ b/app/Models/EntryDAO.php @@ -406,7 +406,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { return isset ($entries[0]) ? $entries[0] : null; } - private function sqlListWhere($type = 'a', $id = '', $state = null , $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $showOlderUnreadsorFavorites = false, $keepHistoryDefault = 0) { + private function sqlListWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $showOlderUnreadsorFavorites = false, $keepHistoryDefault = 0) { if (!$state) { $state = FreshRSS_Entry::STATE_ALL; } @@ -418,8 +418,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { $where .= 'f.priority > 0 '; $joinFeed = true; break; - case 's': - // This is deprecated. The favorite button does not exist anymore + case 's': //Deprecated: use $state instead $where .= 'e1.is_favorite = 1 '; break; case 'c': @@ -443,21 +442,17 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { $where .= 'AND e1.is_read = 0 '; } } - if ($state & FreshRSS_Entry::STATE_READ) { - if (!($state & FreshRSS_Entry::STATE_NOT_READ)) { - $where .= 'AND e1.is_read = 1 '; - } - } - if ($state & FreshRSS_Entry::STATE_NOT_FAVORITE) { - if (!($state & FreshRSS_Entry::STATE_FAVORITE)) { - $where .= 'AND e1.is_favorite = 0 '; - } + elseif ($state & FreshRSS_Entry::STATE_READ) { + $where .= 'AND e1.is_read = 1 '; } if ($state & FreshRSS_Entry::STATE_FAVORITE) { if (!($state & FreshRSS_Entry::STATE_NOT_FAVORITE)) { $where .= 'AND e1.is_favorite = 1 '; } } + elseif ($state & FreshRSS_Entry::STATE_NOT_FAVORITE) { + $where .= 'AND e1.is_favorite = 0 '; + } switch ($order) { case 'DESC': @@ -539,7 +534,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { . ($limit > 0 ? ' LIMIT ' . $limit : '')); //TODO: See http://explainextended.com/2009/10/23/mysql-order-by-limit-performance-late-row-lookups/ } - public function listWhere($type = 'a', $id = '', $state = null, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $showOlderUnreadsorFavorites = false, $keepHistoryDefault = 0) { + public function listWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $showOlderUnreadsorFavorites = false, $keepHistoryDefault = 0) { list($values, $sql) = $this->sqlListWhere($type, $id, $state, $order, $limit, $firstId, $filter, $date_min, $showOlderUnreadsorFavorites, $keepHistoryDefault); $sql = 'SELECT e.id, e.guid, e.title, e.author, UNCOMPRESS(e.content_bin) AS content, e.link, e.date, e.is_read, e.is_favorite, e.id_feed, e.tags ' @@ -555,7 +550,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo { return self::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC)); } - public function listIdsWhere($type = 'a', $id = '', $state = null, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $showOlderUnreadsorFavorites = false, $keepHistoryDefault = 0) { //For API + public function listIdsWhere($type = 'a', $id = '', $state = FreshRSS_Entry::STATE_ALL, $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0, $showOlderUnreadsorFavorites = false, $keepHistoryDefault = 0) { //For API list($values, $sql) = $this->sqlListWhere($type, $id, $state, $order, $limit, $firstId, $filter, $date_min, $showOlderUnreadsorFavorites, $keepHistoryDefault); $stm = $this->bd->prepare($sql); |
