<?php
/*
* @package LabCMS
* @copyright (c) 2006 Alexander Levin aka Loki (loki_angel@mail.ru)
* @support http://labcms.ru
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/

	User::checkToken();
	$key=intval($_GET['var1']);
	$del_arr=array($key);
	recurse_id($key);

	Db::i()->query("DELETE FROM ?_includes WHERE tree_id IN (?a)", $del_arr);
	Db::i()->query("DELETE FROM ?_tree WHERE tree_id IN (?a)", $del_arr);

	LabCMS::i()->reset_cache('objects');
	refresh();
	
	
	function recurse_id($id)
	{
		global $del_arr;
		$result=Db::i()->selectCol("SELECT tree_id FROM ?_tree WHERE parent_id=?", $id);
		foreach ($result as $tree_id)
		{
			$del_arr[]=$tree_id;
			recurse_id($tree_id);
		}
	}