<?php

	lt_include( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
    lt_include( PLOG_CLASS_PATH."class/plugin/pluginmanager.class.php" );
	
	/**
	 * allows visitors to submit a message that will be
     *   emailed to the blog owner.
	 */
	class PluginContact extends PluginBase
	{
	
		function PluginContact( $source = "")
		{
			$this->PluginBase($source);
			$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";
			
			if( $source == "admin" )
				$this->initAdmin();
			else
				$this->init();
		}
		
		/**
		 * registers all the filters and actions that we're going to use on the admin side
		 */
		function initAdmin(){			
			$this->registerAdminAction( "pluginContactSettings", "AdminContactPluginSettingsAction" );
			$this->registerAdminAction( "pluginContactUpdateSettings", "AdminContactPluginUpdateSettingsAction" );
			$this->addMenuEntry( "/menu/controlCenter/manageSettings", "plugin_contact",
                                 "admin.php?op=pluginContactSettings");
        }

        /**
		 * registers all the filters and actions that we're going to use on the public side
		 */
		function init(){			
		    $this->registerBlogAction( "pluginContactSendEmail", "ContactPluginSendAction" );
		}

        function showForm(){
		    $blogSettings = $this->blogInfo->getSettings();
		    if(!$blogSettings->getValue("plugin_contact_enabled"))
                return "";

            $locale =& $this->blogInfo->getLocale();

            lt_include( PLOG_CLASS_PATH."class/view/plugintemplatedview.class.php" );
			$view = new PluginTemplatedView($this->blogInfo, "contact", "form");
            $view->render();
        }
        
        function getPluginConfigurationKeys(){

            return (Array(
                        Array("name" => "plugin_contact_enabled",
                              "type" => "boolean"),
                        Array("name" => "plugin_contact_banned_keywords",
                              "validator" => new StringValidator(),
                              "type" => "string",
                              "allowEmpty" => true)
                        ));
        }	
	}  
?>
