summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-15 04:07:12 +0100
committerGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2013-12-15 04:07:12 +0100
commit7e64cda41548500c25825cca29bb7e0167249b83 (patch)
tree713c590a4d3e10e46861c4ec8ad1247dcf4a2e3a
parent83e8c68b6f9fc563230920ee520eae138898a2c1 (diff)
Date minimum pour afficher les articles
Implémente décision https://github.com/marienfressinaud/FreshRSS/issues/323
-rw-r--r--app/Models/EntryDAO.php7
-rwxr-xr-xapp/controllers/feedController.php6
-rwxr-xr-xapp/controllers/indexController.php8
3 files changed, 14 insertions, 7 deletions
diff --git a/app/Models/EntryDAO.php b/app/Models/EntryDAO.php
index 8c18150b6..b61b97624 100644
--- a/app/Models/EntryDAO.php
+++ b/app/Models/EntryDAO.php
@@ -259,7 +259,7 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
return isset ($entries[0]) ? $entries[0] : false;
}
- public function listWhere($type = 'a', $id = '', $state = 'all', $order = 'DESC', $limit = 1, $firstId = -1, $filter = '') {
+ public function listWhere($type = 'a', $id = '', $state = 'all', $order = 'DESC', $limit = 1, $firstId = '', $filter = '', $date_min = 0) {
$where = '';
$values = array();
switch ($type) {
@@ -299,9 +299,12 @@ class FreshRSS_EntryDAO extends Minz_ModelPdo {
default:
throw new FreshRSS_EntriesGetter_Exception ('Bad order in Entry->listByType: [' . $order . ']!');
}
- if ($firstId > 0) {
+ if ($firstId !== '') {
$where .= 'AND e.id ' . ($order === 'DESC' ? '<=' : '>=') . $firstId . ' ';
}
+ if ($date_min > 0) {
+ $where .= 'AND e.id >= ' . $date_min . '000000 ';
+ }
$terms = array_unique(explode(' ', trim($filter)));
sort($terms); //Put #tags first
$having = '';
diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php
index e4014c326..a85877724 100755
--- a/app/controllers/feedController.php
+++ b/app/controllers/feedController.php
@@ -96,7 +96,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
// on calcule la date des articles les plus anciens qu'on accepte
$nb_month_old = $this->view->conf->oldEntries ();
- $date_min = time () - (60 * 60 * 24 * 30 * $nb_month_old);
+ $date_min = time () - (3600 * 24 * 30 * $nb_month_old);
$transactionStarted = true;
$feedDAO->beginTransaction ();
@@ -196,7 +196,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
// on calcule la date des articles les plus anciens qu'on accepte
$nb_month_old = $this->view->conf->oldEntries ();
- $date_min = time () - (60 * 60 * 24 * 30 * $nb_month_old);
+ $date_min = time () - (3600 * 24 * 30 * $nb_month_old);
$i = 0;
$flux_update = 0;
@@ -310,7 +310,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
// on calcule la date des articles les plus anciens qu'on accepte
$nb_month_old = $this->view->conf->oldEntries ();
- $date_min = time () - (60 * 60 * 24 * 30 * $nb_month_old);
+ $date_min = time () - (3600 * 24 * 30 * $nb_month_old);
// la variable $error permet de savoir si une erreur est survenue
// Le but est de ne pas arrêter l'import même en cas d'erreur
diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php
index 16a053ba3..92070590a 100755
--- a/app/controllers/indexController.php
+++ b/app/controllers/indexController.php
@@ -124,15 +124,19 @@ class FreshRSS_index_Controller extends Minz_ActionController {
}
}
+ // on calcule la date des articles les plus anciens qu'on affiche
+ $nb_month_old = $this->view->conf->oldEntries ();
+ $date_min = time () - (3600 * 24 * 30 * $nb_month_old);
+
try {
- $entries = $this->entryDAO->listWhere($getType, $getId, $state, $order, $nb + 1, $first, $filter);
+ $entries = $this->entryDAO->listWhere($getType, $getId, $state, $order, $nb + 1, $first, $filter, $date_min);
// Si on a récupéré aucun article "non lus"
// on essaye de récupérer tous les articles
if ($state === 'not_read' && empty($entries)) { //TODO: Remove in v0.8
Minz_Log::record ('Conflicting information about nbNotRead!', Minz_Log::DEBUG);
$this->view->state = 'all';
- $entries = $this->entryDAO->listWhere($getType, $getId, 'all', $order, $nb, $first, $filter);
+ $entries = $this->entryDAO->listWhere($getType, $getId, 'all', $order, $nb, $first, $filter, $date_min);
}
if (count($entries) <= $nb) {