/**
  * returns the current quota allocated for a blog
  *
  * @param blogId
  * @return
  * @static
  */
 function getBlogResourceQuota($blogId)
 {
     $blogs = new Blogs();
     $blogSettings = $blogs->getBlogSettings($blogId);
     $blogQuota = $blogSettings->getValue("resources_quota");
     if ($blogQuota == "") {
         $blogQuota = GalleryResourceQuotas::getGlobalResourceQuota();
     }
     return $blogQuota;
 }
 /**
  * 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;
 }
 function AdminBlogSettingsView($blogInfo)
 {
     $this->AdminTemplatedView($blogInfo, "blogsettings");
     $blogs = new Blogs();
     $blogSettings = $blogs->getBlogSettings($this->_blogInfo->getId());
     $this->setValue("blogAbout", $this->_blogInfo->getAbout());
     $this->setValue("blogName", $this->_blogInfo->getBlog());
     $this->setValue("blogLocale", $blogSettings->getValue("locale"));
     $this->setValue("blogMaxRecentItems", $blogSettings->getValue("recent_posts_max"));
     $this->setValue("blogMaxMainPageItems", $blogSettings->getValue("show_posts_max"));
     $this->setValue("blogTemplate", $blogSettings->getValue("template"));
     $this->setValue("blogTimeOffset", $blogSettings->getValue("time_offset"));
     $this->setValue("blogCategoriesOrder", $blogSettings->getValue("categories_order"));
     $this->setValue("blogLinkCategoriesOrder", $blogSettings->getValue("link_categories_order"));
     $this->setValue("blogShowMoreEnabled", $blogSettings->getValue("show_more_enabled"));
     $this->setValue("blogEnableHtmlarea", $blogSettings->getValue("htmlarea_enabled"));
     $this->setValue("blogCommentsEnabled", $blogSettings->getValue("comments_enabled"));
     $this->setValue("blogShowFuturePosts", $blogSettings->getValue("show_future_posts_in_calendar"));
     $this->setValue("blogEnableAutosaveDrafts", $blogSettings->getValue("new_drafts_autosave_enabled"));
     $this->setValue("blogCommentsOrder", $blogSettings->getValue("comments_order"));
 }
 /**
  * Returns true if the template is a valid blog template set, or false otherwise.
  *
  * @param templateName The name of the template.
  * @param blogId The identifier of the blog we'd like to check
  */
 function isBlogTemplate($templateName, $blogId)
 {
     $blogs = new Blogs();
     $blogSettings = $blogs->getBlogSettings($blogId);
     // get the array with the template names stored in the settings
     $blogTemplates = $blogSettings->getValue("blog_templates");
     if (empty($blogTemplates) || $blogTemplates == false) {
         return false;
     }
     return in_array($templateName, $blogTemplates);
 }
 /**
  * Adds a local template to the given blog.
  *
  * @param templateName Name that the template will use
  * @param blogId the identifier of the blog to which we're going to install
  * the new template.
  * @return True if successful or false otherwise.
  */
 function addLocalTemplate($templateName, $blogId)
 {
     $blogs = new Blogs();
     $blogSettings = $blogs->getBlogSettings($blogId);
     if ($blogSettings == "" || $blogSettings == false) {
         return false;
     }
     // get the array with the templates
     $blogTemplates = $blogSettings->getValue("blog_templates");
     // add a new one unless it's already there
     if ($blogTemplates == "" || $blogTemplates == null) {
         $blogTemplates = array();
     }
     if (in_array($templateName, $blogTemplates)) {
         return true;
     }
     array_push($blogTemplates, $templateName);
     $blogSettings->setValue("blog_templates", $blogTemplates);
     $blogs->updateBlogSettings($blogId, $blogSettings);
     return true;
 }