<?php

// -- plugin manager stuff
include_once( PLOG_CLASS_PATH."class/plugin/pluginbase.class.php" );
//include_once( PLOG_CLASS_PATH."class/plugin/eventpluginbase.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/blogs.class.php" );

// -- for the public side action
include_once( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
include_once( PLOG_CLASS_PATH."class/view/errorview.class.php" );

// -- for the admin side action
include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
include_once( PLOG_CLASS_PATH."class/view/admin/adminerrorview.class.php" );

include_once( PLOG_CLASS_PATH."plugins/shoutbox/class/dao/shoutbox.class.php" );

class PluginShoutbox extends PluginBase  {
    var $s;

    function PluginShoutbox()
    {
        $this->PluginBase();

        $this->desc    = "Shoutbox plugin: unleash your visitors";
        $this->author  = "Palantir (radar@netpalantir.it)";
        $this->id      = "shoutbox";
        $this->locales = Array( "en_UK", "it_IT");

        $this->registerAdminAction("shoutbox", "PluginShoutboxAction" );
        $this->registerAdminAction("shoutboxConfig", "PluginShoutboxConfigAction" );
        $this->registerAdminAction("updateShoutboxConfig", "PluginShoutboxUpdateConfigAction" );
        $this->registerAdminAction("deleteShouts", "PluginShoutboxDeleteShoutsAction" );
        
        $this->registerBlogAction("shoutboxHistory", "PluginShoutboxHistoryAction" );
        $this->registerBlogAction("shoutboxQuickDelete", "PluginShoutboxQuickDeleteAction" );
        $this->registerBlogAction("shoutboxNewShout", "PluginShoutboxNewShoutAction" );
        
        $this->addMenuEntry("/menu/controlCenter/manageSettings", "Shoutbox", "?op=shoutbox", "" );
    }

    function process( $eventType, $params )
    {
        // return the content as it came, as the caller class probably expected us to do
        // something with it...
        return $params;
    }

    function thinkAndDo() {
        if(!$this->s)
            $this->s = new Shoutbox($this->blogInfo->getId(), $this->blogSettings, $this->config);
        return $this->s->thinkAndDo();
    }

    function getDefaultNick() {
        if(!$this->s)
            $this->s = new Shoutbox($this->blogInfo->getId(), $this->blogSettings, $this->config);
        return $this->s->default_nick;
    }

    function getDefaultShout() {
        if(!$this->s)
            $this->s = new Shoutbox($this->blogInfo->getId(), $this->blogSettings, $this->config);
        return $this->s->default_shout;
    }
    
    function isShoutboxEnabled() {
        if(!$this->s)
            $this->s = new Shoutbox($this->blogInfo->getId(), $this->blogSettings, $this->config);
        return $this->s->shout_enabled;
    }
}