<?php
	
// TreeGrid repository
if ( $_POST['action'] == 'remove'  )
{
	include_once("_dirinfo.php");
	include_once(PATH_TO_ROOT."init.php");
	$userId = $_SESSION['UserInfo']['id'];
	$tabId = $_POST['sessId'];
	unset($_SESSION['addedTabs'][ $tabId  ]  );
	$sql = "DELETE FROM ".DB_WARPIT_MAIN."._user_tab_state WHERE user_id = $userId AND tab_id = '$tabId'";
	$db->SQLexecute($sql);
	echo $db->GetError();
	//$_SESSION['addedTabs'][ $_POST['sessId'] ] = 0 ;
	exit;
}


	// javascript files
	$_repository['treeGrid']['js'][] = "extjs/examples/ux/treegrid/TreeGridSorter.js";
	$_repository['treeGrid']['js'][] = "extjs/examples/ux/treegrid/TreeGridColumnResizer.js";
	$_repository['treeGrid']['js'][] = "extjs/examples/ux/treegrid/TreeGridNodeUI.js";
	$_repository['treeGrid']['js'][] = "extjs/examples/ux/treegrid/TreeGridLoader.js";
	$_repository['treeGrid']['js'][] = "extjs/examples/ux/treegrid/TreeGridColumns.js";
	$_repository['treeGrid']['js'][] = "extjs/examples/ux/treegrid/TreeGrid.js";
	
	// CSS styles
	$_repository['treeGrid']['css'][] = "extjs/examples/ux/treegrid/treegrid.css";


// FileUpload repository

	// javascript files
	$_repository['fileUpload']['js'][] = "_plugins/Ext.ux.FileUploadField.js";


function loadPlugin($repository,$ar) {
	
	// I check if plugin allready exists in my session
	if ($_SESSION['loadedPlugin'][$ar]) return 0;
	
	// I load information about installed plugi	
	$_SESSION['loadedPlugin'][$ar] = 1;
	
	foreach ($repository[$ar] as $type=>$arrayFiles) {
		if ($type == 'js') 
		{
			foreach ($arrayFiles as $file) echo implode("\n\r",file(PATH_TO_ROOT.$file));
		} 
		elseif ($type == 'css') 
		{
			foreach ($arrayFiles as $file) echo " setClassCss('".$file."');";		
		}
	}

}

?>