[pLog-svn] r4892 - in plugins/branches/lifetype-1.2: . requireemail requireemail/class requireemail/class/action requireemail/class/security requireemail/class/view requireemail/locale requireemail/templates
pwestbro at devel.lifetype.net
pwestbro at devel.lifetype.net
Thu Mar 1 00:22:50 EST 2007
Author: pwestbro
Date: 2007-03-01 00:22:50 -0500 (Thu, 01 Mar 2007)
New Revision: 4892
Added:
plugins/branches/lifetype-1.2/requireemail/
plugins/branches/lifetype-1.2/requireemail/class/
plugins/branches/lifetype-1.2/requireemail/class/action/
plugins/branches/lifetype-1.2/requireemail/class/action/pluginrequireemailconfigaction.class.php
plugins/branches/lifetype-1.2/requireemail/class/action/pluginrequireemailupdateconfigaction.class.php
plugins/branches/lifetype-1.2/requireemail/class/security/
plugins/branches/lifetype-1.2/requireemail/class/security/requireemailfilter.class.php
plugins/branches/lifetype-1.2/requireemail/class/view/
plugins/branches/lifetype-1.2/requireemail/class/view/pluginrequireemailconfigview.class.php
plugins/branches/lifetype-1.2/requireemail/locale/
plugins/branches/lifetype-1.2/requireemail/locale/locale_en_UK.php
plugins/branches/lifetype-1.2/requireemail/pluginrequireemail.class.php
plugins/branches/lifetype-1.2/requireemail/readme.txt
plugins/branches/lifetype-1.2/requireemail/templates/
plugins/branches/lifetype-1.2/requireemail/templates/requireemail.template
Log:
Ported the require email plugin from 1.1 to 1.2
Added: plugins/branches/lifetype-1.2/requireemail/class/action/pluginrequireemailconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/requireemail/class/action/pluginrequireemailconfigaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/requireemail/class/action/pluginrequireemailconfigaction.class.php 2007-03-01 05:22:50 UTC (rev 4892)
@@ -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/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/requireemail/class/view/pluginrequireemailconfigview.class.php" );
+
+ class PluginRequireEmailConfigAction extends AdminAction
+ {
+
+ /**
+ * 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->AdminAction( $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.2/requireemail/class/action/pluginrequireemailupdateconfigaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/requireemail/class/action/pluginrequireemailupdateconfigaction.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/requireemail/class/action/pluginrequireemailupdateconfigaction.class.php 2007-03-01 05:22:50 UTC (rev 4892)
@@ -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/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/requireemail/class/view/pluginrequireemailconfigview.class.php" );
+
+ $apiKeyValid = true;
+
+ class PluginRequireEmailUpdateConfigAction extends AdminAction
+ {
+
+ 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->AdminAction( $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.2/requireemail/class/security/requireemailfilter.class.php
===================================================================
--- plugins/branches/lifetype-1.2/requireemail/class/security/requireemailfilter.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/requireemail/class/security/requireemailfilter.class.php 2007-03-01 05:22:50 UTC (rev 4892)
@@ -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.2/requireemail/class/view/pluginrequireemailconfigview.class.php
===================================================================
--- plugins/branches/lifetype-1.2/requireemail/class/view/pluginrequireemailconfigview.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/requireemail/class/view/pluginrequireemailconfigview.class.php 2007-03-01 05:22:50 UTC (rev 4892)
@@ -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.2/requireemail/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.2/requireemail/locale/locale_en_UK.php (rev 0)
+++ plugins/branches/lifetype-1.2/requireemail/locale/locale_en_UK.php 2007-03-01 05:22:50 UTC (rev 4892)
@@ -0,0 +1,17 @@
+<?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";
+
+$messages['comment_email'] = 'Your email address';
+
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/requireemail/pluginrequireemail.class.php
===================================================================
--- plugins/branches/lifetype-1.2/requireemail/pluginrequireemail.class.php (rev 0)
+++ plugins/branches/lifetype-1.2/requireemail/pluginrequireemail.class.php 2007-03-01 05:22:50 UTC (rev 4892)
@@ -0,0 +1,86 @@
+<?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( $source = "" )
+ {
+ $this->PluginBase($source);
+
+ $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->version = "20070228";
+
+
+ if( $source == "admin" )
+ $this->initAdmin();
+ else
+ $this->init();
+ }
+
+ function init()
+ {
+ $this->registerFilter( "RequireEmailFilter" );
+ }
+
+
+ function initAdmin()
+ {
+ $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;
+ }
+
+ function getPluginConfigurationKeys()
+ {
+ return( Array(
+ Array( "name" => "plugin_requireemail_enabled", "type" => "boolean" ),
+ ));
+ }
+
+ }
+?>
\ No newline at end of file
Added: plugins/branches/lifetype-1.2/requireemail/readme.txt
===================================================================
--- plugins/branches/lifetype-1.2/requireemail/readme.txt (rev 0)
+++ plugins/branches/lifetype-1.2/requireemail/readme.txt 2007-03-01 05:22:50 UTC (rev 4892)
@@ -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.2/requireemail/templates/requireemail.template
===================================================================
--- plugins/branches/lifetype-1.2/requireemail/templates/requireemail.template (rev 0)
+++ plugins/branches/lifetype-1.2/requireemail/templates/requireemail.template 2007-03-01 05:22:50 UTC (rev 4892)
@@ -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
More information about the pLog-svn
mailing list