<?php
include_once ("_dirinfo.php");

include_once (PATH_TO_ROOT."init.php");
include_once (PATH_TO_ROOT."_ajaxManipulators/_class/class.treeData.php");


$db->ChangeDatabase($_POST['database']);

$tableName = $_POST['RMtable'];

//SAFETY FUNCTION...reorders the tree, and removes any holes in positions
/*$db->SQLexecute("SET @cnt:=0");
$db->SQLexecute("SET @prev:=-1");
		if(!$db->SQLexecute("UPDATE {$tableName} SET orderBy = IF( @prev = (SELECT @prev := id_sup ) 
						,(SELECT @cnt := @cnt+1),(SELECT @cnt := 1)) 
						ORDER BY id_sup,orderBy"))
		{
			Echo '{success:false,error:"'.$db->GetError().',aaa:aaa"}';
			return;			
		}*/


$manipulator = new TreeDataManipulator($db,$tableName);
$comm = $_POST['action'].'Action';
if(method_exists($manipulator,$comm))
	echo $manipulator->$comm();
else 
{
	
	Echo '{success:false,error:"Unknown action!"}';	
	
}
?>