diff options
| author | 2014-09-30 15:44:45 +0200 | |
|---|---|---|
| committer | 2014-09-30 15:44:45 +0200 | |
| commit | 9e0a62727f8ff3c6a68b4ef85089633677ff67ef (patch) | |
| tree | 72b2065f0f3e0fb3943ba0e6e98a7aaf673c4aa0 /app/Controllers/categoryController.php | |
| parent | edb02c8fefdb292c96d7b37ad4e2c311e9d43b44 (diff) | |
Move empty cat action in the new Controller
feedController::delete is simpler than before.
Improve coding style
See https://github.com/marienfressinaud/FreshRSS/issues/646
Diffstat (limited to 'app/Controllers/categoryController.php')
| -rw-r--r-- | app/Controllers/categoryController.php | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php index 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); } } |
