<?php

    include_once( PLOG_CLASS_PATH."class/action/blogaction.class.php" );
    include_once( PLOG_CLASS_PATH."class/view/plugintemplatedview.class.php" );
    include_once( PLOG_CLASS_PATH."class/template/cachecontrol.class.php" );
    
    include_once( PLOG_CLASS_PATH."plugins/shoutbox/class/dao/shoutbox.class.php" );
    include_once( PLOG_CLASS_PATH."class/view/errorview.class.php" );

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

            // Get the shoutbox entries
            $s = new Shoutbox($this->_blogInfo->getId(), $blogSettings);
            $shoutId = (int)$this->_request->getValue('shoutId');
            $auth = $this->_request->getValue('auth');
            if($shoutId < 1 || !preg_match('/^[a-zA-Z0-9]+$/', $auth)) {
              $this->_view = new ErrorView($this->_blogInfo );
              $this->_view->setErrorMessage("Invalid parameters. Have you copied the link entirely?");
              $this->setCommonData();
              return true;
            }
            else if($blogSettings->getValue("plugin_shoutbox_quick_delete") == 1) {
              $s->deleteShout($shoutId, $auth);
              
              // Now reset this blog's cache
              CacheControl::resetBlogCache($this->_blogInfo->getId());
            }
            
            // create a view and export the settings to the template
            $this->_view = new PluginTemplatedView($this->_blogInfo, "shoutbox", "shoutbox_history" );
            $this->_view->setValue( "pluginEnabled", $pluginEnabled );
            //$this->_view->setValue( "Shoutboxet", $Shoutboxet );

            $reqPage = 1;
            if($reqPage <= $s->getLastPage())
              $this->_view->setValue("next_page", $reqPage + 1);
            $this->_view->setValue("shoutsHistory", $s->getShoutsArray($reqPage));

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