From dc714d3949373b79344438335cfc0edde77de036 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Tue, 30 Sep 2014 17:11:31 +0200 Subject: Cat updating system works Add a submit button Each box contains a specific form See https://github.com/marienfressinaud/FreshRSS/issues/646 --- app/Controllers/categoryController.php | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'app/Controllers/categoryController.php') diff --git a/app/Controllers/categoryController.php b/app/Controllers/categoryController.php index be8524749..65fe631cc 100644 --- a/app/Controllers/categoryController.php +++ b/app/Controllers/categoryController.php @@ -62,6 +62,45 @@ class FreshRSS_category_Controller extends Minz_ActionController { Minz_Request::forward($url_redirect, true); } + /** + * This action updates the given category. + * + * Request parameters are: + * - id + * - name + */ + public function updateAction() { + $catDAO = new FreshRSS_CategoryDAO(); + $url_redirect = array('c' => 'configure', 'a' => 'categorize'); + + if (Minz_Request::isPost()) { + invalidateHttpCache(); + + $id = Minz_Request::param('id'); + $name = Minz_Request::param('name', ''); + if (strlen($name) <= 0) { + Minz_Request::bad(_t('category_no_name'), $url_redirect); + } + + if ($catDAO->searchById($id) == null) { + Minz_Request::bad(_t('category_not_exist'), $url_redirect); + } + + $cat = new FreshRSS_Category($name); + $values = array( + 'name' => $cat->name(), + ); + + if ($catDAO->updateCategory($id, $values)) { + Minz_Request::good(_t('category_updated'), $url_redirect); + } else { + Minz_Request::bad(_t('error_occurred'), $url_redirect); + } + } + + Minz_Request::forward($url_redirect, true); + } + /** * This action deletes a category. * Feeds in the given category are moved in the default category. -- cgit v1.2.3