<?php

    include_once( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" );
    include_once( PLOG_CLASS_PATH."class/view/admin/adminplugintemplatedview.class.php" );

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

    /**
     * shows a form with the current configuration
    */
    class PluginShoutboxAction extends AdminAction {
        
        function PluginShoutboxAction( $actionInfo, $request ) {
            $this->AdminAction( $actionInfo, $request );
        }
        
        function perform() {
        
            // load some configuration settings
            $blogSettings = $this->_blogInfo->getSettings();

            if(!$blogSettings->getValue("plugin_shoutbox_dbok") || $blogSettings->getValue( "plugin_shoutbox_version") != '0.12') {
                header('Location: admin.php?op=setupShoutbox');
                exit();
            }

            // Get the shoutbox entries
            $s = new Shoutbox($this->_blogInfo->getId(), $blogSettings);
            
            // create a view and export the settings to the template
            $this->_view = new AdminPluginTemplatedView( $this->_blogInfo, "shoutbox", "shoutbox", true );
            $this->_view->setValue( "pluginEnabled", $pluginEnabled );
            //$this->_view->setValue( "Shoutboxet", $Shoutboxet );

            $this->_view->setValue( "shouts", $s->getShoutsArray());
            
            if($s->mail_alert)
                $mail_alert_checked = "checked";
            
            $this->_view->setValue( "mail_alert_checked", $mail_alert_checked);
            $this->_view->setValue( "max_length", $s->max_length);
            $this->_view->setValue( "shouts_per_view", $s->shouts_per_view);
            $this->_view->setValue( "default_nick", $s->default_nick);
            $this->_view->setValue( "default_shout", $s->default_shout);
            $this->_view->setValue( "protected_nicks", $s->protected_nicks);
            $this->_view->setValue( "protection_password", $s->protection_password);
            $this->_view->setValue( "current_page", $s->current_page);

                    
            $this->setCommonData();
            
            return true;
        }
}
?>