[pLog-svn] r6875 - in plugins/branches/lifetype-1.2/contact: . class/action class/view locale templates

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Thu Apr 30 17:16:07 EDT 2009


Author: jondaley
Date: 2009-04-30 17:16:07 -0400 (Thu, 30 Apr 2009)
New Revision: 6875

Modified:
   plugins/branches/lifetype-1.2/contact/class/action/admincontactpluginupdatesettingsaction.class.php
   plugins/branches/lifetype-1.2/contact/class/action/contactpluginsendaction.class.php
   plugins/branches/lifetype-1.2/contact/class/view/admincontactpluginsettingsview.class.php
   plugins/branches/lifetype-1.2/contact/locale/locale_en_UK.php
   plugins/branches/lifetype-1.2/contact/plugincontact.class.php
   plugins/branches/lifetype-1.2/contact/templates/pluginsettings.template
Log:
doesn't quite work yet, but almost does straight keyword blocking

Modified: plugins/branches/lifetype-1.2/contact/class/action/admincontactpluginupdatesettingsaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/contact/class/action/admincontactpluginupdatesettingsaction.class.php	2009-04-28 17:13:14 UTC (rev 6874)
+++ plugins/branches/lifetype-1.2/contact/class/action/admincontactpluginupdatesettingsaction.class.php	2009-04-30 21:16:07 UTC (rev 6875)
@@ -4,6 +4,7 @@
 	lt_include(PLOG_CLASS_PATH."plugins/contact/class/view/admincontactpluginsettingsview.class.php");	
 	lt_include(PLOG_CLASS_PATH."class/dao/blogs.class.php");
 	lt_include(PLOG_CLASS_PATH."class/data/validator/integervalidator.class.php");
+	lt_include(PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php");
 
     class AdminContactPluginUpdateSettingsAction extends AdminAction 
 	{
@@ -13,6 +14,7 @@
         	$this->AdminAction($actionInfo, $request);
 			$this->requirePermission("manage_plugins");
         	$this->registerFieldValidator("pluginEnabled", new IntegerValidator(), true);
+        	$this->registerFieldValidator("bannedKeywords", new StringValidator(), true);
 
 			$view = new AdminContactPluginSettingsView($this->_blogInfo, $this->_userInfo);
         	$view->setErrorMessage($this->_locale->tr("plugin_contact_error_updating_settings"));
@@ -32,6 +34,20 @@
         	// update the plugin configurations to blog setting
 			$blogSettings = $this->_blogInfo->getSettings();
 			$blogSettings->setValue("plugin_contact_enabled", $this->_pluginEnabled);
+
+                // save word list, ignoring commas and leading and trailing spaces
+            $bannedKeywords = explode(",", $this->_request->getValue("bannedKeywords"));
+                // remove spaces
+            $bannedKeywordsArray = array();
+            foreach($bannedKeywords as $key => $word){
+                $word = trim($word);
+                if($word)
+                    $bannedKeywordsArray[] = $word;
+            }
+                // remove duplicates
+            $bannedKeywordsArray = array_unique($bannedKeywordsArray);
+			$blogSettings->setValue("plugin_banned_keywords", $bannedKeywordsArray);
+            
 			$this->_blogInfo->setSettings($blogSettings);
 			
 			// update the settings in the db, and make sure that everything went fine

Modified: plugins/branches/lifetype-1.2/contact/class/action/contactpluginsendaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/contact/class/action/contactpluginsendaction.class.php	2009-04-28 17:13:14 UTC (rev 6874)
+++ plugins/branches/lifetype-1.2/contact/class/action/contactpluginsendaction.class.php	2009-04-30 21:16:07 UTC (rev 6875)
@@ -23,8 +23,28 @@
         	$view->setErrorMessage($this->_locale->tr("plugin_contact_error_data"));
         	$this->setValidationErrorView($view);
         }
+
+
+        function validate(){
+            if(!parent::validate())
+                return false;
+
+            lt_include( PLOG_CLASS_PATH."class/data/validator/rules/filteredwordsrule.class.php" );
+			$config =& Config::getConfig();
+			$bannedKeywords = $config->getValue("plugin_contact_banned_keywords", array());
+			$rule = new FilteredWordsRule($bannedKeywords);
+
+            $text = $this->_request->getValue("contactText");
+            if(!$rule->validate($text))
+                return false;
+
+            $subject = $this->_request->getValue("contactTopic");
+            if(!$rule->validate($subject))
+                return false;
+
+            return true;
+        }
         
-        
         function perform(){
             $username = $this->_request->getValue("userName");
             $emailAddress = $this->_request->getValue("userEmailAddress");

Modified: plugins/branches/lifetype-1.2/contact/class/view/admincontactpluginsettingsview.class.php
===================================================================
--- plugins/branches/lifetype-1.2/contact/class/view/admincontactpluginsettingsview.class.php	2009-04-28 17:13:14 UTC (rev 6874)
+++ plugins/branches/lifetype-1.2/contact/class/view/admincontactpluginsettingsview.class.php	2009-04-30 21:16:07 UTC (rev 6875)
@@ -14,6 +14,16 @@
 			// load some configuration settings
 			$blogSettings = $this->_blogInfo->getSettings();
 			$this->setValue( "pluginEnabled", $blogSettings->getValue("plugin_contact_enabled"));
+            $wordsArray = $blogSettings->getValue("plugin_banned_keywords");
+            $words = "";
+            if(count($wordsArray)){
+                foreach($wordsArray as $word){
+                    if($words)
+                        $words .= ",";
+                    $words .= $word;
+                }
+            }
+			$this->setValue( "bannedKeywords", $words);
 			parent::render();
 		}
 	}

Modified: plugins/branches/lifetype-1.2/contact/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.2/contact/locale/locale_en_UK.php	2009-04-28 17:13:14 UTC (rev 6874)
+++ plugins/branches/lifetype-1.2/contact/locale/locale_en_UK.php	2009-04-30 21:16:07 UTC (rev 6875)
@@ -2,6 +2,9 @@
 $messages["plugin_contact"] = "Contact";
 $messages["plugin_contact_enabled"] = "Enable this plugin";
 
+$messages["plugin_contact_banned_keywords"] = "Banned Words";
+$messages["plugin_contact_help_banned_keywords"] = "Enter a comma delimited list of words that will cause the message to be rejected if the word is contained within the visitor's message.";
+
 $messages["plugin_contact_name"] = "Your Name";
 $messages["plugin_contact_email_address"] = "Your Email Address";
 $messages["plugin_contact_contact_from"] = "Blog contact from: %s\n\n";

Modified: plugins/branches/lifetype-1.2/contact/plugincontact.class.php
===================================================================
--- plugins/branches/lifetype-1.2/contact/plugincontact.class.php	2009-04-28 17:13:14 UTC (rev 6874)
+++ plugins/branches/lifetype-1.2/contact/plugincontact.class.php	2009-04-30 21:16:07 UTC (rev 6875)
@@ -74,7 +74,11 @@
 
             return (Array(
                         Array("name" => "plugin_contact_enabled",
-                              "type" => "boolean")
+                              "type" => "boolean"),
+                        Array("name" => "plugin_contact_banned_keywords",
+                              "validator" => new StringValidator(),
+                              "type" => "string",
+                              "allowEmpty" => true)
                         ));
         }	
 	}  

Modified: plugins/branches/lifetype-1.2/contact/templates/pluginsettings.template
===================================================================
--- plugins/branches/lifetype-1.2/contact/templates/pluginsettings.template	2009-04-28 17:13:14 UTC (rev 6874)
+++ plugins/branches/lifetype-1.2/contact/templates/pluginsettings.template	2009-04-30 21:16:07 UTC (rev 6875)
@@ -14,8 +14,16 @@
      value="1" />{$locale->tr("plugin_contact_enabled")}
    </div>
   </div>
+
+  <div class="field">
+   <label for="bannedKeywords">{$locale->tr("plugin_contact_banned_keywords")}</label>
+   <div class="formHelp">{$locale->tr("plugin_contact_help_banned_keywords")}
+    <input type="text" name="bannedKeywords" id="bannedKeywords" value="{$bannedKeywords}"
+     {user_cannot_override key=plugin_contact_banned_keywords}readonly{/user_cannot_override} />
+   </div>
+  </div>
  </fieldset>
- 
+
  <div class="buttons">  
   <input type="hidden" name="op" value="pluginContactUpdateSettings" />
   <input type="submit" name="{$locale->tr("update_settings")}" value="{$locale->tr("update")}" />



More information about the pLog-svn mailing list