<?php
/*
Plugin - PlogStaticRotator
Copyright (C) 2005 Matthew Wood
                                                                                
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
*/

                                                                                
include_once(PLOG_CLASS_PATH."class/action/admin/blogowneradminaction.class.php");
include_once(PLOG_CLASS_PATH.
    "plugins/plogstaticrotator/class/view/adminstaticcontentview.class.php");
include_once(PLOG_CLASS_PATH.
    "plugins/plogstaticrotator/class/dao/plogstaticrotatorcontents.class.php");
include_once(PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php");

class AdminPlogStaticRotatorDeleteAction extends BlogOwnerAdminAction
{
  function AdminPlogStaticRotatorDeleteAction($actionInfo,$request)
  {
    $this->BlogOwnerAdminAction($actionInfo,$request);
    $this->_view = new 
      AdminStaticContentView($this->_blogInfo,"admincontentview");
  }
  
  function perform()
  {
    $stids = $this->_request->getValue("cid");
    $staticModel = new PlogStaticRotatorContents();

    $smsg = $emsg = "";
    
    if ($stids != "")
    {
      foreach ($stids as $stid)
      {
        if (!$staticModel->deleteContent($stid,$this->_blogInfo->getId()))
          $emsg .= "failure to delete $stid\n";
        else
          $smsg .= "delete of $stid succeded\n";
      }
    }

    if ($smsg != "")
      $this->_view->setSuccessMessage($smsg);
    if ($emsg != "")
      $this->_view->setErrorMessage($emsg);

    $contents = $staticModel->getAllContent($this->_blogInfo->getId());
    $this->_view->setValue("contents",$contents);

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

/* vim:cin:ai:sw=2:expandtab:
*/

?>
