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;
 }
 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;
 }
 function render()
 {
     $blogSettings = $this->_blogInfo->getSettings();
     $pluginEnabled = $blogSettings->getValue("plugin_contentfilter_enabled");
     $contents = new FilteredContents();
     $filteredContent = $contents->getBlogFilteredContent($this->_contentId, $this->_blogInfo->getId());
     $this->setValue("pluginEnabled", $pluginEnabled);
     $this->setValue("filteredcontent", $filteredContent);
     if (!$pluginEnabled) {
         $locale = $this->_blogInfo->getLocale();
         $text = $locale->tr("error_contentfilter_not_enabled");
         $this->setErrorMessage($text);
     }
     parent::render();
 }
 function render()
 {
     $blogSettings = $this->_blogInfo->getSettings();
     $pluginEnabled = $blogSettings->getValue("plugin_contentfilter_enabled");
     // get the content that has been filtered by this blog
     $filteredContents = new FilteredContents();
     $blogFilteredContents = $filteredContents->getAllFilteredContents();
     $this->setValue("pluginEnabled", $pluginEnabled);
     $this->setValue("filteredcontent", $blogFilteredContents);
     if (!$pluginEnabled) {
         $locale = $this->_blogInfo->getLocale();
         $text = $locale->tr("error_contentfilter_not_enabled");
         $this->setErrorMessage($text);
     }
     parent::render();
 }
 function perform()
 {
     // fetch the data
     $this->_contentId = $this->_request->getValue("contentId");
     // fetch the filtered content that we're going to edit
     $contents = new FilteredContents();
     $filteredContent = $contents->getBlogFilteredContent($this->_contentId, 0);
     if (!$filteredContent) {
         $this->_view = new AdminFilteredContentView($this->_blogInfo);
         $this->_view->setErrorMessage($this->_locale->tr("error_fetching_filtered_content"));
         $this->setCommonData();
         return false;
     }
     $this->_view = new AdminEditFilteredContentView($this->_blogInfo, $this->_contentId);
     $this->setCommonData();
     return true;
 }
 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;
 }
 function filter()
 {
     // get some info
     $blogInfo = $this->_pipelineRequest->getBlogInfo();
     $request = $this->_pipelineRequest->getHttpRequest();
     // check if this section has been enabled or disabled
     $blogSettings = $blogInfo->getSettings();
     $pluginEnabled = $blogSettings->getValue("plugin_contentfilter_enabled");
     if (!$pluginEnabled) {
         // if not, nothing to do here...
         //_debug("ip address filter not enabled! quitting...<br/>");
         return new PipelineResult();
     }
     // we only have to filter the contents if the user is posting a comment
     // so there's no point in doing anything else if that's not the case
     if ($request->getValue("op") != "AddComment") {
         $result = new PipelineResult();
         return $result;
     }
     //
     // get the content that has been globally blocked by the admin(s)
     //
     $filteredContents = new FilteredContents();
     $globalFilteredContents = $filteredContents->getGlobalFilteredContents();
     // text and topic of the comment
     $commentText = $request->getValue("commentText");
     $commentTopic = $request->getValue("commentTopic");
     $userName = $request->getValue("userName");
     $userEmail = $request->getValue("userEmail");
     $userUrl = $request->getValue("userUrl");
     foreach ($globalFilteredContents as $globalFilteredContent) {
         //_debug("regexp = ".$globalFilteredContent->getRegExp()."<br/>");
         if (preg_match($globalFilteredContent->getRegExp(), $commentText)) {
             // if there is a match, we can quit and reject this request
             $result = new PipelineResult(false, CONTENT_FILTER_MATCH_FOUND, $globalFilteredContent->getReason());
             return $result;
         }
         if (preg_match($globalFilteredContent->getRegExp(), $commentTopic)) {
             // if there is a match, we can quit and reject this request
             $result = new PipelineResult(false, CONTENT_FILTER_MATCH_FOUND, $globalFilteredContent->getReason());
             return $result;
         }
         if (preg_match($globalFilteredContent->getRegExp(), $userName)) {
             // if there is a match, we can quit and reject this request
             $result = new PipelineResult(false, CONTENT_FILTER_MATCH_FOUND, $globalFilteredContent->getReason());
             return $result;
         }
         if (preg_match($globalFilteredContent->getRegExp(), $userEmail)) {
             // if there is a match, we can quit and reject this request
             $result = new PipelineResult(false, CONTENT_FILTER_MATCH_FOUND, $globalFilteredContent->getReason());
             return $result;
         }
         if (preg_match($globalFilteredContent->getRegExp(), $userUrl)) {
             // if there is a match, we can quit and reject this request
             $result = new PipelineResult(false, CONTENT_FILTER_MATCH_FOUND, $globalFilteredContent->getReason());
             return $result;
         }
     }
     //
     // get the list of filtered content for this blog
     //
     $blogFilteredContents = $filteredContents->getBlogFilteredContents($blogInfo->getId());
     foreach ($blogFilteredContents as $blogFilteredContent) {
         //_debug("regexp = ".$blogFilteredContent->getRegExp()."<br/>");
         if (preg_match($blogFilteredContent->getRegExp(), $commentText)) {
             // if there is a match, we can quit and reject this request
             $result = new PipelineResult(false, CONTENT_FILTER_MATCH_FOUND, $blogFilteredContent->getReason());
             return $result;
         }
         if (preg_match($blogFilteredContent->getRegExp(), $commentTopic)) {
             // if there is a match, we can quit and reject this request
             $result = new PipelineResult(false, CONTENT_FILTER_MATCH_FOUND, $blogFilteredContent->getReason());
             return $result;
         }
         if (preg_match($blogFilteredContent->getRegExp(), $userName)) {
             // if there is a match, we can quit and reject this request
             $result = new PipelineResult(false, CONTENT_FILTER_MATCH_FOUND, $blogFilteredContent->getReason());
             return $result;
         }
         if (preg_match($blogFilteredContent->getRegExp(), $userEmail)) {
             // if there is a match, we can quit and reject this request
             $result = new PipelineResult(false, CONTENT_FILTER_MATCH_FOUND, $blogFilteredContent->getReason());
             return $result;
         }
         if (preg_match($blogFilteredContent->getRegExp(), $userUrl)) {
             // if there is a match, we can quit and reject this request
             $result = new PipelineResult(false, CONTENT_FILTER_MATCH_FOUND, $blogFilteredContent->getReason());
             return $result;
         }
     }
     // if everything went fine, we can say so by returning
     // a positive PipelineResult object
     $result = new PipelineResult(true);
     return $result;
 }