/** * Carries out the specified action */ function perform() { // get the data from the form $this->_categoryName = Textfilter::filterAllHTML($this->_request->getValue("categoryName")); $this->_categoryId = $this->_request->getValue("categoryId"); $this->_categoryDescription = Textfilter::filterAllHTML($this->_request->getValue("categoryDescription")); $this->_categoryInMainPage = $this->_request->getValue("categoryInMainPage"); $this->_properties = array(); // fetch the category we're trying to update $categories = new ArticleCategories(); $category = $categories->getCategory($this->_categoryId, $this->_blogInfo->getId()); if (!$category) { $this->_view = new AdminArticleCategoriesListView($this->_blogInfo); $this->_view->setErrorMessage($this->_locale->tr("error_fetching_category")); $this->setCommonData(); return false; } // fire the pre-event $this->notifyEvent(EVENT_PRE_CATEGORY_UPDATE, array("category" => &$category)); // update the fields $category->setName($this->_categoryName); $category->setUrl(""); $category->setInMainPage($this->_categoryInMainPage); $category->setProperties($this->_properties); $category->setDescription($this->_categoryDescription); // this is view we're going to use to show our messages $this->_view = new AdminArticleCategoriesListView($this->_blogInfo); if (!$categories->updateCategory($category)) { $this->_view->setErrorMessage($this->_locale->tr("error_updating_article_category")); } else { // if everything fine, load the list of categories $this->_view->setSuccessMessage($this->_locale->pr("article_category_updated_ok", $category->getName())); // fire the post-event $this->notifyEvent(EVENT_POST_CATEGORY_UPDATE, array("category" => &$category)); // clear the cache CacheControl::resetBlogCache($this->_blogInfo->getId()); } $this->setCommonData(); // better to return true if everything fine return true; }