<?php
  /**************************************************************************\
  * phpGroupWare - Admin                                                     *
  * (http://www.phpgroupware.org)                                            *
  * Written by Bettina Gille [ceb@phpgroupware.org]                          *    
  * -----------------------------------------------                          *
  *  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: deletesite.php,v 1.1.1.2.6.1 2004/09/26 10:33:03 kazuyan Exp $ */

	if ($_POST['confirm'])
	{
		$GLOBALS['phpgw_info']['flags'] = array(
							'noheader' => True, 
							'nonavbar' => True
		);
	}

	$phpgw_info['flags']['currentapp'] = 'admin';
	$phpgw_info['flags']['enable_config_class'] = True;
	include('../header.inc.php');
	foreach ($_POST as $key => $val)
		$$key = get_var($key, array('POST'));
	foreach ($_GET as $key => $val)
		$$key = $$key ? $$key : get_var($key, array('GET'));

	if(!$phpgw->acl->check('run',1,'admin'))
	{
		echo lang('access not permitted');
		$phpgw->common->phpgw_footer();
		$phpgw->common->phpgw_exit();

	}

	if (!$site_id)
	{
		Header('Location: ' . $phpgw->link('/chora/sites.php'));
	}

	if ($confirm)
	{
		$GLOBALS['phpgw']->db->query('DELETE FROM phpgw_chora_sites'
						. ' WHERE id=' . intval($site_id), __LINE__, __FILE__);
		Header('Location: ' . $GLOBALS['phpgw']->link('/chora/sites.php',"start=$start&query=$query&sort=$sort&order=$order&filter=$filter"));
	}
	else
	{
		$hidden_vars = '<input type="hidden" name="sort" value="' . $sort . "\">\n"
			. '<input type="hidden" name="order" value="' . $order . "\">\n"
			. '<input type="hidden" name="query" value="' . $query . "\">\n"
			. '<input type="hidden" name="start" value="' . $start. "\">\n"
			. '<input type="hidden" name="filter" value="' . $filter. "\">\n"
			. '<input type="hidden" name="site_id" value="' . $site_id . "\">\n";

		$t = CreateObject('phpgwapi.Template',$GLOBALS['phpgw']->common->get_tpl_dir('chora'));
		$t->set_file(array('site_delete' => 'delete_common.tpl'));
		$t->set_var('messages',lang('Are you sure you want to delete this repository?'));

		$nolinkf = $GLOBALS['phpgw']->link('/chora/sites.php',array('site_id' => $site_id,
									'start' => $start,
									'query' => $query,
									'sort'  => $sort,
									'order' => $order,
									'filter'=> $filter
								));
		$nolink = '<a href="' . $nolinkf . '">' . lang('no') . '</a>';
		$t->set_var('no',$nolink);
		$t->set_var('lang_no', lang('No'));

		$yeslinkf = $GLOBALS['phpgw']->link('/chora/deletesite.php', 
				array('site_id' => $site_id, 'confirm' => True));
		$yeslinkf = '<form method="POST" name="yesform" action="'.$phpgw->link('/chora/deletesite.php') . '">'
			. $hidden_vars
			. '<input type="hidden" name="site_id" value="' . $site_id. '">'
			. '<input type="hidden" name="confirm" value="True">'
			. '<input type="submit" name="yesbutton" value="'.lang('Yes').'">'
			. '</form><script>document.yesbutton.yesbutton.focus()</script>';

		$yeslink = '<a href="' . $yeslinkf .'">' . lang('yes') . '</a>';
		$yeslink = $yeslinkf;
		$t->set_var('yes',$yeslink);

		$t->pparse('out','site_delete');
	}

	$phpgw->common->phpgw_footer();
?>
