<?php
/*****************************************************************************\
 * phpGroupWare - Forums                                                       *
 * http://www.phpgroupware.org                                                 *
 * Written by Jani Hirvinen <jpkh@shadownet.com>                               *
 * -------------------------------------------                                 *
 *  This program 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.                                                 *
 \*****************************************************************************/

/* $Id: preference_deletecategory.php 21086 2010-03-25 22:56:09Z Caeies $ */

	$GLOBALS['phpgw_info']['flags'] = array(
						'currentapp'		=> 'forum',
						'enable_nextmatchs_class' => True
						);
	if( $_REQUEST['confirm'] || ! $_REQUEST['cat_id'] )
	{
		$phpgw_info["flags"]["noheader"] = True;
		$phpgw_info["flags"]["nonavbar"] = True;
	}
	include_once('../header.inc.php');

	if ( $_REQUEST['cat_id'] && !$_REQUEST['confirm'] )
	{
		?>
			<center>
			<table border=0 width=65%>
			<tr colspan=2>
			<td align=center>
			<?php echo lang("Are you sure you want to delete this category?"); ?>
			<td>
			</tr>
			<tr colspan=2>
			<td align=center>
			<?php echo "<font color=\"red\"><blink>".lang("All forums, user posts, and topics in this category will be lost!")."</blink></font>"; ?>
			</td>
			</tr>
			<tr>
			<td>
			<a href="<?php echo $GLOBALS['phpgw']->link("/forum") . "\">" . lang("No"); ?></a>
			</td>
			<td>
			<a href="<?php echo $GLOBALS['phpgw']->link("/forum/preference_deletecategory.php","cat_id=$cat_id&confirm=true") . "\">" . lang("Yes"); ?></a>
			</td>
			</tr>
			</table>
			</center>
			<?php
			$GLOBALS['phpgw']->common->phpgw_footer();
	}

	if ( $_REQUEST['cat_id'] && $_REQUEST['confirm'])
	{
		$cat_id = intval($_REQUEST['cat_id']);
		$GLOBALS['phpgw']->db->query("DELETE FROM f_threads WHERE cat_id=$cat_id", __LINE__, __FILE__);
		$GLOBALS['phpgw']->db->query("DELETE FROM f_body WHERE cat_id=$cat_id", __LINE__, __FILE__);
		$GLOBALS['phpgw']->db->query("DELETE FROM f_forums WHERE cat_id=$cat_id", __LINE__, __FILE__);
		$GLOBALS['phpgw']->db->query("DELETE FROM f_categories WHERE id=$cat_id", __LINE__, __FILE__);
		$GLOBALS['phpgw']->redirect_link('/forum');
	}
	?>
