summaryrefslogtreecommitdiff
path: root/app/Controllers
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/Controllers
parente73fae159168b1ed9c0469e1d5bce55a3ef1f911 (diff)
Add mute strategy configuration (#1750)
Diffstat (limited to 'app/Controllers')
-rwxr-xr-xapp/Controllers/configureController.php7
-rwxr-xr-xapp/Controllers/feedController.php15
-rw-r--r--app/Controllers/subscriptionController.php14
3 files changed, 26 insertions, 10 deletions
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php
index de70e475b..2c7739c55 100755
--- a/app/Controllers/configureController.php
+++ b/app/Controllers/configureController.php
@@ -204,16 +204,13 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
* The options available on that page are:
* - duration to retain old article (default: 3)
* - number of article to retain per feed (default: 0)
- * - refresh frequency (default: -2)
- *
- * @todo explain why the default value is -2 but this value does not
- * exist in the drop-down list
+ * - refresh frequency (default: 0)
*/
public function archivingAction() {
if (Minz_Request::isPost()) {
FreshRSS_Context::$user_conf->old_entries = Minz_Request::param('old_entries', 3);
FreshRSS_Context::$user_conf->keep_history_default = Minz_Request::param('keep_history_default', 0);
- FreshRSS_Context::$user_conf->ttl_default = Minz_Request::param('ttl_default', -2);
+ FreshRSS_Context::$user_conf->ttl_default = Minz_Request::param('ttl_default', FreshRSS_Feed::TTL_DEFAULT);
FreshRSS_Context::$user_conf->save();
invalidateHttpCache();
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index fff20f798..2793577d5 100755
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -24,6 +24,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
Minz_Error::error(403);
}
}
+ $this->updateTTL();
}
/**
@@ -282,11 +283,11 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$mtime = 0;
$ttl = $feed->ttl();
- if ($ttl == -1) {
+ if ($ttl < FreshRSS_Feed::TTL_DEFAULT) {
continue; //Feed refresh is disabled
}
if ((!$simplePiePush) && (!$feed_id) &&
- ($feed->lastUpdate() + 10 >= time() - ($ttl == -2 ? FreshRSS_Context::$user_conf->ttl_default : $ttl))) {
+ ($feed->lastUpdate() + 10 >= time() - ($ttl == FreshRSS_Feed::TTL_DEFAULT ? FreshRSS_Context::$user_conf->ttl_default : $ttl))) {
//Too early to refresh from source, but check whether the feed was updated by another user
$mtime = $feed->cacheModifiedTime();
if ($feed->lastUpdate() + 10 >= $mtime) {
@@ -639,4 +640,14 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
Minz_Request::bad(_t('feedback.sub.feed.error'), $redirect_url);
}
}
+
+ /**
+ * This method update TTL values for feeds if needed.
+ * It changes the old default value (-2) to the new default value (0).
+ * It changes the old disabled value (-1) to the default disabled value.
+ */
+ private function updateTTL() {
+ $feedDAO = FreshRSS_Factory::createFeedDao();
+ $feedDAO->updateTTL();
+ }
}
diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php
index 6af048b84..b3f3df46e 100644
--- a/app/Controllers/subscriptionController.php
+++ b/app/Controllers/subscriptionController.php
@@ -15,8 +15,10 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {
}
$catDAO = new FreshRSS_CategoryDAO();
+ $feedDAO = new FreshRSS_FeedDAO();
$catDAO->checkDefault();
+ $feedDAO->updateTTL();
$this->view->categories = $catDAO->listCategories(false);
$this->view->default_category = $catDAO->getDefault();
}
@@ -55,7 +57,7 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {
* - display in main stream (default: 0)
* - HTTP authentication
* - number of article to retain (default: -2)
- * - refresh frequency (default: -2)
+ * - refresh frequency (default: 0)
* Default values are empty strings unless specified.
*/
public function feedAction() {
@@ -87,6 +89,12 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {
$cat = intval(Minz_Request::param('category', 0));
+ $mute = Minz_Request::param('mute', false);
+ $ttl = intval(Minz_Request::param('ttl', FreshRSS_Feed::TTL_DEFAULT));
+ if ($mute && FreshRSS_Feed::TTL_DEFAULT === $ttl) {
+ $ttl = FreshRSS_Context::$user_conf->ttl_default;
+ }
+
$values = array(
'name' => Minz_Request::param('name', ''),
'description' => sanitizeHTML(Minz_Request::param('description', '', true)),
@@ -94,10 +102,10 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {
'url' => checkUrl(Minz_Request::param('url', '')),
'category' => $cat,
'pathEntries' => Minz_Request::param('path_entries', ''),
- 'priority' => intval(Minz_Request::param('priority', 0)),
+ 'priority' => intval(Minz_Request::param('priority', FreshRSS_Feed::PRIORITY_MAIN_STREAM)),
'httpAuth' => $httpAuth,
'keep_history' => intval(Minz_Request::param('keep_history', -2)),
- 'ttl' => intval(Minz_Request::param('ttl', -2)),
+ 'ttl' => $ttl * ($mute ? -1 : 1),
);
invalidateHttpCache();