[pLog-svn] r1015 - in plugins/trunk/contentfilter: . class/action class/security class/view templates

mark at devel.plogworld.net mark at devel.plogworld.net
Wed Feb 9 04:13:10 GMT 2005


Author: mark
Date: 2005-02-09 04:13:09 +0000 (Wed, 09 Feb 2005)
New Revision: 1015

Added:
   plugins/trunk/contentfilter/class/action/adminupdateblogcontentfilterconfigaction.class.php
   plugins/trunk/contentfilter/class/action/adminupdatecontentfilterconfigaction.class.php
Modified:
   plugins/trunk/contentfilter/class/security/contentfilter.class.php
   plugins/trunk/contentfilter/class/view/adminblogfilteredcontentview.class.php
   plugins/trunk/contentfilter/class/view/adminfilteredcontentview.class.php
   plugins/trunk/contentfilter/plugincontentfilter.class.php
   plugins/trunk/contentfilter/templates/blogfilteredcontent.template
   plugins/trunk/contentfilter/templates/filteredcontent.template
Log:
1. add pluginEnabled to contentfilter plugin
2. add commentTopic, userName, userMail, userWeb to contentfilter filter.

Added: plugins/trunk/contentfilter/class/action/adminupdateblogcontentfilterconfigaction.class.php
===================================================================
--- plugins/trunk/contentfilter/class/action/adminupdateblogcontentfilterconfigaction.class.php	2005-02-08 23:19:19 UTC (rev 1014)
+++ plugins/trunk/contentfilter/class/action/adminupdateblogcontentfilterconfigaction.class.php	2005-02-09 04:13:09 UTC (rev 1015)
@@ -0,0 +1,56 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
+	include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+	include_once( PLOG_CLASS_PATH."plugins/contentfilter/class/view/adminblogfilteredcontentview.class.php" );
+		
+	/**
+	 * updates the plugin configuration
+	 */
+	class AdminUpdateBlogContentFilterConfigAction extends BlogOwnerAdminAction
+	{
+		var $_pluginEnabled;
+		
+		function AdminUpdateBlogContentFilterConfigAction( $actionInfo, $request )
+		{
+			$this->AdminAction( $actionInfo, $request );
+		}
+		
+		function validate()
+		{
+            $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+            $this->_pluginEnabled = ($this->_pluginEnabled != "" );			
+			
+			return true;
+		}
+		        
+		function perform()
+		{
+            // update the plugin configurations to blog setting
+			$blogSettings = $this->_blogInfo->getSettings();
+            $blogSettings->setValue( "plugin_contentfilter_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 AdminBlogFilteredContentView( $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 AdminBlogFilteredContentView( $this->_blogInfo );
+			$this->_view->setSuccessMessage( $this->_locale->tr("contentfilter_settings_saved_ok"));			
+			$this->setCommonData();
+            
+            return true;		
+		}
+	}
+?>
\ No newline at end of file

Added: plugins/trunk/contentfilter/class/action/adminupdatecontentfilterconfigaction.class.php
===================================================================
--- plugins/trunk/contentfilter/class/action/adminupdatecontentfilterconfigaction.class.php	2005-02-08 23:19:19 UTC (rev 1014)
+++ plugins/trunk/contentfilter/class/action/adminupdatecontentfilterconfigaction.class.php	2005-02-09 04:13:09 UTC (rev 1015)
@@ -0,0 +1,56 @@
+<?php
+
+	include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+	include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
+	include_once( PLOG_CLASS_PATH."plugins/contentfilter/class/view/adminfilteredcontentview.class.php" );
+		
+	/**
+	 * updates the plugin configuration
+	 */
+	class AdminUpdateContentFilterConfigAction extends AdminAction
+	{
+		var $_pluginEnabled;
+		
+		function AdminUpdateContentFilterConfigAction( $actionInfo, $request )
+		{
+			$this->AdminAction( $actionInfo, $request );
+		}
+		
+		function validate()
+		{
+            $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+            $this->_pluginEnabled = ($this->_pluginEnabled != "" );			
+			
+			return true;
+		}
+		        
+		function perform()
+		{
+            // update the plugin configurations to blog setting
+			$blogSettings = $this->_blogInfo->getSettings();
+            $blogSettings->setValue( "plugin_contentfilter_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 AdminFilteredContentView( $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 AdminFilteredContentView( $this->_blogInfo );
+			$this->_view->setSuccessMessage( $this->_locale->tr("contentfilter_settings_saved_ok"));			
+			$this->setCommonData();
+            
+            return true;		
+		}
+	}
+?>
\ No newline at end of file

Modified: plugins/trunk/contentfilter/class/security/contentfilter.class.php
===================================================================
--- plugins/trunk/contentfilter/class/security/contentfilter.class.php	2005-02-08 23:19:19 UTC (rev 1014)
+++ plugins/trunk/contentfilter/class/security/contentfilter.class.php	2005-02-09 04:13:09 UTC (rev 1015)
@@ -25,17 +25,19 @@
 
         function filter()
         {
+        	// get some info
+            $blogInfo = $this->_pipelineRequest->getBlogInfo();
+            $request  = $this->_pipelineRequest->getHttpRequest();
+
         	// check if this section has been enabled or disabled
-            $config =& Config::getConfig();
-            if( !$config->getValue( "content_filter_enabled" )) {
+            $blogSettings = $blogInfo->getSettings();
+		    $pluginEnabled = $blogSettings->getValue( "plugin_dropcase_enabled" );
+            if( !$pluginEnabled) {
             	// if not, nothing to do here...
                 //_debug("ip address filter not enabled! quitting...<br/>");
             	return new PipelineResult();
             }
 
-        	// get some info
-            $blogInfo = $this->_pipelineRequest->getBlogInfo();
-            $request  = $this->_pipelineRequest->getHttpRequest();
 
             // 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
@@ -52,6 +54,9 @@
             // 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 )) {
@@ -59,6 +64,30 @@
                     $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;
+                }                                                                
             }
 
             //
@@ -72,6 +101,30 @@
                     $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

Modified: plugins/trunk/contentfilter/class/view/adminblogfilteredcontentview.class.php
===================================================================
--- plugins/trunk/contentfilter/class/view/adminblogfilteredcontentview.class.php	2005-02-08 23:19:19 UTC (rev 1014)
+++ plugins/trunk/contentfilter/class/view/adminblogfilteredcontentview.class.php	2005-02-09 04:13:09 UTC (rev 1015)
@@ -16,11 +16,15 @@
 		
 		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->getBlogFilteredContents( $this->_blogInfo->getId());
 
-            $this->setValue( "filteredcontent", $blogFilteredContents );	
+            $this->setValue( "pluginEnabled", $pluginEnabled );
+            $this->setValue( "filteredcontent", $blogFilteredContents );
 			
 			parent::render();
 		}

Modified: plugins/trunk/contentfilter/class/view/adminfilteredcontentview.class.php
===================================================================
--- plugins/trunk/contentfilter/class/view/adminfilteredcontentview.class.php	2005-02-08 23:19:19 UTC (rev 1014)
+++ plugins/trunk/contentfilter/class/view/adminfilteredcontentview.class.php	2005-02-09 04:13:09 UTC (rev 1015)
@@ -16,10 +16,14 @@
 		
 		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 );	
 			
 			parent::render();

Modified: plugins/trunk/contentfilter/plugincontentfilter.class.php
===================================================================
--- plugins/trunk/contentfilter/plugincontentfilter.class.php	2005-02-08 23:19:19 UTC (rev 1014)
+++ plugins/trunk/contentfilter/plugincontentfilter.class.php	2005-02-09 04:13:09 UTC (rev 1015)
@@ -47,6 +47,7 @@
 			$this->registerAdminAction( "updateFilteredContent", "AdminUpdateFilteredContentAction" );
 			$this->registerAdminAction( "deleteFilteredContent", "AdminDeleteFilteredContentAction" );
 			$this->registerAdminAction( "deleteFilteredContents", "AdminDeleteFilteredContentAction" );
+			$this->registerAdminAction( "updateContentFilterConfig", "AdminUpdateContentFilterConfigAction" );
 			
 			// register the blog owner actions
 			$this->registerAdminAction( "blogFilteredContent", "AdminBlogFilteredContentsAction" );
@@ -56,6 +57,7 @@
 			$this->registerAdminAction( "updateBlogFilteredContent", "AdminUpdateBlogFilteredContentAction" );
 			$this->registerAdminAction( "deleteBlogFilteredContent", "AdminDeleteBlogFilteredContentAction" );
 			$this->registerAdminAction( "deleteBlogFilteredContents", "AdminDeleteBlogFilteredContentAction" );
+			$this->registerAdminAction( "updateBlogContentFilterConfig", "AdminUpdateBlogContentFilterConfigAction" );
 			
 			$menu =& Menu::getMenu();
 			if( !$menu->entryExists( "/menu/Manage/blogSecurity" ))

Modified: plugins/trunk/contentfilter/templates/blogfilteredcontent.template
===================================================================
--- plugins/trunk/contentfilter/templates/blogfilteredcontent.template	2005-02-08 23:19:19 UTC (rev 1014)
+++ plugins/trunk/contentfilter/templates/blogfilteredcontent.template	2005-02-09 04:13:09 UTC (rev 1015)
@@ -1,5 +1,28 @@
 {include file="$admintemplatepath/header.template"}
 {include file="$admintemplatepath/navigation.template" showOpt=blogFilteredContent title=$locale->tr("blogFilteredContent")}
+<div id="list_nav_bar">
+ <div id="list_nav_select">
+  <form id="blogContentFilter" action="admin.php" method="post">
+   <fieldset>
+    <legend>{$locale->tr("label_configuration")}</legend>
+    <div class="list_nav_option">
+     <label for="pluginEnabled">{$locale->tr("label_enable")}</label>
+     <span class="required"></span>
+     <div class="formHelp">
+      <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if} value="1" />{$locale->tr("articlereferers_plugin_enabled")}
+     </div>
+    </div>
+    <div class="list_nav_option">
+     <br />
+     <input type="hidden" name="op" value="updateBlogContentFilterConfig">
+     <input type="submit" name="{$locale->tr("update_settings")}" value="{$locale->tr("update")}">
+    </div>
+   </fieldset> 
+  </form> 
+ </div>
+ <br style="clear:both">
+</div>
+
 <form name="blogFilteredContent" action="admin.php" method="post">
  <div id="list">
   {include file="$admintemplatepath/successmessage.template"}

Modified: plugins/trunk/contentfilter/templates/filteredcontent.template
===================================================================
--- plugins/trunk/contentfilter/templates/filteredcontent.template	2005-02-08 23:19:19 UTC (rev 1014)
+++ plugins/trunk/contentfilter/templates/filteredcontent.template	2005-02-09 04:13:09 UTC (rev 1015)
@@ -1,5 +1,28 @@
 {include file="$admintemplatepath/header.template"}
 {include file="$admintemplatepath/navigation.template" showOpt=filteredContent title=$locale->tr("filteredContent")}
+<div id="list_nav_bar">
+ <div id="list_nav_select">
+  <form id="contentFilter" action="admin.php" method="post">
+   <fieldset>
+    <legend>{$locale->tr("label_configuration")}</legend>
+    <div class="list_nav_option">
+     <label for="pluginEnabled">{$locale->tr("label_enable")}</label>
+     <span class="required"></span>
+     <div class="formHelp">
+      <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if} value="1" />{$locale->tr("contentfilter_plugin_enabled")}
+     </div>
+    </div>
+    <div class="list_nav_option">
+     <br />
+     <input type="hidden" name="op" value="updateContentFilterConfig">
+     <input type="submit" name="{$locale->tr("update_settings")}" value="{$locale->tr("update")}">
+    </div>
+   </fieldset> 
+  </form> 
+ </div>
+ <br style="clear:both">
+</div>
+  
 <form name="filteredContent" action="admin.php" method="post">
  <div id="list">
   {include file="$admintemplatepath/successmessage.template"}




More information about the pLog-svn mailing list