[pLog-svn] r4609 - in plugins/branches/lifetype-1.1: . requireemail requireemail/class requireemail/class/action requireemail/class/security requireemail/class/view requireemail/locale requireemail/templates

Paul Westbrook paul at westbrooks.org
Mon Jan 29 06:19:01 EST 2007


Hello,
    This is the quick plugin that makes email address required for  
comments.  This works great, but I noticed a little annoyance.

$messages['comment_email'] is defined in the the main LifeType  
templates.  Unfortunately, this string specifies "(if any)".  Is  
there a mechanism to have a plugin optionally (only when enabled)  
override a string?

--Paul


On Jan 29, 2007, at 2:51 AM, pwestbro at devel.lifetype.net wrote:

> Author: pwestbro
> Date: 2007-01-29 05:51:24 -0500 (Mon, 29 Jan 2007)
> New Revision: 4609
>
> Added:
>    plugins/branches/lifetype-1.1/requireemail/
>    plugins/branches/lifetype-1.1/requireemail/class/
>    plugins/branches/lifetype-1.1/requireemail/class/action/
>    plugins/branches/lifetype-1.1/requireemail/class/action/ 
> pluginrequireemailconfigaction.class.php
>    plugins/branches/lifetype-1.1/requireemail/class/action/ 
> pluginrequireemailupdateconfigaction.class.php
>    plugins/branches/lifetype-1.1/requireemail/class/security/
>    plugins/branches/lifetype-1.1/requireemail/class/security/ 
> requireemailfilter.class.php
>    plugins/branches/lifetype-1.1/requireemail/class/view/
>    plugins/branches/lifetype-1.1/requireemail/class/view/ 
> pluginrequireemailconfigview.class.php
>    plugins/branches/lifetype-1.1/requireemail/locale/
>    plugins/branches/lifetype-1.1/requireemail/locale/locale_en_UK.php
>    plugins/branches/lifetype-1.1/requireemail/ 
> pluginrequireemail.class.php
>    plugins/branches/lifetype-1.1/requireemail/readme.txt
>    plugins/branches/lifetype-1.1/requireemail/templates/
>    plugins/branches/lifetype-1.1/requireemail/templates/ 
> requireemail.template
> Log:
> Checkin of plugin that makes email address required for adding a  
> comment.
>
>
> Added: plugins/branches/lifetype-1.1/requireemail/class/action/ 
> pluginrequireemailconfigaction.class.php
> ===================================================================
> --- plugins/branches/lifetype-1.1/requireemail/class/action/ 
> pluginrequireemailconfigaction.class.php	                         
> (rev 0)
> +++ plugins/branches/lifetype-1.1/requireemail/class/action/ 
> pluginrequireemailconfigaction.class.php	2007-01-29 10:51:24 UTC  
> (rev 4609)
> @@ -0,0 +1,49 @@
> +<?php
> +
> +    /*
> +    Copyright 2006 Paul Westbrook (paul at westbrooks.org)
> +
> +    This program is free software; you can redistribute it and/or  
> modify
> +    it under the terms of the GNU General Public License as  
> published by
> +    the Free Software Foundation; either version 2 of the License, or
> +    (at your option) any later version.
> +
> +    This program is distributed in the hope that it will be useful,
> +    but WITHOUT ANY WARRANTY; without even the implied warranty of
> +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +    GNU General Public License for more details.
> +
> +    You should have received a copy of the GNU General Public License
> +    along with this program; if not, write to the Free Software
> +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   
> 02111-1307  USA
> +    */
> +
> +	include_once( PLOG_CLASS_PATH."class/action/admin/ 
> blogowneradminaction.class.php" );
> +    include_once( PLOG_CLASS_PATH."plugins/requireemail/class/view/ 
> pluginrequireemailconfigview.class.php" );
> +
> +    class PluginRequireEmailConfigAction extends BlogOwnerAdminAction
> +	{
> +
> +    	/**
> +         * Constructor. If nothing else, it also has to call the  
> constructor of the parent
> +         * class, BlogAction with the same parameters
> +         */
> +        function PluginRequireEmailConfigAction( $actionInfo,  
> $request )
> +        {
> +        	$this->BlogOwnerAdminAction( $actionInfo, $request );
> +        }
> +
> +        /**
> +         * Carries out the specified action
> +         */
> +        function perform()
> +        {
> +			$this->_view = new PluginRequireEmailConfigView( $this- 
> >_blogInfo );
> +
> +            $this->setCommonData();
> +
> +            // better to return true if everything fine
> +            return true;
> +        }
> +    }
> +?>
>
> Added: plugins/branches/lifetype-1.1/requireemail/class/action/ 
> pluginrequireemailupdateconfigaction.class.php
> ===================================================================
> --- plugins/branches/lifetype-1.1/requireemail/class/action/ 
> pluginrequireemailupdateconfigaction.class.php	                        
>  (rev 0)
> +++ plugins/branches/lifetype-1.1/requireemail/class/action/ 
> pluginrequireemailupdateconfigaction.class.php	2007-01-29 10:51:24  
> UTC (rev 4609)
> @@ -0,0 +1,87 @@
> +<?php
> +
> +    /*
> +    Copyright 2006 Paul Westbrook (paul at westbrooks.org)
> +
> +    This program is free software; you can redistribute it and/or  
> modify
> +    it under the terms of the GNU General Public License as  
> published by
> +    the Free Software Foundation; either version 2 of the License, or
> +    (at your option) any later version.
> +
> +    This program is distributed in the hope that it will be useful,
> +    but WITHOUT ANY WARRANTY; without even the implied warranty of
> +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +    GNU General Public License for more details.
> +
> +    You should have received a copy of the GNU General Public License
> +    along with this program; if not, write to the Free Software
> +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   
> 02111-1307  USA
> +    */
> +
> +	include_once( PLOG_CLASS_PATH."class/action/admin/ 
> blogowneradminaction.class.php" );
> +    include_once( PLOG_CLASS_PATH."plugins/requireemail/class/view/ 
> pluginrequireemailconfigview.class.php" );
> +
> +    $apiKeyValid = true;
> +
> +    class PluginRequireEmailUpdateConfigAction extends  
> BlogOwnerAdminAction
> +	{
> +	
> +		var $_pluginEnabled;
> +
> +
> +    	/**
> +         * Constructor. If nothing else, it also has to call the  
> constructor of the parent
> +         * class, BlogAction with the same parameters
> +         */
> +        function PluginRequireEmailUpdateConfigAction 
> ( $actionInfo, $request )
> +        {
> +        	$this->BlogOwnerAdminAction( $actionInfo, $request );
> +        }
> +		
> +		function validate()
> +		{
> +
> +            $this->_pluginEnabled = $this->_request->getValue 
> ( "pluginEnabled" );
> +            $this->_pluginEnabled = ($this->_pluginEnabled !=  
> "" );			
> +
> +			return true;
> +		}
> +		
> +        /**
> +         * Carries out the specified action
> +         */
> +        function perform()
> +        {
> +            // update the plugin configurations to blog setting
> +			$blogSettings = $this->_blogInfo->getSettings();
> +            $blogSettings->setValue 
> ( "plugin_requireemail_enabled", $this->_pluginEnabled );
> +
> +            $this->_blogInfo->setSettings( $blogSettings );
> +		
> +			// save the blogs settings
> +			$blogs = new Blogs();
> +            if( !$blogs->updateBlog( $this->_blogInfo )) {
> +                $this->_view = new PluginRequireEmailConfigView 
> ( $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 PluginRequireEmailConfigView( $this- 
> >_blogInfo );
> +			$this->_view->setSuccessMessage( $this->_locale->tr 
> ("requireemail_settings_saved_ok"));			
> +			$this->setCommonData();
> +			
> +			// clear the cache
> +			CacheControl::resetBlogCache( $this->_blogInfo->getId());					
> +
> +            return true;		
> +        }
> +    }
> +
> +?>
>
> Added: plugins/branches/lifetype-1.1/requireemail/class/security/ 
> requireemailfilter.class.php
> ===================================================================
> --- plugins/branches/lifetype-1.1/requireemail/class/security/ 
> requireemailfilter.class.php	                        (rev 0)
> +++ plugins/branches/lifetype-1.1/requireemail/class/security/ 
> requireemailfilter.class.php	2007-01-29 10:51:24 UTC (rev 4609)
> @@ -0,0 +1,87 @@
> +<?php
> +
> +    /*
> +    Copyright 2006 Paul Westbrook (paul at westbrooks.org)
> +
> +    This program is free software; you can redistribute it and/or  
> modify
> +    it under the terms of the GNU General Public License as  
> published by
> +    the Free Software Foundation; either version 2 of the License, or
> +    (at your option) any later version.
> +
> +    This program is distributed in the hope that it will be useful,
> +    but WITHOUT ANY WARRANTY; without even the implied warranty of
> +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +    GNU General Public License for more details.
> +
> +    You should have received a copy of the GNU General Public License
> +    along with this program; if not, write to the Free Software
> +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   
> 02111-1307  USA
> +    */
> +
> +	include_once( PLOG_CLASS_PATH."class/security/ 
> pipelinefilter.class.php" );
> +
> +
> +    // custom error code that will be returned to the pipeline  
> whenever an
> +    // error is found... Be careful so as to not to have two  
> different modules
> +    // use the same code!!
> +    define( "REQUIREEMAIL_SPAM", 810 );
> +
> +	class RequireEmailFilter extends PipelineFilter
> +	{
> +
> +    	function RequireEmailFilter( $pipelineRequest )
> +        {
> +        	$this->PipelineFilter( $pipelineRequest );
> +        }
> +
> +        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_requireemail_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;
> +            }
> +
> +            // if this is already rejected, there is no reason to  
> do anything here
> +            if ( $this->_pipelineRequest->getRejectedState() )
> +                return new PipelineResult();
> +
> +            // text and topic of the comment
> +            $userEmail = $request->getValue( "userEmail" );
> +
> +            if (trim($userEmail) == "") {
> +                //  Assume that if the user had entered something  
> in this field, that
> +                // LifeType has validated the input.
> +               $locale = $blogInfo->getLocale();
> +               $result = new PipelineResult( false,  
> REQUIREEMAIL_SPAM, $locale->tr("requireemail_missing_email") );
> +               return $result;
> +
> +            }
> +
> +
> +            // if everything went fine, we can say so by returning
> +            // a positive PipelineResult object
> +            $result = new PipelineResult( true );
> +
> +            return $result;
> +        }
> +
> +    }
> +
> +
> +?>
>
> Added: plugins/branches/lifetype-1.1/requireemail/class/view/ 
> pluginrequireemailconfigview.class.php
> ===================================================================
> --- plugins/branches/lifetype-1.1/requireemail/class/view/ 
> pluginrequireemailconfigview.class.php	                        (rev 0)
> +++ plugins/branches/lifetype-1.1/requireemail/class/view/ 
> pluginrequireemailconfigview.class.php	2007-01-29 10:51:24 UTC (rev  
> 4609)
> @@ -0,0 +1,46 @@
> +<?php
> +	
> +    /*
> +    Copyright 2006 Paul Westbrook (paul at westbrooks.org)
> +
> +    This program is free software; you can redistribute it and/or  
> modify
> +    it under the terms of the GNU General Public License as  
> published by
> +    the Free Software Foundation; either version 2 of the License, or
> +    (at your option) any later version.
> +
> +    This program is distributed in the hope that it will be useful,
> +    but WITHOUT ANY WARRANTY; without even the implied warranty of
> +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +    GNU General Public License for more details.
> +
> +    You should have received a copy of the GNU General Public License
> +    along with this program; if not, write to the Free Software
> +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   
> 02111-1307  USA
> +    */
> +
> +	include_once( PLOG_CLASS_PATH."class/view/admin/ 
> adminplugintemplatedview.class.php" );
> +
> +	/**
> +	 * implements the main view of the validate trackback plugin
> +	 */
> +	class PluginRequireEmailConfigView extends AdminPluginTemplatedView
> +	{
> +
> +		function PluginRequireEmailConfigView( $blogInfo )
> +		{
> +			$this->AdminPluginTemplatedView( $blogInfo, "requireemail",  
> "requireemail" );
> +		}
> +		
> +		function render()
> +		{
> +			// load some configuration settings
> +			$blogSettings = $this->_blogInfo->getSettings();
> +			$pluginEnabled = $blogSettings->getValue 
> ( "plugin_requireemail_enabled" );			
> +			
> +			// create a view and export the settings to the template
> +			$this->setValue( "pluginEnabled", $pluginEnabled );
> +			
> +			parent::render();
> +		}
> +	}
> +?>
> \ No newline at end of file
>
> Added: plugins/branches/lifetype-1.1/requireemail/locale/ 
> locale_en_UK.php
> ===================================================================
> --- plugins/branches/lifetype-1.1/requireemail/locale/ 
> locale_en_UK.php	                        (rev 0)
> +++ plugins/branches/lifetype-1.1/requireemail/locale/ 
> locale_en_UK.php	2007-01-29 10:51:24 UTC (rev 4609)
> @@ -0,0 +1,14 @@
> +<?php
> +$messages["manageAntiSpamPlugins"] = "Anti Spam Management";
> +$messages["requireemailPluginSettings"] = "Require Email";
> +$messages["requireemail"] = "Require Email";
> +
> +$messages["requireemail_plugin_enabled"] = "Enable this plugin";
> +$messages["requireemail_plugin"] = "Require Email Plugin";
> +
> +$messages["requireemail_settings_saved_ok"] = "Require Email  
> settings saved successfully!";
> +$messages["requireemail_missing_email"] = "Email addresses are  
> required to post comments";
> +
> +$messages["label_configuration"] = "Configuration";
> +$messages["label_enable"] = "Enable";
> +?>
> \ No newline at end of file
>
> Added: plugins/branches/lifetype-1.1/requireemail/ 
> pluginrequireemail.class.php
> ===================================================================
> --- plugins/branches/lifetype-1.1/requireemail/ 
> pluginrequireemail.class.php	                        (rev 0)
> +++ plugins/branches/lifetype-1.1/requireemail/ 
> pluginrequireemail.class.php	2007-01-29 10:51:24 UTC (rev 4609)
> @@ -0,0 +1,67 @@
> +<?php
> +
> +    /*
> +    Copyright 2006 Paul Westbrook (paul at westbrooks.org)
> +
> +    This program is free software; you can redistribute it and/or  
> modify
> +    it under the terms of the GNU General Public License as  
> published by
> +    the Free Software Foundation; either version 2 of the License, or
> +    (at your option) any later version.
> +
> +    This program is distributed in the hope that it will be useful,
> +    but WITHOUT ANY WARRANTY; without even the implied warranty of
> +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +    GNU General Public License for more details.
> +
> +    You should have received a copy of the GNU General Public License
> +    along with this program; if not, write to the Free Software
> +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA   
> 02111-1307  USA
> +    */
> +
> +	include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
> +	include_once( PLOG_CLASS_PATH."class/plugin/ 
> pluginmanager.class.php" );
> +    include_once( PLOG_CLASS_PATH."plugins/requireemail/class/ 
> security/requireemailfilter.class.php" );
> +
> +	class PluginRequireEmail extends PluginBase
> +	{
> +		var $pluginEnabled;
> +		
> +		function PluginRequireEmail()
> +		{
> +			$this->PluginBase();
> +
> +			$this->id      = "requireemail";
> +			$this->desc    = "The Require Email plugin requires that an  
> email is entered for comments.";
> +			$this->author  = "Paul Westbrook";
> +			$this->locales = Array( "en_UK" );
> +
> +			$this->init();
> +		}
> +
> +		function init()
> +		{
> +            $this->registerFilter( "RequireEmailFilter" );
> +
> +            $this->registerAdminAction( "requireemail",  
> "PluginRequireEmailConfigAction" );
> +			$this->registerAdminAction( "updateRequireEmailConfig",  
> "PluginRequireEmailUpdateConfigAction" );
> +			
> +		    include_once( PLOG_CLASS_PATH."class/template/menu/ 
> menu.class.php" );
> +
> +			$menu =& Menu::getMenu();
> +			if( !$menu->entryExists( "/menu/controlCenter/ 
> manageAntiSpamPlugins" ))						
> +				$this->addMenuEntry( "/menu/controlCenter",  
> "manageAntiSpamPlugins", "", "", true, false );			
> +            $this->addMenuEntry( "/menu/controlCenter/ 
> manageAntiSpamPlugins", "requireemail", "?op=requireemail", "" );
> +		}
> +
> +		function register()
> +		{
> +		    $blogSettings = $this->blogInfo->getSettings();
> +			$this->pluginEnabled = $blogSettings->getValue 
> ( "plugin_requireemail_enabled" );
> +		}
> +
> +	    function isEnabled()
> +	    {
> +	        return $this->pluginEnabled;
> +	    }
> +	}
> +?>
> \ No newline at end of file
>
> Added: plugins/branches/lifetype-1.1/requireemail/readme.txt
> ===================================================================
> --- plugins/branches/lifetype-1.1/requireemail/ 
> readme.txt	                        (rev 0)
> +++ plugins/branches/lifetype-1.1/requireemail/readme.txt	 
> 2007-01-29 10:51:24 UTC (rev 4609)
> @@ -0,0 +1,9 @@
> +Plugin: Require Email
> +Author: Paul Westbrook
> +Release Date: 08/27/2006
> +Version: 1.0
> +
> +The Require Email plugin requires email address to be speicified  
> for all comments.
> +
> +Install:
> +1. Configurate your Require Email plugin in your LifeType control  
> center
> \ No newline at end of file
>
> Added: plugins/branches/lifetype-1.1/requireemail/templates/ 
> requireemail.template
> ===================================================================
> --- plugins/branches/lifetype-1.1/requireemail/templates/ 
> requireemail.template	                        (rev 0)
> +++ plugins/branches/lifetype-1.1/requireemail/templates/ 
> requireemail.template	2007-01-29 10:51:24 UTC (rev 4609)
> @@ -0,0 +1,25 @@
> +{include file="$admintemplatepath/header.template"}
> +{include file="$admintemplatepath/navigation.template"  
> showOpt=requireemail title=$locale->tr("requireemail_plugin")}
> +<form name="requireemailPluginSettings" method="post">
> + <fieldset class="inputField">
> + <legend>{$locale->tr("label_configuration")}</legend>
> +  {include file="$admintemplatepath/successmessage.template"}
> +  {include file="$admintemplatepath/errormessage.template"}
> +  <div class="field">
> +   <label for="pluginEnabled">{$locale->tr("label_enable")}</label>
> +   <div class="formHelp">
> +    <input class="checkbox" type="checkbox" name="pluginEnabled"  
> id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if}  
> value="1" />{$locale->tr("requireemail_plugin_enabled")}
> +   </div>
> +  </div>
> +
> +
> + </fieldset>
> +
> + <div class="buttons">
> +  <input type="hidden" name="op" value="updateRequireEmailConfig" />
> +  <input type="reset" name="{$locale->tr("reset")}" />
> +  <input type="submit" name="{$locale->tr("update_settings")}"  
> value="{$locale->tr("update")}" />
> + </div>
> +</form>
> +{include file="$admintemplatepath/footernavigation.template"}
> +{include file="$admintemplatepath/footer.template"}
> \ No newline at end of file
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://limedaley.com/mailman/listinfo/plog-svn

--
Paul Westbrook
paul at westbrooks.org
<http://www.westbrooks.org>




More information about the pLog-svn mailing list