<?php
/*
Plugin - PlogBirthday
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/siteadminaction.class.php");
include_once(PLOG_CLASS_PATH.
    "plugins/plogbirthdays/class/dao/plogbirthdays.class.php");
include_once(PLOG_CLASS_PATH.
    "plugins/plogbirthdays/class/view/adminplogbirthdaysview.class.php");
include_once(PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php");

class AdminPlogBirthdaysDeleteEntryAction extends SiteAdminAction
{
  function perform()
  {
    $pbdays = new PlogBirthdays();

    $emsg = $smsg = "";
    
    $bdayid = $this->_request->getValue('bdayid');
    $aryv = new ArrayValidator();
    if ($aryv->validate($bdayid))
    {
      foreach ($bdayid as $bid)
      {
        if($pbdays->deleteBirthday($bid))
          $smsg .= "Successfully deleted id ". $bid ."\n";
        else
          $emsg .= "Invalid id ". $bid ."\n";
      }
    }

    $total = $pbdays->getBirthdayCount();
    $this->_view = new AdminPlogBirthdaysView(
        $this->_blogInfo,1,$total,"plogbirthdaysView");
    
    if ($smsg != "")
      $this->_view->setSuccessMessage($smsg);
    if ($emsg != "")
      $this->_view->setErrorMessage($emsg);

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

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