<?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_deleteforum.php,v 1.4.4.1 2005/06/02 12:51:27 skwashd Exp $ */

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

	if ( $_REQUEST['for_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 forum?"); ?>
			<td>
			</tr>
			<tr colspan=2>
			<td align=center>
			<?php echo "<font color=\"red\"><blink>".lang("All user posts and topics will be lost!")."</blink></font>"; ?>
			</td>
			</tr>
			<tr>
			<td>
			<a href="<?php echo $GLOBALS['phpgw']->link('/forum/index.php') . "\">" . lang("No"); ?></a>
			</td>
			<td>
			<a href="<?php echo $GLOBALS['phpgw']->link('/forum/preference_deleteforum.php', 
						array('for_id' => intval($_REQUEST['for_id']), 'confirm' => 'true') ) . "\">" . lang("Yes"); ?></a>
			</td>
			</tr>
			</table>
			</center>
			<?php
			$phpgw->common->phpgw_footer();
	}

	if ( $_REQUEST['for_id'] && $_REQUEST['confirm'] )
	{
		$for_id = intval($_REQUEST['for_id']);
		$GLOBALS['phpgw']->db->query("DELETE FROM f_threads WHERE for_id = $for_id", __LINE__, __FILE__);
		$GLOBALS['phpgw']->db->query("DELETE FROM f_body WHERE for_id = $for_id", __LINE__, __FILE__);
		$GLOBALS['phpgw']->db->query("DELETE FROM f_forums WHERE id = $for_id", __LINE__, __FILE__);

		$GLOBALS['phpgw']->redirect_link('/forum/index.php');
	}
?>
