/** * Carries out the specified action */ function perform() { // fetch the settings from the db and update them accordingly $blogs = new Blogs(); $blogSettings = $blogs->getBlogSettings($this->_blogInfo->getId()); $blogSettings->setValue("locale", $this->_request->getValue("blogLocale")); $blogSettings->setValue("show_posts_max", $this->_request->getValue("blogMaxMainPageItems")); $blogSettings->setValue("recent_posts_max", $this->_request->getValue("blogMaxRecentItems")); $blogSettings->setValue("template", $this->_request->getValue("blogTemplate")); $blogSettings->setValue("time_offset", $this->_request->getValue("blogTimeOffset")); $blogSettings->setValue("categories_order", $this->_request->getValue("blogCategoriesOrder")); $blogSettings->setValue("link_categories_order", $this->_request->getValue("blogLinkCategoriesOrder")); $blogSettings->setValue("show_more_enabled", Textfilter::checkboxToBoolean($this->_request->getValue("blogShowMoreEnabled"))); $blogSettings->setValue("htmlarea_enabled", Textfilter::checkboxToBoolean($this->_request->getValue("blogEnableHtmlarea"))); $blogSettings->setValue("comments_enabled", Textfilter::checkboxToBoolean($this->_request->getValue("blogCommentsEnabled"))); $blogSettings->setValue("show_future_posts_in_calendar", Textfilter::checkboxToBoolean($this->_request->getValue("blogShowFuturePosts"))); $blogSettings->setValue("new_drafts_autosave_enabled", Textfilter::checkboxToBoolean($this->_request->getValue("blogEnableAutosaveDrafts"))); $blogSettings->setValue("comments_order", $this->_request->getValue("blogCommentsOrder")); $this->_blogInfo->setAbout(Textfilter::filterAllHTML($this->_request->getValue("blogAbout"))); $this->_blogInfo->setBlog(Textfilter::filterAllHTML($this->_request->getValue("blogName"))); $this->_blogInfo->setSettings($blogSettings); $this->_blogInfo->setProperties($this->_request->getValue("properties")); $this->_blogInfo->setMangledBlog(Textfilter::urlize($this->_blogInfo->getBlog())); // and now update the settings in the database $blogs = new Blogs(); // and now we can proceed... $this->notifyEvent(EVENT_PRE_BLOG_UPDATE, array("blog" => &$this->_blogInfo)); if (!$blogs->updateBlog($this->_blogInfo->getId(), $this->_blogInfo)) { $this->_view = new AdminBlogSettingsView($this->_blogInfo); $this->_view->setErrorMessage($this->_locale->tr("error_updating_settings")); $this->setCommonData(); return false; } // do it again, baby :))) $this->_blogInfo->setAbout(Textfilter::filterAllHTML(stripslashes($this->_request->getValue("blogAbout")))); $this->_blogInfo->setBlog(Textfilter::filterAllHTML(stripslashes($this->_request->getValue("blogName")))); $this->_blogInfo->setSettings($blogSettings); $this->_blogInfo->setProperties($this->_blogProperties); $this->_session->setValue("blogInfo", $this->_blogInfo); $this->saveSession(); $this->notifyEvent(EVENT_POST_BLOG_UPDATE, array("blog" => &$this->_blogInfo)); $this->_view = new AdminBlogSettingsView($this->_blogInfo); $this->_locale =& Locales::getLocale($blogSettings->getValue("locale")); $this->_view->setSuccessMessage($this->_locale->pr("blog_settings_updated_ok", $this->_blogInfo->getBlog())); $this->setCommonData(); // clear the cache CacheControl::resetBlogCache($this->_blogInfo->getId()); // better to return true if everything fine return true; }
/** * Carries out the specified action */ function perform() { // fetch the data, we already know it's valid and that we can trust it! $this->_categoryName = Textfilter::filterAllHTML($this->_request->getValue("categoryName")); $this->_categoryUrl = $this->_request->getValue("categoryUrl"); $this->_categoryInMainPage = Textfilter::checkboxToBoolean($this->_request->getValue("categoryInMainPage")); $this->_categoryDescription = Textfilter::filterAllHTML($this->_request->getValue("categoryDescription")); $this->_properties = $this->_request->getValue("properties"); // create the object... $categories = new ArticleCategories(); $category = new ArticleCategory($this->_categoryName, $this->_categoryUrl, $this->_blogInfo->getId(), $this->_categoryInMainPage, $this->_categoryDescription, 0, $this->_properties); // fire the pre event... $this->notifyEvent(EVENT_PRE_CATEGORY_ADD, array("category" => &$category)); // once we have built the object, we can add it to the database! if ($categories->addArticleCategory($category)) { // if everything went fine, transfer the execution flow to the action that // lists all the article categories... without forgetting that we should let the // next class know that we actually added a category alongside a message // and the category that we just added! $this->_view = new AdminArticleCategoriesListView($this->_blogInfo); $this->_view->setSuccess(true); $this->_view->setSuccessMessage($this->_locale->pr("category_added_ok", $category->getName())); // fire the post event $this->notifyEvent(EVENT_POST_CATEGORY_ADD, array("category" => &$category)); // clear the cache if everything went fine CacheControl::resetBlogCache($this->_blogInfo->getId(), false); $this->setCommonData(); } else { // if there was an error, we should say so... as well as not changing the view since // we're going back to the original view where we can add the category $this->_view->setError(true); $this->_view->setErrorMessage($this->_locale->tr("error_adding_article_category")); $this->setCommonData(true); } // better to return true if everything fine return true; }