A free, self-hostable news aggregator…
Move empty cat action in the new Controller
Marien Fressinaud9e0a62727f8f
diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.phpindex e2d98a509..6863c3bb8 100644--- a/app/Controllers/categoryController.php+++ b/app/Controllers/categoryController.php@@ -26,7 +26,7 @@ class FreshRSS_category_Controller extends Minz_ActionController {/*** This action creates a new category.*- * URL parameter is:+ * Request parameter is:* - new-category*/public function createAction() {@@ -55,7 +55,46 @@ class FreshRSS_category_Controller extends Minz_ActionController {if ($catDAO->addCategory($values)) {Minz_Request::good(_t('category_created', $cat->name()), $url_redirect);} else {- Minz_Request::bad(_t('category_not_created'), $url_redirect);+ Minz_Request::bad(_t('error_occured'), $url_redirect);+ }+ }++ Minz_Request::forward($url_redirect, true);+ }++ /**+ * This action deletes all the feeds relative to a given category+ *+ * Request parameter is:+ * - id (of a category)+ */+ public function emptyAction() {+ $feedDAO = FreshRSS_Factory::createFeedDao();+ $url_redirect = array('c' => 'configure', 'a' => 'categorize');++ if (Minz_Request::isPost()) {+ invalidateHttpCache();++ $id = Minz_Request::param('id');+ if (!$id) {+ Minz_Request::bad(_t('category_no_id'), $url_redirect);+ }++ // List feeds to remove then related user queries.+ $feeds = $feedDAO->listByCategory($id);++ if ($feedDAO->deleteFeedByCategory($id)) {+ // TODO: Delete old favicons++ // Remove related queries+ foreach ($feeds as $feed) {+ $this->view->conf->remove_query_by_get('f_' . $feed->id());+ }+ $this->view->conf->save();++ Minz_Request::good(_t('category_emptied'), $url_redirect);+ } else {+ Minz_Request::bad(_t('error_occured'), $url_redirect);}}diff --git a/app/Controllers/feedController.php b/app/Controllers/feedController.phpindex c7cc25fbb..7ef427ac2 100755--- a/app/Controllers/feedController.php+++ b/app/Controllers/feedController.php@@ -376,62 +376,36 @@ class FreshRSS_feed_Controller extends Minz_ActionController {}}- public function deleteAction () {- if (Minz_Request::isPost ()) {- $type = Minz_Request::param ('type', 'feed');- $id = Minz_Request::param ('id');-+ public function deleteAction() {+ if (Minz_Request::isPost()) {+ $id = Minz_Request::param('id');$feedDAO = FreshRSS_Factory::createFeedDao();- if ($type == 'category') {- // List feeds to remove then related user queries.- $feeds = $feedDAO->listByCategory($id);-- if ($feedDAO->deleteFeedByCategory ($id)) {- // Remove related queries- foreach ($feeds as $feed) {- $this->view->conf->remove_query_by_get('f_' . $feed->id());- }- $this->view->conf->save();- $notif = array (- 'type' => 'good',- 'content' => Minz_Translate::t ('category_emptied')- );- //TODO: Delete old favicons- } else {- $notif = array (- 'type' => 'bad',- 'content' => Minz_Translate::t ('error_occured')- );- }- } else {- if ($feedDAO->deleteFeed ($id)) {- // Remove related queries- $this->view->conf->remove_query_by_get('f_' . $id);- $this->view->conf->save();+ if ($feedDAO->deleteFeed($id)) {+ // TODO: Delete old favicon- $notif = array (- 'type' => 'good',- 'content' => Minz_Translate::t ('feed_deleted')- );- //TODO: Delete old favicon- } else {- $notif = array (- 'type' => 'bad',- 'content' => Minz_Translate::t ('error_occured')- );- }+ // Remove related queries+ $this->view->conf->remove_query_by_get('f_' . $id);+ $this->view->conf->save();++ $notif = array(+ 'type' => 'good',+ 'content' => _t('feed_deleted')+ );+ } else {+ $notif = array(+ 'type' => 'bad',+ 'content' => _t('error_occured')+ );}- Minz_Session::_param ('notification', $notif);+ Minz_Session::_param('notification', $notif);$redirect_url = Minz_Request::param('r', false, true);if ($redirect_url) {Minz_Request::forward($redirect_url);- } elseif ($type == 'category') {- Minz_Request::forward(array ('c' => 'configure', 'a' => 'categorize'), true);} else {- Minz_Request::forward(array ('c' => 'configure', 'a' => 'feed'), true);+ Minz_Request::forward(array('c' => 'configure', 'a' => 'feed'), true);}}}diff --git a/app/views/configure/categorize.phtml b/app/views/configure/categorize.phtmlindex e7435e1c7..2d9dd65ca 100644--- a/app/views/configure/categorize.phtml+++ b/app/views/configure/categorize.phtml@@ -1,7 +1,6 @@<?php $this->partial('aside_feed'); ?><div>- <form id="configure-categorize" method="post" style="display: none;"></form><div class="box"><div class="box-title"><label for="new-category"><?php echo _t('add_category'); ?></label></div>@@ -14,6 +13,8 @@</div></div>+ <form id="controller-category" method="post" style="display: none;"></form>+<?phpforeach ($this->categories as $cat) {$feeds = $cat->feeds();@@ -32,8 +33,9 @@<button class="as-link confirm"data-str-confirm="<?php echo _t('confirm_action_feed_cat'); ?>"type="submit"- form="configure-categorize"- formaction="<?php echo _url('feed', 'delete', 'id', $cat->id(), 'type', 'category'); ?>"><?php echo _t('ask_empty'); ?></button>+ form="controller-category"+ formaction="<?php echo _url('category', 'empty', 'id', $cat->id()); ?>">+ <?php echo _t('ask_empty'); ?></button></li><li class="item"><a href=""><?php echo _t('delete'); ?></a></li></ul>