aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/Controllers')
-rwxr-xr-xapp/Controllers/configureController.php10
-rwxr-xr-xapp/Controllers/entryController.php4
-rw-r--r--app/Controllers/extensionController.php2
-rwxr-xr-xapp/Controllers/feedController.php23
-rwxr-xr-xapp/Controllers/indexController.php2
-rw-r--r--app/Controllers/subscriptionController.php16
-rw-r--r--app/Controllers/userController.php58
7 files changed, 77 insertions, 38 deletions
diff --git a/app/Controllers/configureController.php b/app/Controllers/configureController.php
index 9d2ee450c..d34b5d59d 100755
--- a/app/Controllers/configureController.php
+++ b/app/Controllers/configureController.php
@@ -55,6 +55,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
FreshRSS_Context::$user_conf->bottomline_date = Minz_Request::param('bottomline_date', false);
FreshRSS_Context::$user_conf->bottomline_link = Minz_Request::param('bottomline_link', false);
FreshRSS_Context::$user_conf->html5_notif_timeout = Minz_Request::param('html5_notif_timeout', 0);
+ FreshRSS_Context::$user_conf->show_nav_buttons = Minz_Request::param('show_nav_buttons', false);
FreshRSS_Context::$user_conf->save();
Minz_Session::_param('language', FreshRSS_Context::$user_conf->language);
@@ -170,7 +171,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
'm', 'n', 'o', 'p', 'page_down', 'page_up', 'q', 'r', 'return', 'right',
's', 'space', 't', 'tab', 'u', 'up', 'v', 'w', 'x', 'y',
'z', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9',
- 'f10', 'f11', 'f12');
+ 'f10', 'f11', 'f12', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0');
$this->view->list_keys = $list_keys;
if (Minz_Request::isPost()) {
@@ -204,16 +205,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/entryController.php b/app/Controllers/entryController.php
index bd8b65b2b..9c6b248a9 100755
--- a/app/Controllers/entryController.php
+++ b/app/Controllers/entryController.php
@@ -177,9 +177,7 @@ class FreshRSS_entry_Controller extends Minz_ActionController {
foreach ($feeds as $feed) {
$feed_history = $feed->keepHistory();
- if ($feed_history == -2) {
- // TODO: -2 must be a constant!
- // -2 means we take the default value from configuration
+ if (FreshRSS_Feed::KEEP_HISTORY_DEFAULT === $feed_history) {
$feed_history = FreshRSS_Context::$user_conf->keep_history_default;
}
diff --git a/app/Controllers/extensionController.php b/app/Controllers/extensionController.php
index bb846e921..311fd2e96 100644
--- a/app/Controllers/extensionController.php
+++ b/app/Controllers/extensionController.php
@@ -240,7 +240,7 @@ class FreshRSS_extension_Controller extends Minz_ActionController {
$res = recursive_unlink($ext->getPath());
if ($res) {
Minz_Request::good(_t('feedback.extensions.removed', $ext_name),
- $url_redirect);
+ $url_redirect);
} else {
Minz_Request::bad(_t('feedback.extensions.cannot_delete', $ext_name),
$url_redirect);
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index fff20f798..7f66b10db 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();
}
/**
@@ -44,6 +45,8 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$catDAO = new FreshRSS_CategoryDAO();
+ $url = trim($url);
+
$cat = null;
if ($new_cat_name != '') {
$new_cat_id = $catDAO->addCategory(array('name' => $new_cat_name));
@@ -282,11 +285,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) {
@@ -316,10 +319,8 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$feed_history = $feed->keepHistory();
if ($isNewFeed) {
- $feed_history = -1; //∞
- } elseif ($feed_history == -2) {
- // TODO: -2 must be a constant!
- // -2 means we take the default value from configuration
+ $feed_history = FreshRSS_Feed::KEEP_HISTORY_INFINITE;
+ } elseif (FreshRSS_Feed::KEEP_HISTORY_DEFAULT === $feed_history) {
$feed_history = FreshRSS_Context::$user_conf->keep_history_default;
}
$needFeedCacheRefresh = false;
@@ -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/indexController.php b/app/Controllers/indexController.php
index e8dde36fa..e3dbd4664 100755
--- a/app/Controllers/indexController.php
+++ b/app/Controllers/indexController.php
@@ -203,7 +203,7 @@ class FreshRSS_index_Controller extends Minz_ActionController {
$entryDAO = FreshRSS_Factory::createEntryDao();
$get = FreshRSS_Context::currentGet(true);
- if (count($get) > 1) {
+ if (is_array($get)) {
$type = $get[0];
$id = $get[1];
} else {
diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php
index 6af048b84..37efd3b57 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)),
+ 'keep_history' => intval(Minz_Request::param('keep_history', FreshRSS_Feed::KEEP_HISTORY_DEFAULT)),
+ 'ttl' => $ttl * ($mute ? -1 : 1),
);
invalidateHttpCache();
diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php
index 2a1d43d9e..2dad6a3f0 100644
--- a/app/Controllers/userController.php
+++ b/app/Controllers/userController.php
@@ -44,29 +44,54 @@ class FreshRSS_user_Controller extends Minz_ActionController {
return preg_match('/^' . self::USERNAME_PATTERN . '$/', $username) === 1;
}
- public static function updateContextUser($passwordPlain, $apiPasswordPlain, $userConfigUpdated = array()) {
+ public static function updateUser($user, $passwordPlain, $apiPasswordPlain, $userConfigUpdated = array()) {
+ $userConfig = get_user_configuration($user);
if ($passwordPlain != '') {
$passwordHash = self::hashPassword($passwordPlain);
- FreshRSS_Context::$user_conf->passwordHash = $passwordHash;
+ $userConfig->passwordHash = $passwordHash;
}
if ($apiPasswordPlain != '') {
$apiPasswordHash = self::hashPassword($apiPasswordPlain);
- FreshRSS_Context::$user_conf->apiPasswordHash = $apiPasswordHash;
+ $userConfig->apiPasswordHash = $apiPasswordHash;
}
if (is_array($userConfigUpdated)) {
foreach ($userConfigUpdated as $configName => $configValue) {
if ($configValue !== null) {
- FreshRSS_Context::$user_conf->_param($configName, $configValue);
+ $userConfig->_param($configName, $configValue);
}
}
}
- $ok = FreshRSS_Context::$user_conf->save();
+ $ok = $userConfig->save();
return $ok;
}
+ public function updateAction() {
+ if (Minz_Request::isPost()) {
+ $passwordPlain = Minz_Request::param('newPasswordPlain', '', true);
+ Minz_Request::_param('newPasswordPlain'); //Discard plain-text password ASAP
+ $_POST['newPasswordPlain'] = '';
+
+ $apiPasswordPlain = Minz_Request::param('apiPasswordPlain', '', true);
+
+ $username = Minz_Request::param('username');
+ $ok = self::updateUser($username, $passwordPlain, $apiPasswordPlain, array(
+ 'token' => Minz_Request::param('token', null),
+ ));
+
+ if ($ok) {
+ Minz_Request::good(_t('feedback.user.updated', $username),
+ array('c' => 'user', 'a' => 'manage'));
+ } else {
+ Minz_Request::bad(_t('feedback.user.updated.error', $username),
+ array('c' => 'user', 'a' => 'manage'));
+ }
+
+ }
+ }
+
/**
* This action displays the user profile page.
*/
@@ -84,7 +109,7 @@ class FreshRSS_user_Controller extends Minz_ActionController {
$apiPasswordPlain = Minz_Request::param('apiPasswordPlain', '', true);
- $ok = self::updateContextUser($passwordPlain, $apiPasswordPlain, array(
+ $ok = self::updateUser(Minz_Session::param('currentUser'), $passwordPlain, $apiPasswordPlain, array(
'token' => Minz_Request::param('token', null),
));
@@ -110,19 +135,18 @@ class FreshRSS_user_Controller extends Minz_ActionController {
Minz_View::prependTitle(_t('admin.user.title') . ' · ');
- // Get the correct current user.
- $username = Minz_Request::param('u', Minz_Session::param('currentUser'));
- if (!FreshRSS_UserDAO::exist($username)) {
- $username = Minz_Session::param('currentUser');
- }
- $this->view->current_user = $username;
+ $this->view->current_user = Minz_Request::param('u');
- // Get information about the current user.
- $entryDAO = FreshRSS_Factory::createEntryDao($this->view->current_user);
- $this->view->nb_articles = $entryDAO->count();
+ $this->view->nb_articles = 0;
+ $this->view->size_user = 0;
+ if ($this->view->current_user) {
+ // Get information about the current user.
+ $entryDAO = FreshRSS_Factory::createEntryDao($this->view->current_user);
+ $this->view->nb_articles = $entryDAO->count();
- $databaseDAO = FreshRSS_Factory::createDatabaseDAO();
- $this->view->size_user = $databaseDAO->size();
+ $databaseDAO = FreshRSS_Factory::createDatabaseDAO();
+ $this->view->size_user = $databaseDAO->size();
+ }
}
public static function createUser($new_user_name, $passwordPlain, $apiPasswordPlain, $userConfig = array(), $insertDefaultFeeds = true) {