[pLog-svn] r7191 - in plugins/branches/lifetype-1.2/contact: . class/action templates
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Wed May 30 20:52:14 EDT 2012
Author: jondaley
Date: 2012-05-30 20:52:13 -0400 (Wed, 30 May 2012)
New Revision: 7191
Modified:
plugins/branches/lifetype-1.2/contact/class/action/contactpluginsendaction.class.php
plugins/branches/lifetype-1.2/contact/plugincontact.class.php
plugins/branches/lifetype-1.2/contact/templates/form.template
Log:
Since we use the normal security pipeline, we have to check the hidden input setting to avoid blocking comments as spam incorrectly
Modified: plugins/branches/lifetype-1.2/contact/class/action/contactpluginsendaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/contact/class/action/contactpluginsendaction.class.php 2012-05-11 16:27:48 UTC (rev 7190)
+++ plugins/branches/lifetype-1.2/contact/class/action/contactpluginsendaction.class.php 2012-05-31 00:52:13 UTC (rev 7191)
@@ -17,8 +17,7 @@
$this->BlogAction($actionInfo, $request);
$this->registerFieldValidator("userName", new StringValidator());
- $this->registerFieldValidator("userEmail", new EmailValidator());
- $this->registerFieldValidator("commentTopic", new StringValidator());
+ $this->registerFieldValidator("commentTopic", new StringValidator(), true);
$this->registerFieldValidator("commentText", new StringValidator( true ));
$f = new AllowedHtmlFilter();
@@ -35,8 +34,18 @@
if(!parent::validate())
return false;
+ // Check for valid email address, and print a nice error message if not correct
+ $val = new EmailValidator();
+ $emailAddress = $this->_request->getValue( 'userEmail' );
+ if( !$val->validate( $emailAddress )){
+ $this->_view = new ErrorView( $this->_blogInfo, $this->_locale->tr("error_incorrect_email_address"));
+ $this->setCommonData();
+ return false;
+ }
+
$blogSettings = $this->_blogInfo->getSettings();
+ /////////// CHECK BANNED KEYWORDS ////////////////
// get words to match
$bannedKeywords = $blogSettings->getValue("plugin_contact_banned_keywords");
// no banned words, exit out
@@ -67,7 +76,7 @@
$text = $this->_request->getValue("commentText");
$subject = $this->_request->getValue("commentTopic");
- if($this->_checkSpam($username, $emailAddress, $text, $subject)){
+ if($this->_checkSpam()){
$this->_view = new ErrorView($this->_blogInfo);
$this->_view->setErrorMessage($this->_locale->tr("plugin_contact_error_spam"));
$this->setCommonData();
@@ -100,12 +109,12 @@
// run the inputs through the bayesian filter to see if it thinks it is spam
// copied from bayesianfilter::getSpamProbability since that function is marked
// as private
- function _checkSpam($userName, $userEmail, $text, $topic){
+ function _checkSpam(){
// make a copy of the request so we can fake the filters into running
// during our action
$request = new Request($this->_request->getAsArray());
$request->setValue("op", "AddComment");
-
+
$pipeline = new Pipeline($request, $this->_blogInfo);
$result = $pipeline->process();
Modified: plugins/branches/lifetype-1.2/contact/plugincontact.class.php
===================================================================
--- plugins/branches/lifetype-1.2/contact/plugincontact.class.php 2012-05-11 16:27:48 UTC (rev 7190)
+++ plugins/branches/lifetype-1.2/contact/plugincontact.class.php 2012-05-31 00:52:13 UTC (rev 7191)
@@ -16,7 +16,7 @@
$this->id = "contact";
$this->desc = "Allows visitors to submit a message to the blog owner (via email). To prevent spam, this plugin uses a keyword blacklist, the built-in bayesian filter, and authimage and hiddeninput if installed and enabled.";
$this->author = "Jon Daley";
- $this->version = "20090501";
+ $this->version = "20120530";
if( $source == "admin" )
$this->initAdmin();
@@ -42,14 +42,18 @@
}
function showForm(){
- $blogSettings = $this->blogInfo->getSettings();
- if(!$blogSettings->getValue("plugin_contact_enabled"))
- return "";
+ if(!$this->blogInfo || !$this->blogSettings || !$this->blogSettings->getValue("plugin_contact_enabled"))
+ return "Contact form is disabled.";
$locale =& $this->blogInfo->getLocale();
lt_include( PLOG_CLASS_PATH."class/view/plugintemplatedview.class.php" );
$view = new PluginTemplatedView($this->blogInfo, "contact", "form");
+
+ // Check to see if hidden input expects the topic field to be empty
+ $noTopic = $this->blogSettings->getValue( "plugin_hiddeninput_enabled" ) &&
+ $this->blogSettings->getValue( "plugin_hiddeninput_notopic" );
+ $view->setValue("showTopic", $noTopic != 1);
$view->render();
}
Modified: plugins/branches/lifetype-1.2/contact/templates/form.template
===================================================================
--- plugins/branches/lifetype-1.2/contact/templates/form.template 2012-05-11 16:27:48 UTC (rev 7190)
+++ plugins/branches/lifetype-1.2/contact/templates/form.template 2012-05-31 00:52:13 UTC (rev 7191)
@@ -5,10 +5,12 @@
<label for="userEmail">{$locale->tr("plugin_contact_email_address")}: </label>
<input type="text" name="userEmail" /><br/>
+
+ {if $showTopic}
+ <label for="commentTopic">{$locale->tr("comment_topic")}: </label>
+ <input type="text" name="commentTopic" /><br/>
+ {/if}
- <label for="commentTopic">{$locale->tr("comment_topic")}: </label>
- <input type="text" name="commentTopic" /><br/>
-
<label for="commentText">{$locale->tr("comment_text")}: </label>
<script type="text/javascript">var ed1 = new LifetypeUIEditor("commentText","ed1");</script>
<textarea rows="15" id="commentText" name="commentText" style="width:100%"></textarea><br/>
More information about the pLog-svn
mailing list