A free, self-hostable news aggregator…
Nouveau bouton pour lancer manuellement la purge des vieux articles
Alexandre Alapetite7eda2793bbc3
diff --git a/app/Controllers/entryController.php b/app/Controllers/entryController.phpindex a332ca8a9..1c3c56c4d 100755--- a/app/Controllers/entryController.php+++ b/app/Controllers/entryController.php@@ -109,4 +109,45 @@ class FreshRSS_entry_Controller extends Minz_ActionController {'a' => 'display'), true);}++ public function purgeAction() {+ @set_time_limit(300);++ $nb_month_old = max($this->view->conf->oldEntries(), 1);+ $date_min = time() - (3600 * 24 * 30 * $nb_month_old);++ $feedDAO = new FreshRSS_FeedDAO();+ $feeds = $feedDAO->listFeedsOrderUpdate();+ $nbTotal = 0;++ invalidateHttpCache();++ foreach ($feeds as $feed) {+ $feedHistory = $feed->keepHistory();+ if ($feedHistory == -2) { //default+ $feedHistory = $this->view->conf->keepHistoryDefault();+ }+ if ($feedHistory >= 0) {+ $nb = $feedDAO->cleanOldEntries($feed->id(), $date_min, $feedHistory);+ if ($nb > 0) {+ $nbTotal += $nb;+ Minz_Log::record($nb . ' old entries cleaned in feed ' . $feed->id(), Minz_Log::DEBUG);+ $feedDAO->updateLastUpdate($feed->id());+ }+ }+ }++ invalidateHttpCache();++ $notif = array(+ 'type' => 'good',+ 'content' => Minz_Translate::t('purge_completed', $nbTotal)+ );+ Minz_Session::_param('notification', $notif);++ Minz_Request::forward(array(+ 'c' => 'configure',+ 'a' => 'display'+ ), true);+ }}diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.phpindex 836044da6..04d0aa98b 100755--- a/app/Controllers/feedController.php+++ b/app/Controllers/feedController.php@@ -192,7 +192,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 ();+ $nb_month_old = max($this->view->conf->oldEntries(), 1);$date_min = time () - (3600 * 24 * 30 * $nb_month_old);$i = 0;diff --git a/app/Models/FeedDAO.php b/app/Models/FeedDAO.phpindex c1d1f24e8..d517f9580 100644--- a/app/Models/FeedDAO.php+++ b/app/Models/FeedDAO.php@@ -315,20 +315,23 @@ class FreshRSS_FeedDAO extends Minz_ModelPdo {if (isset ($dao['id'])) {$key = $dao['id'];}+ if ($catID === null) {+ $catID = isset($dao['category']) ? $dao['category'] : 0;+ }- $myFeed = new FreshRSS_Feed (isset($dao['url']) ? $dao['url'] : '', false);- $myFeed->_category ($catID === null ? $dao['category'] : $catID);- $myFeed->_name ($dao['name']);- $myFeed->_website ($dao['website'], false);- $myFeed->_description (isset($dao['description']) ? $dao['description'] : '');- $myFeed->_lastUpdate (isset($dao['lastUpdate']) ? $dao['lastUpdate'] : 0);- $myFeed->_priority ($dao['priority']);- $myFeed->_pathEntries (isset($dao['pathEntries']) ? $dao['pathEntries'] : '');- $myFeed->_httpAuth (isset($dao['httpAuth']) ? base64_decode ($dao['httpAuth']) : '');- $myFeed->_error ($dao['error']);+ $myFeed = new FreshRSS_Feed(isset($dao['url']) ? $dao['url'] : '', false);+ $myFeed->_category(intval($catID));+ $myFeed->_name($dao['name']);+ $myFeed->_website(isset($dao['website']) ? $dao['website'] : '', false);+ $myFeed->_description(isset($dao['description']) ? $dao['description'] : '');+ $myFeed->_lastUpdate(isset($dao['lastUpdate']) ? $dao['lastUpdate'] : 0);+ $myFeed->_priority(isset($dao['priority']) ? $dao['priority'] : 10);+ $myFeed->_pathEntries(isset($dao['pathEntries']) ? $dao['pathEntries'] : '');+ $myFeed->_httpAuth(isset($dao['httpAuth']) ? base64_decode ($dao['httpAuth']) : '');+ $myFeed->_error(isset($dao['error']) ? $dao['error'] : 0);$myFeed->_keepHistory(isset($dao['keep_history']) ? $dao['keep_history'] : -2);- $myFeed->_nbNotRead ($dao['cache_nbUnreads']);- $myFeed->_nbEntries ($dao['cache_nbEntries']);+ $myFeed->_nbNotRead(isset($dao['cache_nbUnreads']) ? $dao['cache_nbUnreads'] : 0);+ $myFeed->_nbEntries(isset($dao['cache_nbEntries']) ? $dao['cache_nbEntries'] : 0);if (isset ($dao['id'])) {$myFeed->_id ($dao['id']);}diff --git a/app/i18n/en.php b/app/i18n/en.phpindex ca72d885c..498fccd14 100644--- a/app/i18n/en.php+++ b/app/i18n/en.php@@ -168,6 +168,8 @@ return array ('login_configuration' => 'Login','archiving_configuration' => 'Archiving','delete_articles_every' => 'Remove articles after',+ 'purge_now' => 'Purge now',+ 'purge_completed' => 'Purge completed (%d articles deleted)','archiving_configuration_help' => 'More options are available in the individual stream settings','reading_configuration' => 'Reading','articles_per_page' => 'Number of articles per page',diff --git a/app/i18n/fr.php b/app/i18n/fr.phpindex 053a97c8a..c918daa44 100644--- a/app/i18n/fr.php+++ b/app/i18n/fr.php@@ -169,6 +169,8 @@ return array ('login_configuration' => 'Identification','archiving_configuration' => 'Archivage','delete_articles_every' => 'Supprimer les articles après',+ 'purge_now' => 'Purger maintenant',+ 'purge_completed' => 'Purge effectuée (%d articles supprimés)','archiving_configuration_help' => 'D’autres options sont disponibles dans la configuration individuelle des flux','reading_configuration' => 'Lecture','articles_per_page' => 'Nombre d’articles par page',diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtmlindex 3280f657f..fca533752 100644--- a/app/views/configure/display.phtml+++ b/app/views/configure/display.phtml@@ -76,6 +76,7 @@<label class="group-name" for="old_entries"><?php echo Minz_Translate::t ('delete_articles_every'); ?></label><div class="group-controls"><input type="number" id="old_entries" name="old_entries" min="1" max="1200" value="<?php echo $this->conf->oldEntries (); ?>" /> <?php echo Minz_Translate::t ('month'); ?>+ <a class="btn confirm" href="<?php echo _url('entry', 'purge'); ?>"><?php echo Minz_Translate::t('purge_now'); ?></a></div></div><div class="form-group">