aboutsummaryrefslogtreecommitdiff
path: root/app/Controllers
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-07-25 16:51:48 +0200
committerGravatar GitHub <noreply@github.com> 2019-07-25 16:51:48 +0200
commit82611c9622ed23b0e9fcf5f9f651ddffa1fd7706 (patch)
treefc2c97fd8dd84ec30473cb85b889d8326c9a831a /app/Controllers
parent744a9e8cf00aef7dec0acfa5f90f0dcfa2ef8837 (diff)
parent042b40eeeea77db854daab1bec96fce5c2cdd4b2 (diff)
Merge pull request #2451 from FreshRSS/dev1.14.3
FreshRSS 1.14.3
Diffstat (limited to 'app/Controllers')
-rwxr-xr-xapp/Controllers/feedController.php14
-rwxr-xr-xapp/Controllers/indexController.php2
-rw-r--r--app/Controllers/subscriptionController.php46
-rw-r--r--app/Controllers/userController.php2
4 files changed, 55 insertions, 9 deletions
diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php
index 0aed9b0a1..862bb10fb 100755
--- a/app/Controllers/feedController.php
+++ b/app/Controllers/feedController.php
@@ -243,7 +243,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
}
}
- public static function actualizeFeed($feed_id, $feed_url, $force, $simplePiePush = null, $isNewFeed = false, $noCommit = false) {
+ public static function actualizeFeed($feed_id, $feed_url, $force, $simplePiePush = null, $isNewFeed = false, $noCommit = false, $maxFeeds = 10) {
@set_time_limit(300);
$feedDAO = FreshRSS_Factory::createFeedDao();
@@ -262,6 +262,11 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$feeds = $feedDAO->listFeedsOrderUpdate(-1);
}
+ // Set maxFeeds to a minimum of 10
+ if (!is_int($maxFeeds) || $maxFeeds < 10) {
+ $maxFeeds = 10;
+ }
+
// Calculate date of oldest entries we accept in DB.
$nb_month_old = max(FreshRSS_Context::$user_conf->old_entries, 1);
$date_min = time() - (3600 * 24 * 30 * $nb_month_old);
@@ -459,9 +464,9 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$updated_feeds++;
unset($feed);
- // No more than 10 feeds unless $force is true to avoid overloading
+ // No more than $maxFeeds feeds unless $force is true to avoid overloading
// the server.
- if ($updated_feeds >= 10 && !$force) {
+ if ($updated_feeds >= $maxFeeds && !$force) {
break;
}
}
@@ -497,6 +502,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$id = Minz_Request::param('id');
$url = Minz_Request::param('url');
$force = Minz_Request::param('force');
+ $maxFeeds = (int)Minz_Request::param('maxFeeds');
$noCommit = Minz_Request::fetchPOST('noCommit', 0) == 1;
if ($id == -1 && !$noCommit) { //Special request only to commit & refresh DB cache
@@ -511,7 +517,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
$databaseDAO = FreshRSS_Factory::createDatabaseDAO();
$databaseDAO->minorDbMaintenance();
} else {
- list($updated_feeds, $feed, $nb_new_articles) = self::actualizeFeed($id, $url, $force, null, false, $noCommit);
+ list($updated_feeds, $feed, $nb_new_articles) = self::actualizeFeed($id, $url, $force, null, false, $noCommit, $maxFeeds);
}
if (Minz_Request::param('ajax')) {
diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php
index 824d65815..f536113dd 100755
--- a/app/Controllers/indexController.php
+++ b/app/Controllers/indexController.php
@@ -54,7 +54,7 @@ class FreshRSS_index_Controller extends Minz_ActionController {
}
};
- $this->view->callbackBeforeEntries = function ($view) {
+ $this->view->callbackBeforePagination = function ($view) {
try {
FreshRSS_Context::$number++; //+1 for pagination
$entries = FreshRSS_index_Controller::listEntriesByContext();
diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php
index 9cf41ed0b..79da39751 100644
--- a/app/Controllers/subscriptionController.php
+++ b/app/Controllers/subscriptionController.php
@@ -35,9 +35,20 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {
$this->view->onlyFeedsWithError = Minz_Request::paramTernary('error');
$id = Minz_Request::param('id');
- if ($id !== false) {
- $feedDAO = FreshRSS_Factory::createFeedDao();
- $this->view->feed = $feedDAO->searchById($id);
+ $this->view->displaySlider = false;
+ if (false !== $id) {
+ $type = Minz_Request::param('type');
+ $this->view->displaySlider = true;
+ switch ($type) {
+ case 'category':
+ $categoryDAO = FreshRSS_Factory::createCategoryDao();
+ $this->view->category = $categoryDAO->searchById($id);
+ break;
+ default:
+ $feedDAO = FreshRSS_Factory::createFeedDao();
+ $this->view->feed = $feedDAO->searchById($id);
+ break;
+ }
}
}
@@ -140,6 +151,35 @@ class FreshRSS_subscription_Controller extends Minz_ActionController {
}
}
+ public function categoryAction() {
+ $this->view->_useLayout(false);
+
+ $categoryDAO = FreshRSS_Factory::createCategoryDao();
+
+ $id = Minz_Request::param('id');
+ $category = $categoryDAO->searchById($id);
+ if ($id === false || null === $category) {
+ Minz_Error::error(404);
+ return;
+ }
+ $this->view->category = $category;
+
+ if (Minz_Request::isPost()) {
+ $values = array(
+ 'name' => Minz_Request::param('name', ''),
+ );
+
+ invalidateHttpCache();
+
+ $url_redirect = array('c' => 'subscription', 'params' => array('id' => $id, 'type' => 'category'));
+ if (false !== $categoryDAO->updateCategory($id, $values)) {
+ Minz_Request::good(_t('feedback.sub.category.updated'), $url_redirect);
+ } else {
+ Minz_Request::bad(_t('feedback.sub.category.error'), $url_redirect);
+ }
+ }
+ }
+
/**
* This action displays the bookmarklet page.
*/
diff --git a/app/Controllers/userController.php b/app/Controllers/userController.php
index be3787561..6d0fced5b 100644
--- a/app/Controllers/userController.php
+++ b/app/Controllers/userController.php
@@ -38,7 +38,7 @@ class FreshRSS_user_Controller extends Minz_ActionController {
* The username is also used as folder name, file name, and part of SQL table name.
* '_' is a reserved internal username.
*/
- const USERNAME_PATTERN = '[0-9a-zA-Z_][0-9a-zA-Z_.]{1,38}|[0-9a-zA-Z]';
+ const USERNAME_PATTERN = '([0-9a-zA-Z_][0-9a-zA-Z_.@-]{1,38}|[0-9a-zA-Z])';
public static function checkUsername($username) {
return preg_match('/^' . self::USERNAME_PATTERN . '$/', $username) === 1;