<?php
/*
 * @version $Id: HEADER 15930 2011-10-30 15:47:55Z tsmr $
 -------------------------------------------------------------------------
 Eventlog plugin for GLPI
 Copyright (C) 2003-2011 by the Eventlog Development Team.

 https://forge.indepnet.net/projects/eventlog
 -------------------------------------------------------------------------

 LICENSE
		
 This file is part of Eventlog.

 Eventlog is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 Eventlog is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with Eventlog. If not, see <http://www.gnu.org/licenses/>.
 --------------------------------------------------------------------------
 */

if (!defined('GLPI_ROOT')) {
	define('GLPI_ROOT', '../../..');
	include (GLPI_ROOT . "/inc/includes.php");
}

$plugin = new Plugin();
if ($plugin->isActivated("eventlog")) {

   Session::checkRight("config","w");

   $cat = new PluginEventlogTicketCategory();
   $know = new PluginEventlogKnowbaseItemCategory();

   if (isset($_POST["add_ticket"])) {

      $cat->addTicketCategory($_POST['ticketcategories_id']);
      Html::back();

   } else if (isset($_POST["delete_ticket"])) {

      foreach ($_POST["item"] as $key => $val) {
         if ($val==1) {
            $cat->delete(array('id'=>$key));
         }
      }
      Html::back();

   } else if (isset($_POST["add_knowbase"])) {

      $know->addKnowbaseItemsCategory($_POST['knowbaseitemcategories_id']);
      Html::back();

   } else if (isset($_POST["delete_knowbase"])) {

      foreach ($_POST["item"] as $key => $val) {
         if ($val==1) {
            $know->delete(array('id'=>$key));
         }
      }
      Html::back();

   } else {

      Html::header($LANG['common'][12],'',"plugins","eventlog");

      $cat->showForm();

      $know->showForm();

      Html::footer();

   }

} else {
   commonHeader($LANG["common"][12],'',"config","plugins");
   echo "<div align='center'><br><br><img src=\"".$CFG_GLPI["root_doc"]."/pics/warning.png\" alt=\"warning\"><br><br>";
   echo "<b>Please activate the plugin</b></div>";
   commonFooter();
}

?>