[pLog-svn] r7051 - in plugins/branches/lifetype-1.2/moderate: . class/action class/view locale templates
jondaley at devel.lifetype.net
jondaley at devel.lifetype.net
Fri Oct 8 14:37:38 EDT 2010
Author: jondaley
Date: 2010-10-08 14:37:38 -0400 (Fri, 08 Oct 2010)
New Revision: 7051
Modified:
plugins/branches/lifetype-1.2/moderate/class/action/adminmoderatepluginupdatesettingsaction.class.php
plugins/branches/lifetype-1.2/moderate/class/view/adminmoderatepluginsettingsview.class.php
plugins/branches/lifetype-1.2/moderate/locale/locale_en_UK.php
plugins/branches/lifetype-1.2/moderate/pluginmoderate.class.php
plugins/branches/lifetype-1.2/moderate/templates/pluginsettings.template
Log:
updated to 1.2 interface. Added two new checkboxes/features: allow authenticated users to bypass moderation, and allow previously approved commenters to skip moderation.
Modified: plugins/branches/lifetype-1.2/moderate/class/action/adminmoderatepluginupdatesettingsaction.class.php
===================================================================
--- plugins/branches/lifetype-1.2/moderate/class/action/adminmoderatepluginupdatesettingsaction.class.php 2010-10-08 18:28:07 UTC (rev 7050)
+++ plugins/branches/lifetype-1.2/moderate/class/action/adminmoderatepluginupdatesettingsaction.class.php 2010-10-08 18:37:38 UTC (rev 7051)
@@ -7,6 +7,8 @@
{
var $_pluginEnabled;
+ var $_bypassByIp;
+ var $_bypassByAuth;
/**
* Constructor. If nothing else, it also has to call the constructor of the parent
@@ -23,6 +25,12 @@
{
$this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
$this->_pluginEnabled = ($this->_pluginEnabled != "" );
+
+ $this->_bypassByIp = $this->_request->getValue( "bypassByIp" );
+ $this->_bypassByIp = ($this->_bypassByIp != "" );
+
+ $this->_bypassByAuth = $this->_request->getValue( "bypassByAuth" );
+ $this->_bypassByAuth = ($this->_bypassByAuth != "" );
return true;
}
@@ -35,6 +43,8 @@
// // update the plugin configurations to blog setting
$blogSettings = $this->_blogInfo->getSettings();
$blogSettings->setValue( "plugin_moderate_enabled", $this->_pluginEnabled );
+ $blogSettings->setValue( "plugin_moderate_bypass_by_ip", $this->_bypassByIp );
+ $blogSettings->setValue( "plugin_moderate_bypass_by_auth", $this->_bypassByAuth );
$this->_blogInfo->setSettings( $blogSettings );
// save the blogs settings
@@ -56,10 +66,7 @@
$this->_view->setSuccessMessage( $this->_locale->tr("moderate_settings_saved_ok"));
$this->setCommonData();
- // clear the cache
- CacheControl::resetBlogCache( $this->_blogInfo->getId());
-
return true;
}
}
-?>
+
Modified: plugins/branches/lifetype-1.2/moderate/class/view/adminmoderatepluginsettingsview.class.php
===================================================================
--- plugins/branches/lifetype-1.2/moderate/class/view/adminmoderatepluginsettingsview.class.php 2010-10-08 18:28:07 UTC (rev 7050)
+++ plugins/branches/lifetype-1.2/moderate/class/view/adminmoderatepluginsettingsview.class.php 2010-10-08 18:37:38 UTC (rev 7051)
@@ -18,9 +18,13 @@
// load some configuration settings
$blogSettings = $this->_blogInfo->getSettings();
$pluginEnabled = $blogSettings->getValue( "plugin_moderate_enabled" );
+ $bypassByIp = $blogSettings->getValue( "plugin_moderate_bypass_by_ip" );
+ $bypassByAuth = $blogSettings->getValue( "plugin_moderate_bypass_by_auth" );
// create a view and export the settings to the template
$this->setValue( "pluginEnabled", $pluginEnabled );
+ $this->setValue( "bypassByIp", $bypassByIp );
+ $this->setValue( "bypassByAuth", $bypassByAuth );
parent::render();
}
Modified: plugins/branches/lifetype-1.2/moderate/locale/locale_en_UK.php
===================================================================
--- plugins/branches/lifetype-1.2/moderate/locale/locale_en_UK.php 2010-10-08 18:28:07 UTC (rev 7050)
+++ plugins/branches/lifetype-1.2/moderate/locale/locale_en_UK.php 2010-10-08 18:37:38 UTC (rev 7051)
@@ -26,3 +26,6 @@
$messages["error_you_have_been_blocked"] = "Thank you! However, there was a problem processing your request.";
+$messages["moderate_label_skip_moderation"] = "Allow commenters to bypass moderation";
+$messages["moderate_bypass_by_ip"] = "Do not moderate commenters from computers (ip addresses) who have previously commented.";
+$messages["moderate_bypass_by_auth"] = "Do not moderate authenticated users.";
Modified: plugins/branches/lifetype-1.2/moderate/pluginmoderate.class.php
===================================================================
--- plugins/branches/lifetype-1.2/moderate/pluginmoderate.class.php 2010-10-08 18:28:07 UTC (rev 7050)
+++ plugins/branches/lifetype-1.2/moderate/pluginmoderate.class.php 2010-10-08 18:37:38 UTC (rev 7051)
@@ -10,17 +10,20 @@
{
var $pluginEnabled;
- function PluginModerate()
+ function PluginModerate($source = "")
{
- $this->PluginBase();
+ $this->PluginBase($source);
$this->id = "moderate";
$this->desc = "Provides moderation of comments";
$this->author = "The LifeType Project";
$this->locales = Array( "en_UK", "zh_TW", "es_ES", "fr_FR", "ca_ES" );
- $this->version = "20080102";
-
- $this->init();
+ $this->version = "20101008";
+
+ if( $source == "admin" )
+ $this->initAdmin();
+ else
+ $this->init();
}
/**
@@ -34,43 +37,64 @@
// make sure we're processing the right event!
if( $eventType != EVENT_PRE_COMMENT_ADD )
return true;
-
+
+ $blogSettings = $this->blogInfo->getSettings();
+
// do nothing if the plugin is not enabled!
- $blogSettings = $this->blogInfo->getSettings();
- if( !$blogSettings->getValue( "plugin_moderate_enabled" ))
+ if( !$blogSettings->getValue("plugin_moderate_enabled"))
return true;
-
- // change the stauts of the comment, as is easy as it seems...
- $comment = $params["comment"];
+
+ if($blogSettings->getValue("plugin_moderate_bypass_by_auth")){
+ // If this user is logged in, bypass moderation
+ if(SessionManager::getUserInfoFromSession())
+ return true;
+ }
+
+ $comment = $params["comment"];
+
+ if($blogSettings->getValue("plugin_moderate_bypass_by_ip")){
+ // if this ip has previously been used for a validated comment,
+ // don't moderate it
+
+ lt_include( PLOG_CLASS_PATH."class/database/db.class.php" );
+ $this->db =& Db::getDb();
+ $dbPrefix = Db::getPrefix();
+ $query = "SELECT id FROM ${dbPrefix}articles_comments WHERE ".
+ "client_ip = '".$comment->getClientIp()."' LIMIT 1";
+
+ $result = $this->db->Execute($query);
+ if($result && $result->RecordCount())
+ return true;
+ }
+
+ // set the comment as moderated:
+ // change the status of the comment, as is easy as it seems...
$comment->setStatus( COMMENT_STATUS_UNMODERATED );
$params["comment"] = $comment;
return true;
}
- /**
- * registers all the filters and actions that we're going to use
- */
- function init()
- {
- // register the events we want
+ function init(){
$this->registerNotification( EVENT_PRE_COMMENT_ADD );
-
- // register an action that will allow users to see which comments have not been
- // accepted yet
+ }
+
+ function initAdmin(){
$this->registerAdminAction( "unmoderatedComments", "AdminUnmoderatedCommentsAction" );
$this->registerAdminAction( "updateUnmoderatedComment", "AdminUpdateUnmoderatedCommentsAction" );
$this->registerAdminAction( "updateUnmoderatedComments", "AdminUpdateUnmoderatedCommentsAction" );
$this->registerAdminAction( "moderatePluginSettings", "AdminModeratePluginSettingsAction" );
$this->registerAdminAction( "moderatePluginUpdateSettings", "AdminModeratePluginUpdateSettingsAction" );
- // add a menu entry
- $this->addMenuEntry( "/menu/Manage/managePosts", "unmoderatedComments", "admin.php?op=unmoderatedComments", "" );
+ $this->addMenuEntry( "/menu/Manage/managePosts", "unmoderatedComments",
+ "admin.php?op=unmoderatedComments", "" );
$menu =& Menu::getMenu();
if( !$menu->entryExists( "/menu/controlCenter/manageAntiSpamPlugins" ))
$this->addMenuEntry( "/menu/controlCenter", "manageAntiSpamPlugins", "", "" );
- $this->addMenuEntry( "/menu/controlCenter/manageAntiSpamPlugins", "moderatePluginSettings", "admin.php?op=moderatePluginSettings", "" );
+ $this->addMenuEntry( "/menu/controlCenter/manageAntiSpamPlugins",
+ "moderatePluginSettings",
+ "admin.php?op=moderatePluginSettings", "" );
}
function register()
@@ -87,8 +111,9 @@
function getPluginConfigurationKeys()
{
return( Array(
- Array( "name" => "plugin_moderate_enabled", "type" => "boolean" )
+ Array( "name" => "plugin_moderate_enabled", "type" => "boolean" ),
+ Array( "name" => "plugin_moderate_bypass_by_ip", "type" => "boolean" ),
+ Array( "name" => "plugin_moderate_bypass_by_auth", "type" => "boolean" )
));
}
}
-?>
\ No newline at end of file
Modified: plugins/branches/lifetype-1.2/moderate/templates/pluginsettings.template
===================================================================
--- plugins/branches/lifetype-1.2/moderate/templates/pluginsettings.template 2010-10-08 18:28:07 UTC (rev 7050)
+++ plugins/branches/lifetype-1.2/moderate/templates/pluginsettings.template 2010-10-08 18:37:38 UTC (rev 7051)
@@ -5,12 +5,24 @@
<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" {user_cannot_override key=plugin_moderate_enabled}disabled="disabled"{/user_cannot_override}/>{$locale->tr("moderate_plugin_enabled")}
</div>
</div>
+
+ <div class="field">
+ <label for="bypassByIp">{$locale->tr("moderate_label_skip_moderation")}</label>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" name="bypassByIp" id="bypassByIp" {if $bypassByIp} checked="checked" {/if} value="1" {user_cannot_override key=plugin_moderate_bypass_by_ip}disabled="disabled"{/user_cannot_override}/>{$locale->tr("moderate_bypass_by_ip")}
+ </div>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" name="bypassByAuth" id="bypassByAuth" {if $bypassByAuth} checked="checked" {/if} value="1" {user_cannot_override key=plugin_moderate_bypass_by_auth}disabled="disabled"{/user_cannot_override}/>{$locale->tr("moderate_bypass_by_auth")}
+ </div>
+ </div>
+
</fieldset>
@@ -21,4 +33,4 @@
</div>
</form>
{include file="$admintemplatepath/footernavigation.template"}
-{include file="$admintemplatepath/footer.template"}
\ No newline at end of file
+{include file="$admintemplatepath/footer.template"}
More information about the pLog-svn
mailing list