/**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch the category we're trying to update
     $this->_categoryId = $this->_request->getValue("linkCategoryId");
     $this->_categoryName = Textfilter::filterAllHTML($this->_request->getValue("linkCategoryName"));
     $categories = new MyLinksCategories();
     $category = $categories->getMyLinksCategory($this->_categoryId, $this->_blogInfo->getId());
     if (!$category) {
         $this->_view = new AdminLinkCategoriesListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_link_category"));
         $this->setCommonData();
         return false;
     }
     // update the fields
     $category->setName($this->_categoryName);
     $this->notifyEvent(EVENT_PRE_LINK_CATEGORY_UPDATE, array("linkcategory" => &$category));
     if (!$categories->updateMyLinksCategory($category)) {
         $this->_view = new AdminLinkCategoriesListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_link_category"));
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_POST_LINK_CATEGORY_UPDATE, array("linkcategory" => &$category));
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     $this->_view = new AdminLinkCategoriesListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->pr("link_category_updated_ok", $category->getName()));
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 function perform()
 {
     // fetch the data
     $this->_newFilteredContent = $this->_request->getValue("filteredContent");
     $this->_reason = $this->_request->getValue("reason");
     // create the dao object and add the info to the db
     $filteredContents = new FilteredContents();
     $filteredContent = new FilteredContent($this->_newFilteredContent, $this->_blogInfo->getId(), $this->_reason);
     // throw the pre-event
     $this->notifyEvent(EVENT_PRE_FILTERED_CONTENT_ADD, array("content" => &$filteredContent));
     // and add the filtered content to the database
     $result = $filteredContents->addBlogFilteredContent($filteredContent);
     // and give some feedback to the user
     if (!$result) {
         $this->_view = new AdminNewBlogFilteredContentView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_adding_blocked_content"));
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_POST_FILTERED_CONTENT_ADD, array("content" => &$filteredContent));
     $this->_view = new AdminBlogFilteredContentView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->tr("blocked_content_added_ok"));
     $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()
 {
     // load the resource
     $resourceId = $this->_request->getValue("resourceId");
     $resources = new GalleryResources();
     // initialize the view we're going to use
     $this->_view = new AdminResourcesListView($this->_blogInfo);
     // fetch the resource first, to get some info about it
     $resource = $resources->getResource($resourceId, $this->_blogInfo->getId());
     if (!$resource) {
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_resource"));
         $this->setCommonData();
         return false;
     }
     // if the resource was loaded ok...
     $this->notifyEvent(EVENT_PRE_RESOURCE_DELETE, array("resource" => &$resource));
     // remove it
     $res = $resources->deleteResource($resourceId, $this->_blogInfo->getId());
     if ($res) {
         $this->_view->setSuccessMessage($this->_locale->pr("resource_deleted_ok", $resource->getFileName()));
         $this->notifyEvent(EVENT_PRE_RESOURCE_DELETE, array("resource" => &$resource));
         // clear the cache if everything went fine
         CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     } else {
         $this->_view->setErrorMessage($this->_locale->pr("error_deleting_resource", $resource->getFileName()));
     }
     // return the view
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch our data
     $this->_albumName = Textfilter::filterAllHTML($this->_request->getValue("albumName"));
     $this->_albumDescription = Textfilter::filterAllHTML($this->_request->getValue("albumDescription"));
     $this->_parentId = $this->_request->getValue("parentId");
     $showAlbum = $this->_request->getValue("showAlbum") ? 1 : 0;
     // create the album
     $albums = new GalleryAlbums();
     $t = new Timestamp();
     $album = new GalleryAlbum($this->_blogInfo->getId(), $this->_albumName, $this->_albumDescription, GALLERY_RESOURCE_PREVIEW_AVAILABLE, $this->_parentId, $t->getTimestamp(), array(), $showAlbum);
     $this->notifyEvent(EVENT_PRE_ALBUM_ADD, array("album" => &$album));
     // and add it to the database
     $result = $albums->addAlbum($album);
     $this->_view = new AdminResourcesListView($this->_blogInfo, array("albumId" => $this->_parentId));
     if ($result) {
         $this->_view->setSuccessMessage($this->_locale->pr("album_added_ok", $album->getName()));
         $this->notifyEvent(EVENT_POST_ALBUM_ADD, array("album" => &$album));
         // clear the cache if everything went fine
         CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     } else {
         $this->_view->setErrorMessage($this->_locale->tr("error_adding_album"));
     }
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 function perform()
 {
     // // update the plugin configurations to blog setting
     $blogSettings = $this->_blogInfo->getSettings();
     $blogSettings->setValue("plugin_authimage_enabled", $this->_pluginEnabled);
     $blogSettings->setValue("plugin_authimage_length", $this->_length);
     $blogSettings->setValue("plugin_authimage_key", $this->_key);
     $blogSettings->setValue("plugin_authimage_expiredtime", $this->_expiredTime);
     $blogSettings->setValue("plugin_authimage_default", $this->_default);
     $this->_blogInfo->setSettings($blogSettings);
     // save the blogs settings
     $blogs = new Blogs();
     if (!$blogs->updateBlog($this->_blogInfo->getId(), $this->_blogInfo)) {
         $this->_view = new PluginAuthImageConfigView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_settings"));
         $this->setCommonData();
         return false;
     }
     // if everything went ok...
     $this->_blogInfo->setSettings($blogSettings);
     $this->_session->setValue("blogInfo", $this->_blogInfo);
     $this->saveSession();
     $this->_view = new PluginAuthImageConfigView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->tr("authimage_settings_saved_ok"));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     return true;
 }
 function perform()
 {
     // update the plugin configurations to blog setting
     $config =& Config::getConfig();
     $config->setValue("plugin_moblog_mailserver", $this->_mailServer);
     $config->setValue("plugin_moblog_port", $this->_port);
     $config->setValue("plugin_moblog_username", $this->_userName);
     $config->setValue("plugin_moblog_password", $this->_password);
     $config->setValue("plugin_moblog_pseudobatch", $this->_pseudoBatch);
     if (!$config->save()) {
         $this->_view = new AdminMoblogBatchPluginSettingsView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_settings"));
         $this->setCommonData();
         return false;
     }
     // if everything went ok...
     $this->_session->setValue("blogInfo", $this->_blogInfo);
     $this->saveSession();
     $this->_view = new AdminMoblogBatchPluginSettingsView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->tr("moblog_settings_saved_ok"));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     return true;
 }
 function perform()
 {
     // fetch the data
     $this->_filteredContentRule = $this->_request->getValue("filteredContent");
     $this->_reason = $this->_request->getValue("reason");
     // create the dao object and add the info to the db
     $filteredContents = new FilteredContents();
     $content = $filteredContents->getBlogFilteredContent($this->_contentId, 0);
     // check if we could find the information, or give up otherwise...
     if (!$content) {
         $this->_view = new AdminFilteredContentView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_filtered_content"));
         $this->setCommonData();
         return false;
     }
     $content->setRegExp($this->_filteredContentRule);
     $content->setReason($this->_reason);
     $this->notifyEvent(EVENT_PRE_FILTERED_CONTENT_UPDATE, array("content" => &$content));
     $result = $filteredContents->updateFilteredContent($content);
     // and give some feedback to the user
     if (!$result) {
         $this->_view = new AdminFilteredContentView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_blocked_content"));
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_POST_FILTERED_CONTENT_UPDATE, array("content" => &$content));
     $this->_view = new AdminFilteredContentView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->tr("blocked_content_updated_ok"));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // load the resource
     $this->_resourceDescription = Textfilter::filterAllHTML($this->_request->getValue("resourceDescription"));
     $this->_albumId = $this->_request->getValue("albumId");
     $this->_resourceId = $this->_request->getValue("resourceId");
     $resources = new GalleryResources();
     $resource = $resources->getResource($this->_resourceId, $this->_blogInfo->getId());
     // update the fields we'd like to update
     $resource->setAlbumId($this->_albumId);
     $resource->setDescription($this->_resourceDescription);
     // send the event
     $this->notifyEvent(EVENT_PRE_RESOURCE_UPDATE, array("resource" => &$resource));
     // and update it in the db
     $result = $resources->updateResource($resource);
     if (!$result) {
         $this->_view = new AdminResourcesListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_resource"));
     } else {
         // check which submit button was pressed
         if ($this->_request->getValue("regenerate") != "") {
             return Controller::setForwardAction("regeneratePreview");
         }
         $this->_view = new AdminResourcesListView($this->_blogInfo);
         $this->_view->setSuccessMessage($this->_locale->pr("resource_updated_ok", $resource->getFileName()));
         $this->notifyEvent(EVENT_POST_RESOURCE_UPDATE, array("resource" => &$resource));
         // clear the cache
         CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     }
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // // update the plugin configurations to blog setting
     $blogSettings = $this->_blogInfo->getSettings();
     $blogSettings->setValue("plugin_moderate_enabled", $this->_pluginEnabled);
     $this->_blogInfo->setSettings($blogSettings);
     // save the blogs settings
     $blogs = new Blogs();
     if (!$blogs->updateBlog($this->_blogInfo->getId(), $this->_blogInfo)) {
         $this->_view = new AdminModeratePluginSettingsView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_settings"));
         $this->setCommonData();
         return false;
     }
     // if everything went ok...
     $this->_blogInfo->setSettings($blogSettings);
     $this->_session->setValue("blogInfo", $this->_blogInfo);
     $this->saveSession();
     $this->_view = new AdminModeratePluginSettingsView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->tr("moderate_settings_saved_ok"));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     return true;
 }
 function perform()
 {
     // fetch the data
     $this->_ip1 = $this->_request->getValue("ip1");
     $this->_ip2 = $this->_request->getValue("ip2");
     $this->_ip3 = $this->_request->getValue("ip3");
     $this->_ip4 = $this->_request->getValue("ip4");
     $this->_hostIp = $this->_ip1 . "." . $this->_ip2 . "." . $this->_ip3 . "." . $this->_ip4;
     $this->_mask = $this->_request->getValue("mask");
     $this->_blockType = $this->_request->getValue("blockType");
     $this->_reason = $this->_request->getValue("reason");
     // create the dao object and add the info to the db
     $blockedHosts = new BlockedHosts();
     $t = new Timestamp();
     $blockedHost = new BlockedHost($this->_hostIp, $this->_mask, $this->_reason, $t->getTimestamp(), GLOBALLY_BLOCKED_HOST, $this->_blockType, BLOCK_BLACKLIST);
     $this->notifyEvent(EVENT_PRE_BLOCK_HOST_ADD, array("host" => &$blockedHost));
     $result = $blockedHosts->add($blockedHost);
     // and give some feedback to the user
     if (!$result) {
         $this->_view = new AdminNewBlockedHostView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_adding_blocked_host"));
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_POST_BLOCK_HOST_ADD, array("host" => &$blockedHost));
     $this->_view = new AdminBlockedHostsView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->tr("blocked_host_updated_ok"));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     return true;
 }
 function perform()
 {
     // create the view
     $this->_view = new AdminResourcesListView($this->_blogInfo);
     // fetch the parameters
     $this->_resourceIds = $this->_request->getValue("resourceIds");
     $this->_albumIds = $this->_request->getValue("albumIds");
     // make sure that we're dealing with arrays!
     if (!is_array($this->_resourceIds)) {
         $this->_resourceIds = array();
     }
     if (!is_array($this->_albumIds)) {
         $this->_albumIds = array();
     }
     // remove the items, if any
     $this->_deleteAlbums();
     $this->_deleteResources();
     // put error and success messages (if any) into the view
     if ($this->_successMessage != "") {
         $this->_view->setSuccessMessage($this->_successMessage);
     }
     if ($this->_errorMessage != "") {
         $this->_view->setErrorMessage($this->_errorMessage);
     }
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch the data
     $this->_linkName = Textfilter::filterAllHTML($this->_request->getValue("linkName"));
     $this->_linkUrl = Textfilter::filterAllHTML($this->_request->getValue("linkUrl"));
     $this->_linkCategoryId = $this->_request->getValue("linkCategoryId");
     $this->_linkDescription = Textfilter::filterAllHTML($this->_request->getValue("linkDescription"));
     $this->_linkRss = Textfilter::filterAllHTML($this->_request->getValue("linkRssFeed"));
     $this->_properties = array();
     // adds the new link to the database
     $myLinks = new MyLinks();
     $myLink = new MyLink($this->_linkName, $this->_linkDescription, $this->_linkUrl, $this->_blogInfo->getId(), $this->_linkCategoryId, 0, $this->_linkRss, $this->_properties);
     $this->notifyEvent(EVENT_PRE_LINK_ADD, array("link" => &$link));
     if (!$myLinks->addMyLink($myLink, $this->_blogInfo->getId())) {
         $this->_view = new AdminNewLinkView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_adding_link"));
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_POST_LINK_ADD, array("link" => &$link));
     $this->_view = new AdminLinksListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->pr("link_added_ok", $myLink->getName()));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     // better to return true if everything fine
     return true;
 }
Exemple #13
0
function deleteSidebarModuleOrderData($dataArray, $sidebarNumber, $modulePos)
{
    $gCacheStorage = globalCacheStorage::getInstance();
    if (!isset($dataArray[$sidebarNumber])) {
        $dataArray[$sidebarNumber] = array();
    }
    array_splice($dataArray[$sidebarNumber], $modulePos, 1);
    CacheControl::flushSkin();
    $gCacheStorage->purge();
    return $dataArray;
}
 /**
  * rejects the comments, and removes from the database from the db
  */
 function _rejectComments()
 {
     $comments = new UnmoderatedComments();
     foreach ($this->_updateComments as $commentId) {
         $comments->deleteComment($commentId);
     }
     $this->_view = new AdminUnmoderatedCommentsview($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->tr("moderate_comments_rejected_ok"));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     return true;
 }
 /**
  * Carries out the specified action
  */
 function _deletePosts()
 {
     // delete the post (it is not physically deleted but rather, we set
     // the status field to 'DELETED'
     $articles = new Articles();
     $errorMessage = "";
     $successMessage = "";
     $totalOk = 0;
     foreach ($this->_postIds as $postId) {
         // get the post
         $post = $articles->getBlogArticle($postId, $this->_blogInfo->getId());
         if ($post) {
             // fire the event
             $this->notifyEvent(EVENT_PRE_POST_DELETE, array("article" => &$post));
             //
             // the next if-else branch allows a site administrator or the blog owner to remove
             // anybody's articles. If not, then users can only remove their own articles
             //
             if ($this->_userInfo->isSiteAdmin() || $this->_blogInfo->getOwner() == $this->_userInfo->getId()) {
                 $result = $articles->deleteArticle($postId, $post->getUser(), $this->_blogInfo->getId(), false);
             } else {
                 $result = $articles->deleteArticle($postId, $this->_userInfo->getId(), $this->_blogInfo->getId(), false);
             }
             if (!$result) {
                 $errorMessage .= $this->_locale->pr("error_deleting_article", $post->getTopic()) . "<br/>";
             } else {
                 $totalOk++;
                 if ($totalOk < 2) {
                     $successMessage .= $this->_locale->pr("article_deleted_ok", $post->getTopic()) . "<br/>";
                 } else {
                     $successMessage = $this->_locale->pr("articles_deleted_ok", $totalOk);
                 }
                 // fire the post event
                 $this->notifyEvent(EVENT_POST_POST_DELETE, array("article" => &$post));
             }
         } else {
             $errorMessage .= $this->_locale->pr("error_deleting_article2", $postId) . "<br/>";
         }
     }
     // clean up the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     $this->_view = new AdminPostsListView($this->_blogInfo);
     if ($errorMessage != "") {
         $this->_view->setErrorMessage($errorMessage);
     }
     if ($successMessage != "") {
         $this->_view->setSuccessMessage($successMessage);
     }
     $this->setCommonData();
     return true;
 }
 /**
  * @private
  * removes categories from the database
  */
 function _deleteArticleCategories()
 {
     $categories = new ArticleCategories();
     $errorMessage = "";
     $successMessage = "";
     $totalOk = 0;
     foreach ($this->_categoryIds as $categoryId) {
         // get the category
         $category = $categories->getCategory($categoryId, $this->_blogInfo->getId());
         if ($category) {
             // get how many articles it has
             //$numArticles = $categories->getNumArticlesCategory( $categoryId );
             $numArticles = $category->getNumArticles(POST_STATUS_ALL);
             // fire the pre-event
             $this->notifyEvent(EVENT_PRE_CATEGORY_DELETE, array("category" => &$category));
             // if it has at least one we can't delete it because then it would break the
             // integrity of our data in the database...
             if ($numArticles > 0) {
                 $errorMessage .= $this->_locale->pr("error_category_has_articles", $category->getName()) . "<br/>";
             } else {
                 // if everything correct, we can proceed and delete it
                 if (!$categories->deleteCategory($categoryId, $this->_blogInfo->getId())) {
                     $errorMessage .= $this->_locale->pr("error_deleting_category") . "<br/>";
                 } else {
                     if ($totalOk < 2) {
                         $successMessage .= $this->_locale->pr("category_deleted_ok", $category->getName()) . "<br/>";
                     } else {
                         $successMessage = $this->_locale->pr("categories_deleted_ok", $totalOk);
                     }
                     // fire the pre-event
                     $this->notifyEvent(EVENT_POST_CATEGORY_DELETE, array("category" => &$category));
                 }
             }
         } else {
             $errorMessage .= $this->_locale->pr("error_deleting_category2", $categoryId) . "<br/>";
         }
     }
     // prepare the view and all the information it needs to know
     $this->_view = new AdminArticleCategoriesListView($this->_blogInfo);
     if ($errorMessage != "") {
         $this->_view->setErrorMessage($errorMessage);
     }
     if ($successMessage != "") {
         // and clear the cache to avoid outdated information
         CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
         $this->_view->setSuccessMessage($successMessage);
     }
     $this->setCommonData();
     return true;
 }
 /**
  * perform
  */
 function perform()
 {
     $userId = $this->createUser();
     if (!$userId) {
         return false;
     }
     $blogId = $this->createBlog($userId);
     if (!$blogId) {
         return false;
     }
     // let's assume that everything went fine at this point...
     $this->doneRegister();
     // reset the summary cache, since there's new information to show
     CacheControl::resetSummaryCache();
 }
 /**
  * Carries out the specified action
  */
 function _deleteReferrers()
 {
     $referrers = new Referers();
     $errorMessage = "";
     $successMessage = "";
     $totalOk = 0;
     foreach ($this->_referrerIds as $referrerId) {
         // fetch the referrer
         $referrer = $referrers->getBlogReferer($referrerId, $this->_blogInfo->getId());
         // fire the pre-event
         $this->notifyEvent(EVEN_PRE_REFERRER_DELETE, array("referrer" => &$referrer));
         if (!$referrer) {
             $errorMessage .= $this->_locale->pr("error_deleting_referrer2", $referrerId) . "<br/>";
         } else {
             if (!$referrers->deleteBlogReferer($referrerId, $this->_blogInfo->getId())) {
                 $errorMessage .= $this->_locale->pr("error_deleting_referrer", $referrer->getUrl()) . "<br/>";
             } else {
                 $totalOk++;
                 if ($totalOk < 2) {
                     $successMessage = $this->_locale->pr("referrer_deleted_ok", $referrer->getUrl());
                 } else {
                     $successMessage = $this->_locale->pr("referrers_deleted_ok", $totalOk);
                 }
                 // fire the post-event
                 $this->notifyEvent(EVENT_POST_REFERRER_DELETE, array("referrer" => &$referrer));
                 $clearCache = true;
             }
         }
     }
     if ($clearCache) {
         // clear the cache if needed
         CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     }
     $this->_view = new AdminReferrersView($this->_blogInfo);
     if ($errorMessage != "") {
         $this->_view->setErrorMessage($errorMessage);
     }
     if ($successMessage != "") {
         $this->_view->setSuccessMessage($successMessage);
     }
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // data is fine, we have already validated it
     $this->_linkName = Textfilter::filterAllHTML($this->_request->getValue("linkName"));
     $this->_linkDescription = Textfilter::filterAllHTML($this->_request->getValue("linkDescription"));
     $this->_linkUrl = Textfilter::filterAllHTML($this->_request->getValue("linkUrl"));
     $this->_linkCategoryId = $this->_request->getValue("linkCategoryId");
     $this->_linkId = $this->_request->getValue("linkId");
     $this->_linkFeed = Textfilter::filterAllHTML($this->_request->getValue("linkRssFeed"));
     // fetch the link we're trying to update
     $links = new MyLinks();
     $link = $links->getMyLink($this->_linkId, $this->_blogInfo->getId());
     if (!$link) {
         $this->_view = new AdminLinksListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_link"));
         $this->setCommonData();
         return false;
     }
     // update the fields
     $link->setName($this->_linkName);
     $link->setDescription($this->_linkDescription);
     $link->setCategoryId($this->_linkCategoryId);
     $link->setUrl($this->_linkUrl);
     $link->setProperties($this->_properties);
     $link->setRssFeed($this->_linkFeed);
     $this->notifyEvent(EVENT_PRE_LINK_UPDATE, array("link" => &$link));
     // and now update it in the database
     if (!$links->updateMyLink($link)) {
         $this->_view = new AdminLinksListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_link"));
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_POST_LINK_UPDATE, array("link" => &$link));
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     // and go back to the view with the list of links
     $this->_view = new AdminLinksListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->pr("link_updated_ok", $link->getName()));
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     $this->_albumId = $this->_request->getValue("albumId");
     $this->_parentId = $this->_request->getValue("parentId");
     $this->_albumName = Textfilter::filterAllHTML($this->_request->getValue("albumName"));
     $this->_albumDescription = Textfilter::filterAllHTML($this->_request->getValue("albumDescription"));
     $this->_showAlbum = $this->_request->getValue("showAlbum");
     if ($this->_showAlbum == "") {
         $this->_showAlbum = 0;
     }
     // fetch the albums for this blog
     $albums = new GalleryAlbums();
     $album = $albums->getAlbum($this->_albumId, $this->_blogInfo->getId());
     if (!$album) {
         $this->_view = new AdminResourcesListView($this->_blogInfo);
         $this->_blogInfo;
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_album"));
         $this->setCommonData();
         return false;
     }
     // update the fields in the object
     $album->setName($this->_albumName);
     $album->setDescription($this->_albumDescription);
     $album->setParentId($this->_parentId);
     $album->setShowAlbum($this->_showAlbum);
     $this->notifyEvent(EVENT_PRE_ALBUM_UPDATE, array("album" => &$album));
     // and update the data in the database
     if (!$albums->updateAlbum($album)) {
         $this->_view = new AdminResourcesListView($this->_blogInfo);
         $this->_blogInfo;
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_album"));
         $this->setCommonData();
         return false;
     }
     $this->_view = new AdminResourcesListView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->pr("album_updated_ok", $album->getName()));
     $this->notifyEvent(EVENT_POST_ALBUM_UPDATE, array("album" => &$album));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // add the new link category to the database
     $this->_linkCategoryName = Textfilter::filterAllHTML($this->_request->getValue("linkCategoryName"));
     $mylinksCategories = new MyLinksCategories();
     $mylinksCategory = new MyLinksCategory($this->_linkCategoryName, $this->_blogInfo->getId(), 0, $this->_properties);
     // the view is the same for both conditions
     $this->_view = new AdminLinkCategoriesListView($this->_blogInfo);
     if (!$mylinksCategories->addMyLinksCategory($mylinksCategory, $this->_blogInfo->getId())) {
         // set an error message
         $this->_view->setErrorMessage($this->_locale->tr("error_adding_link_category"));
     } else {
         // clear the cache
         CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
         $this->_view->setSuccessMessage($this->_locale->pr("link_category_added_ok", $mylinksCategory->getName()));
     }
     $this->setCommonData();
     return true;
 }
 /**
  * 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;
 }
 /**
  * carries out the specified album
  */
 function perform()
 {
     // get the album id
     $albumId = $this->_request->getValue("albumId");
     // load the resource
     $albums = new GalleryAlbums();
     // create the view
     $this->_view = new AdminResourcesListView($this->_blogInfo);
     // fetch the resource albumm first, to get some info about it
     $album = $albums->getAlbum($albumId, $this->_blogInfo->getId(), false);
     if (!$album) {
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_album"));
         $this->setCommonData();
         return false;
     }
     // notify of the "pre" delete event
     $this->notifyEvent(EVENT_PRE_ALBUM_DELETE, array("album" => &$album));
     //
     // this album cannot be deleted if either:
     //   1) we have resources under it
     //   2) we have child albums under it
     //
     if ($album->getNumChildren() > 0 || $album->getNumResources() > 0) {
         $this->_view->setErrorMessage($this->_locale->pr("error_album_has_children", $album->getName()));
     } else {
         // otherwise, we can go ahead and remove it
         if ($albums->deleteAlbum($albumId, $this->_blogInfo->getId())) {
             $this->_view->setSuccessMessage($this->_locale->pr("album_deleted_ok", $album->getName()));
             $this->notifyEvent(EVENT_PRE_ALBUM_DELETE, array("album" => &$album));
             // clear the cache
             CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
         } else {
             $this->_view->setErrorMessage($this->_locale->pr("error_deleting_album", $album->getName()));
         }
     }
     // return the view
     $this->setCommonData();
     // better to return true if everything fine
     return true;
 }
 /**
  * Carries out the specified action
  */
 function perform()
 {
     // fetch the data
     $this->_ip1 = $this->_request->getValue("ip1");
     $this->_ip2 = $this->_request->getValue("ip2");
     $this->_ip3 = $this->_request->getValue("ip3");
     $this->_ip4 = $this->_request->getValue("ip4");
     $this->_ip = $this->_ip1 . "." . $this->_ip2 . "." . $this->_ip3 . "." . $this->_ip4;
     $this->_mask = $this->_request->getValue("mask");
     $this->_type = $this->_request->getValue("blockType");
     $this->_reason = $this->_request->getValue("reason");
     $blockedHosts = new BlockedHosts();
     $blockedHost = $blockedHosts->getBlockedHost($this->_hostId, $this->_blogInfo->getId());
     // check if the info about the blocked host is correct
     if (!$blockedHost) {
         $this->_view = new AdminBlogBlockedHostsView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_blocked_host"));
         $this->setCommonData();
         return false;
     }
     // set the new information
     $blockedHost->setHost($this->_ip);
     $blockedHost->setReason($this->_reason);
     $blockedHost->setType($this->_type);
     $blockedHost->setMask($this->_mask);
     $this->notifyEvent(EVENT_PRE_BLOCK_HOST_UPDATE, array("host" => &$blockedHost));
     if (!$blockedHosts->update($blockedHost)) {
         $this->_view = new AdminBlogBlockedHostsView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_blocked_host"));
         $this->setCommonData();
         return false;
     }
     $this->notifyEvent(EVENT_POST_BLOCK_HOST_UPDATE, array("host" => &$blockedHost));
     $this->_view = new AdminBlogBlockedHostsView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->tr("blocked_host_updated_ok"));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     return true;
 }
 function perform()
 {
     // we can proceed to update the config
     foreach ($this->_newConfigOpts as $key => $value) {
         $this->_config->setValue($key, $value);
     }
     // and finally save everything
     $res = $this->_config->save();
     // depending on the result, we shall show one thing or another...
     if ($res) {
         $this->_view = new AdminGlobalSettingsListView($this->_blogInfo);
         $this->_view->setSuccessMessage($this->_locale->tr("site_config_saved_ok"));
         $this->setCommonData();
         // clear the contents of all the caches
         CacheControl::resetAllCaches();
     } else {
         $this->_view = new AdminGlobalSettingsListView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_saving_site_config"));
         $this->setCommonData();
     }
     return $res;
 }
 function _deleteFilteredContents()
 {
     // get the content that has been filtered by this blog
     $filteredContents = new FilteredContents();
     // loop through the array of things to remove
     $errorMessage = "";
     $successMessage = "";
     $numOk = 0;
     foreach ($this->_deleteFilteredContents as $filteredContentId) {
         // fetch the content
         $filteredContent = $filteredContents->getBlogFilteredContent($filteredContentId, 0);
         $this->notifyEvent(EVENT_PRE_FILTERED_CONTENT_DELETE, array("content" => &$filteredContent));
         // first remove it
         if (!$filteredContents->removeBlogFilteredContent($filteredContentId, $filteredContent->getBlogId())) {
             $errorMessage .= $this->_locale->pr("error_deleting_content", $filteredContent->getRegExp(false)) . "<br/>";
         } else {
             $numOk++;
             if ($numOk > 1) {
                 $successMessage = $this->_locale->pr("contents_deleted_ok", $numOk);
             } else {
                 $successMessage = $this->_locale->pr("content_deleted_ok", $filteredContent->getRegExp(false));
             }
             $this->notifyEvent(EVENT_POST_FILTERED_CONTENT_DELETE, array("content" => &$filteredContent));
         }
     }
     $this->_view = new AdminFilteredContentView($this->_blogInfo);
     if ($errorMessage != "") {
         $this->_view->setErrorMessage($errorMessage);
     }
     if ($successMessage != "") {
         $this->_view->setSuccessMessage($successMessage);
     }
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     // better to return true if everything fine
     return true;
 }
Exemple #27
0
function clearCache()
{
    global $database, $changed, $errorlog, $memcache;
    static $isCleared = false;
    if ($isCleared == true) {
        return;
    }
    if (!is_null($blogids = POD::queryColumn("SELECT blogid FROM {$database['prefix']}PageCacheLog"))) {
        $changed = true;
        $errorlog = false;
        echo '<li>', _textf('페이지 캐시를 초기화합니다.'), ': ';
        foreach ($blogids as $ids) {
            if (CacheControl::flushAll($ids) == false) {
                $errorlog = true;
            }
        }
        if ($errorlog == false) {
            echo '<span class="result success">', _text('성공'), '</span></li>';
        } else {
            echo '<span class="result fail">', _text('실패'), '</span></li>';
        }
    }
    if (!is_null($memcache)) {
        echo '<li>', _textf('Memcached 캐시를 초기화합니다.'), ': ';
        if ($memcache->flush()) {
            echo '<span class="result success">', _text('성공'), '</span></li>';
        } else {
            echo '<span class="result fail">', _text('실패'), '</span></li>';
        }
    }
    echo '<li>', _textf('공지사항 캐시를 초기화합니다.'), ': ';
    if (POD::execute("DELETE FROM {$database['prefix']}ServiceSettings WHERE name like 'TextcubeNotice%'")) {
        echo '<span class="result success">', _text('성공'), '</span></li>';
    } else {
        echo '<span class="result fail">', _text('실패'), '</span></li>';
    }
    $isCleared = true;
}
 /**
  * Carries out the specified action
  * @private
  */
 function _deleteLinks()
 {
     // delete the link
     $links = new MyLinks();
     $errorMessage = "";
     $successMessage = "";
     $numOk = 0;
     foreach ($this->_linkIds as $linkId) {
         // load the link
         $link = $links->getMyLink($linkId, $this->_blogInfo->getId());
         if ($link) {
             if (!$links->deleteMyLink($linkId, $this->_blogInfo->getId())) {
                 $errorMessage .= $this->_locale->pr("error_removing_link", $link->getName()) . "<br/>";
             } else {
                 $numOk++;
                 if ($numOk > 1) {
                     $successMessage = $this->_locale->pr("links_deleted_ok", $numOk);
                 } else {
                     $successMessage = $this->_locale->pr("link_deleted_ok", $link->getName());
                 }
             }
         } else {
             $errorMessage .= $this->_locale->pr("error_removing_link2", $linkId) . "<br/>";
         }
     }
     $this->_view = new AdminLinksListView($this->_blogInfo);
     if ($errorMessage != "") {
         $this->_view->setErrorMessage($errorMessage);
     }
     if ($successMessage != "") {
         $this->_view->setSuccessMessage($successMessage);
     }
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId(), false);
     // better to return true if everything fine
     return true;
 }
 function perform()
 {
     // // update the plugin configurations to blog setting
     $config =& Config::getConfig();
     $config->setValue("plugin_templateeditor_enabled", $this->_pluginEnabled);
     $config->setValue("plugin_templateeditor_maxbackupfiles", $this->_maxBackupFiles);
     $config->setValue("plugin_templateeditor_allowedextension", $this->_allowedExtension);
     if (!$config->save()) {
         $this->_view = new PluginTemplateEditorConfigView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_updating_settings"));
         $this->setCommonData();
         return false;
     }
     // if everything went ok...
     $this->_session->setValue("blogInfo", $this->_blogInfo);
     $this->saveSession();
     $this->_view = new PluginTemplateEditorConfigView($this->_blogInfo);
     $this->_view->setSuccessMessage($this->_locale->tr("templateeditor_settings_saved_ok"));
     $this->setCommonData();
     // clear the cache
     CacheControl::resetBlogCache($this->_blogInfo->getId());
     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;
 }