<?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
*/
	$success=true;
	
	$items=Db::instance()->selectCol("SELECT tree_id FROM ?_modules m LEFT JOIN ?_includes i ON m.module_id=i.module_id WHERE module IN ('lost_password', 'reg', 'profile')");
	
	if (count($items)) foreach($items as $item)
	{
		//если элементы дерева не имеют потомков
		if (!Db::instance()->selectCell("SELECT COUNT(tree_id) FROM ?_tree WHERE parent_id=?", $item))
		{
			//удаляем элемент
			Db::instance()->selectCell("DELETE FROM ?_tree WHERE tree_id=?", $item);
		}
	}
	
	Db::instance()->query("DELETE m, i FROM ?_modules m LEFT JOIN ?_includes i ON m.module_id=i.module_id WHERE module IN ('lost_password', 'reg', 'profile')");