diff options
| author | 2020-06-05 10:09:31 +0200 | |
|---|---|---|
| committer | 2020-06-05 10:09:31 +0200 | |
| commit | d4554fa087f9057610085ca685cd8fb79d8f2bd0 (patch) | |
| tree | 60ab634136516e98d0885d1033a5636233f837b7 /app/Controllers | |
| parent | 27f0b614189c090028dfb9a56d1b21f1adf263d4 (diff) | |
Change add feed action (#3027)
* Docker Alpine 3.12 (#3025)
https://alpinelinux.org/posts/Alpine-3.12.0-released.html
With PHP 7.3.18 (from 7.3.17) (and Apache 2.4.43 unchanged).
No other significant change spotted
* Ensure feed attributes are used before load
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'app/Controllers')
| -rw-r--r-- | app/Controllers/categoryController.php | 3 | ||||
| -rwxr-xr-x | app/Controllers/feedController.php | 28 | ||||
| -rw-r--r-- | app/Controllers/subscriptionController.php | 7 |
3 files changed, 26 insertions, 12 deletions
diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php index 2551a79d4..1d0359a39 100644 --- a/app/Controllers/categoryController.php +++ b/app/Controllers/categoryController.php @@ -28,7 +28,7 @@ class FreshRSS_category_Controller extends Minz_ActionController { */ public function createAction() { $catDAO = FreshRSS_Factory::createCategoryDao(); - $url_redirect = array('c' => 'subscription', 'a' => 'index'); + $url_redirect = array('c' => 'subscription', 'a' => 'add'); $limits = FreshRSS_Context::$system_conf->limits; $this->view->categories = $catDAO->listCategories(false); @@ -58,6 +58,7 @@ class FreshRSS_category_Controller extends Minz_ActionController { ); if ($catDAO->addCategory($values)) { + $url_redirect['a'] = 'index'; Minz_Request::good(_t('feedback.sub.category.created', $cat->name()), $url_redirect); } else { Minz_Request::bad(_t('feedback.sub.category.error'), $url_redirect); diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.php index 4750f4558..81c54f161 100755 --- a/app/Controllers/feedController.php +++ b/app/Controllers/feedController.php @@ -39,7 +39,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { * @throws FreshRSS_Feed_Exception * @throws Minz_FileNotExistException */ - public static function addFeed($url, $title = '', $cat_id = 0, $new_cat_name = '', $http_auth = '') { + public static function addFeed($url, $title = '', $cat_id = 0, $new_cat_name = '', $http_auth = '', $attributes = array()) { FreshRSS_UserDAO::touch(); @set_time_limit(300); @@ -67,6 +67,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $cat_id = $cat == null ? FreshRSS_CategoryDAO::DEFAULTCATEGORYID : $cat->id(); $feed = new FreshRSS_Feed($url); //Throws FreshRSS_BadUrl_Exception + $feed->_attributes('', $attributes); $feed->_httpAuth($http_auth); $feed->load(true); //Throws FreshRSS_Feed_Exception, Minz_FileNotExistException $feed->_category($cat_id); @@ -90,7 +91,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { 'description' => $feed->description(), 'lastUpdate' => time(), 'httpAuth' => $feed->httpAuth(), - 'attributes' => array(), + 'attributes' => $feed->attributes(), ); $id = $feedDAO->addFeed($values); @@ -141,7 +142,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feedDAO = FreshRSS_Factory::createFeedDao(); $url_redirect = array( 'c' => 'subscription', - 'a' => 'index', + 'a' => 'add', 'params' => array(), ); @@ -154,13 +155,6 @@ class FreshRSS_feed_Controller extends Minz_ActionController { if (Minz_Request::isPost()) { $cat = Minz_Request::param('category'); - $new_cat_name = ''; - if ($cat === 'nc') { - // User want to create a new category, new_category parameter - // must exist - $new_cat = Minz_Request::param('new_category'); - $new_cat_name = isset($new_cat['name']) ? trim($new_cat['name']) : ''; - } // HTTP information are useful if feed is protected behind a // HTTP authentication @@ -171,8 +165,18 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $http_auth = $user . ':' . $pass; } + $attributes = array( + 'ssl_verify' => null, + 'timeout' => null, + ); + if (FreshRSS_Auth::hasAccess('admin')) { + $attributes['ssl_verify'] = Minz_Request::paramTernary('ssl_verify'); + $timeout = intval(Minz_Request::param('timeout', 0)); + $attributes['timeout'] = $timeout > 0 ? $timeout : null; + } + try { - $feed = self::addFeed($url, '', $cat, $new_cat_name, $http_auth); + $feed = self::addFeed($url, '', $cat, null, $http_auth, $attributes); } catch (FreshRSS_BadUrl_Exception $e) { // Given url was not a valid url! Minz_Log::warning($e->getMessage()); @@ -192,6 +196,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { } // Entries are in DB, we redirect to feed configuration page. + $url_redirect['a'] = 'index'; $url_redirect['params']['id'] = $feed->id(); Minz_Request::good(_t('feedback.sub.feed.added', $feed->name()), $url_redirect); } else { @@ -212,6 +217,7 @@ class FreshRSS_feed_Controller extends Minz_ActionController { $feed = $feedDAO->searchByUrl($this->view->feed->url()); if ($feed) { // Already subscribe so we redirect to the feed configuration page. + $url_redirect['a'] = 'index'; $url_redirect['params']['id'] = $feed->id(); Minz_Request::good(_t('feedback.sub.feed.already_subscribed', $feed->name()), $url_redirect); } diff --git a/app/Controllers/subscriptionController.php b/app/Controllers/subscriptionController.php index b4520c8e6..1be0fd376 100644 --- a/app/Controllers/subscriptionController.php +++ b/app/Controllers/subscriptionController.php @@ -241,4 +241,11 @@ class FreshRSS_subscription_Controller extends Minz_ActionController { public function bookmarkletAction() { Minz_View::prependTitle(_t('sub.title.subscription_tools') . ' . '); } + + /** + * This action displays the page to add a new feed + */ + public function addAction() { + Minz_View::prependTitle(_t('sub.title.add') . ' . '); + } } |
