[pLog-svn] r1018 - in plugins/trunk/hostblock: . class/action
class/security class/view templates
mark at devel.plogworld.net
mark at devel.plogworld.net
Wed Feb 9 07:12:42 GMT 2005
Author: mark
Date: 2005-02-09 07:12:41 +0000 (Wed, 09 Feb 2005)
New Revision: 1018
Added:
plugins/trunk/hostblock/class/action/adminupdatebloghostblockconfigaction.class.php
plugins/trunk/hostblock/class/action/adminupdatehostblockconfigaction.class.php
Modified:
plugins/trunk/hostblock/class/security/hostsblacklist.class.php
plugins/trunk/hostblock/class/view/adminblockedhostsview.class.php
plugins/trunk/hostblock/class/view/adminblogblockedhostsview.class.php
plugins/trunk/hostblock/pluginhostblock.class.php
plugins/trunk/hostblock/templates/blockedhosts.template
plugins/trunk/hostblock/templates/blogblockedhosts.template
Log:
Add enable/disable capability to hostblock plugin.
Added: plugins/trunk/hostblock/class/action/adminupdatebloghostblockconfigaction.class.php
===================================================================
--- plugins/trunk/hostblock/class/action/adminupdatebloghostblockconfigaction.class.php 2005-02-09 07:10:07 UTC (rev 1017)
+++ plugins/trunk/hostblock/class/action/adminupdatebloghostblockconfigaction.class.php 2005-02-09 07:12:41 UTC (rev 1018)
@@ -0,0 +1,55 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/hostblock/class/view/adminblogblockedhostsview.class.php" );
+
+ /**
+ * updates the plugin configuration
+ */
+ class AdminUpdateBlogHostBlockConfigAction extends BlogOwnerAdminAction
+ {
+ var $_pluginEnabled;
+
+ function AdminUpdateBlogHostBlockConfigAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ function validate()
+ {
+ $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+ $this->_pluginEnabled = ($this->_pluginEnabled != "" );
+
+ return true;
+ }
+
+ function perform()
+ {
+ // update the plugin configurations to blog setting
+ $blogSettings = $this->_blogInfo->getSettings();
+ $blogSettings->setValue( "plugin_hostblock_enabled", $this->_pluginEnabled );
+ $this->_blogInfo->setSettings( $blogSettings );
+
+ // save the blogs settings
+ $blogs = new Blogs();
+ if( !$blogs->updateBlog( $this->_blogInfo->getId(), $this->_blogInfo )) {
+ $this->_view = new AdminBlogBlockedHostsView( $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 AdminBlogBlockedHostsView( $this->_blogInfo );
+ $this->_view->setSuccessMessage( $this->_locale->tr("hostblock_settings_saved_ok"));
+ $this->setCommonData();
+
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Added: plugins/trunk/hostblock/class/action/adminupdatehostblockconfigaction.class.php
===================================================================
--- plugins/trunk/hostblock/class/action/adminupdatehostblockconfigaction.class.php 2005-02-09 07:10:07 UTC (rev 1017)
+++ plugins/trunk/hostblock/class/action/adminupdatehostblockconfigaction.class.php 2005-02-09 07:12:41 UTC (rev 1018)
@@ -0,0 +1,55 @@
+<?php
+
+ include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
+ include_once( PLOG_CLASS_PATH."plugins/hostblock/class/view/adminblockedhostsview.class.php" );
+
+ /**
+ * updates the plugin configuration
+ */
+ class AdminUpdateHostBlockConfigAction extends AdminAction
+ {
+ var $_pluginEnabled;
+
+ function AdminUpdateHostBlockConfigAction( $actionInfo, $request )
+ {
+ $this->AdminAction( $actionInfo, $request );
+ }
+
+ function validate()
+ {
+ $this->_pluginEnabled = $this->_request->getValue( "pluginEnabled" );
+ $this->_pluginEnabled = ($this->_pluginEnabled != "" );
+
+ return true;
+ }
+
+ function perform()
+ {
+ // update the plugin configurations to blog setting
+ $blogSettings = $this->_blogInfo->getSettings();
+ $blogSettings->setValue( "plugin_hostblock_enabled", $this->_pluginEnabled );
+ $this->_blogInfo->setSettings( $blogSettings );
+
+ // save the blogs settings
+ $blogs = new Blogs();
+ if( !$blogs->updateBlog( $this->_blogInfo->getId(), $this->_blogInfo )) {
+ $this->_view = new AdminBlockedHostsView( $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 AdminBlockedHostsView( $this->_blogInfo );
+ $this->_view->setSuccessMessage( $this->_locale->tr("hostblock_settings_saved_ok"));
+ $this->setCommonData();
+
+ return true;
+ }
+ }
+?>
\ No newline at end of file
Modified: plugins/trunk/hostblock/class/security/hostsblacklist.class.php
===================================================================
--- plugins/trunk/hostblock/class/security/hostsblacklist.class.php 2005-02-09 07:10:07 UTC (rev 1017)
+++ plugins/trunk/hostblock/class/security/hostsblacklist.class.php 2005-02-09 07:12:41 UTC (rev 1018)
@@ -19,19 +19,20 @@
function filter()
{
+ // get all the hosts that have been blacklisted
+ // by this blog
+ $blogInfo = $this->_pipelineRequest->getBlogInfo();
+ $request = $this->_pipelineRequest->getHttpRequest();
+
// check if this section has been enabled or disabled
- $config =& Config::getConfig();
- if( !$config->getValue( "ip_address_filter_enabled" )) {
+ $blogSettings = $blogInfo->getSettings();
+ $pluginEnabled = $blogSettings->getValue( "plugin_hostblock_enabled" );
+ if( !$pluginEnabled) {
// if not, nothing to do here...
//_debug("ip address filter not enabled! quitting...<br/>");
return new PipelineResult();
- }
+ }
- // get all the hosts that have been blacklisted
- // by this blog
- $blogInfo = $this->_pipelineRequest->getBlogInfo();
- $request = $this->_pipelineRequest->getHttpRequest();
-
// get the list of blocked hosts for this blog
$blockedHosts = new BlockedHosts();
$hostsAccessBlocked = $blockedHosts->getBlogBlacklist( $blogInfo->getId(), BLOCK_ACCESS, true );
Modified: plugins/trunk/hostblock/class/view/adminblockedhostsview.class.php
===================================================================
--- plugins/trunk/hostblock/class/view/adminblockedhostsview.class.php 2005-02-09 07:10:07 UTC (rev 1017)
+++ plugins/trunk/hostblock/class/view/adminblockedhostsview.class.php 2005-02-09 07:12:41 UTC (rev 1018)
@@ -2,6 +2,7 @@
include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
include_once( PLOG_CLASS_PATH."plugins/hostblock/class/dao/blockedhosts.class.php" );
+
/**
* implements the main view of the feed reader plugin
*/
@@ -15,6 +16,9 @@
function render()
{
+ $blogSettings = $this->_blogInfo->getSettings();
+ $pluginEnabled = $blogSettings->getValue( "plugin_hostblock_enabled" );
+
// get the content that has been filtered by this blog
$blockedHosts = new BlockedHosts();
$hostsBlockedFromPosting = $blockedHosts->getBlogBlacklist( GLOBALLY_BLOCKED_HOST, BLOCK_COMMENT_POSTING );
@@ -22,6 +26,7 @@
$blogBlockedHosts = array_merge( $hostsBlockedFromPosting, $hostsBlocked );
+ $this->setValue( "pluginEnabled", $pluginEnabled );
$this->setValue( "blockedhosts", $blogBlockedHosts );
parent::render();
Modified: plugins/trunk/hostblock/class/view/adminblogblockedhostsview.class.php
===================================================================
--- plugins/trunk/hostblock/class/view/adminblogblockedhostsview.class.php 2005-02-09 07:10:07 UTC (rev 1017)
+++ plugins/trunk/hostblock/class/view/adminblogblockedhostsview.class.php 2005-02-09 07:12:41 UTC (rev 1018)
@@ -2,6 +2,7 @@
include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );
include_once( PLOG_CLASS_PATH."plugins/hostblock/class/dao/blockedhosts.class.php" );
+
/**
* implements the main view of the feed reader plugin
*/
@@ -15,6 +16,9 @@
function render()
{
+ $blogSettings = $this->_blogInfo->getSettings();
+ $pluginEnabled = $blogSettings->getValue( "plugin_hostblock_enabled" );
+
// get the content that has been filtered by this blog
$blockedHosts = new BlockedHosts();
$hostsBlockedFromPosting = $blockedHosts->getBlogBlacklist( $this->_blogInfo->getId(), BLOCK_COMMENT_POSTING );
@@ -22,6 +26,7 @@
$blogBlockedHosts = array_merge( $hostsBlockedFromPosting, $hostsBlocked );
+ $this->setValue( "pluginEnabled", $pluginEnabled );
$this->setValue( "blockedhosts", $blogBlockedHosts );
parent::render();
Modified: plugins/trunk/hostblock/pluginhostblock.class.php
===================================================================
--- plugins/trunk/hostblock/pluginhostblock.class.php 2005-02-09 07:10:07 UTC (rev 1017)
+++ plugins/trunk/hostblock/pluginhostblock.class.php 2005-02-09 07:12:41 UTC (rev 1018)
@@ -37,6 +37,9 @@
*/
function init()
{
+ // register the filter
+ $this->registerFilter( "HostsBlackList" );
+
// register the superadmin actions
$this->registerAdminAction( "blockedHosts", "AdminBlockedHostsAction" );
$this->registerAdminAction( "newBlockedHost", "AdminNewBlockedHostAction" );
@@ -45,8 +48,8 @@
$this->registerAdminAction( "updateBlockedHost", "AdminUpdateBlockedHostAction" );
$this->registerAdminAction( "deleteBlockedHost", "AdminDeleteBlockedHostAction" );
$this->registerAdminAction( "deleteBlockedHosts", "AdminDeleteBlockedHostAction" );
- // register the filter
- $this->registerFilter( "HostsBlackList" );
+ $this->registerAdminAction( "updateHostBlockConfig", "AdminUpdateHostBlockConfigAction" );
+
// register the blog owner actions
$this->registerAdminAction( "blogBlockHostFromPosting", "AdminBlogBlockHostFromPostingAction" );
$this->registerAdminAction( "blogBlockedHosts", "AdminBlogBlockedHostsAction" );
@@ -56,6 +59,7 @@
$this->registerAdminAction( "updateBlogBlockedHost", "AdminUpdateBlogBlockedHostAction" );
$this->registerAdminAction( "deleteBlogBlockedHost", "AdminDeleteBlogBlockedHostAction" );
$this->registerAdminAction( "deleteBlogBlockedHosts", "AdminDeleteBlogBlockedHostAction" );
+ $this->registerAdminAction( "updateBlogHostBlockConfig", "AdminUpdateBlogHostBlockConfigAction" );
// register the menu entries, but the first one is only registered if it hasn't been
// created yet
Modified: plugins/trunk/hostblock/templates/blockedhosts.template
===================================================================
--- plugins/trunk/hostblock/templates/blockedhosts.template 2005-02-09 07:10:07 UTC (rev 1017)
+++ plugins/trunk/hostblock/templates/blockedhosts.template 2005-02-09 07:12:41 UTC (rev 1018)
@@ -1,5 +1,28 @@
{include file="$admintemplatepath/header.template"}
{include file="$admintemplatepath/navigation.template" showOpt=blockedHosts title=$locale->tr("blockedHosts")}
+<div id="list_nav_bar">
+ <div id="list_nav_select">
+ <form id="hostBlock" action="admin.php" method="post">
+ <fieldset>
+ <legend>{$locale->tr("label_configuration")}</legend>
+ <div class="list_nav_option">
+ <label for="pluginEnabled">{$locale->tr("label_enable")}</label>
+ <span class="required"></span>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if} value="1" />{$locale->tr("hostblock_plugin_enabled")}
+ </div>
+ </div>
+ <div class="list_nav_option">
+ <br />
+ <input type="hidden" name="op" value="updateHostBlockConfig">
+ <input type="submit" name="{$locale->tr("update_settings")}" value="{$locale->tr("update")}">
+ </div>
+ </fieldset>
+ </form>
+ </div>
+ <br style="clear:both">
+</div>
+
<form name="blockedHosts" action="admin.php" method="post">
<div id="list">
{include file="$admintemplatepath/successmessage.template"}
Modified: plugins/trunk/hostblock/templates/blogblockedhosts.template
===================================================================
--- plugins/trunk/hostblock/templates/blogblockedhosts.template 2005-02-09 07:10:07 UTC (rev 1017)
+++ plugins/trunk/hostblock/templates/blogblockedhosts.template 2005-02-09 07:12:41 UTC (rev 1018)
@@ -1,5 +1,28 @@
{include file="$admintemplatepath/header.template"}
{include file="$admintemplatepath/navigation.template" showOpt=blogBlockedHosts title=$locale->tr("blogBlockedHosts")}
+<div id="list_nav_bar">
+ <div id="list_nav_select">
+ <form id="blogHostBlock" action="admin.php" method="post">
+ <fieldset>
+ <legend>{$locale->tr("label_configuration")}</legend>
+ <div class="list_nav_option">
+ <label for="pluginEnabled">{$locale->tr("label_enable")}</label>
+ <span class="required"></span>
+ <div class="formHelp">
+ <input class="checkbox" type="checkbox" name="pluginEnabled" id="pluginEnabled" {if $pluginEnabled} checked="checked" {/if} value="1" />{$locale->tr("hotblock_plugin_enabled")}
+ </div>
+ </div>
+ <div class="list_nav_option">
+ <br />
+ <input type="hidden" name="op" value="updateBlogHostBlockConfig">
+ <input type="submit" name="{$locale->tr("update_settings")}" value="{$locale->tr("update")}">
+ </div>
+ </fieldset>
+ </form>
+ </div>
+ <br style="clear:both">
+</div>
+
<form name="blogBlockedHosts" action="admin.php" method="post">
<div id="list">
{include file="$admintemplatepath/successmessage.template"}
More information about the pLog-svn
mailing list