<?
    require_once('user.php');
	require_once('mysql.php');
	require_once('functions.php');
	
	// SETUP MYSQL HANDLERS
	$mysqldb1 = new mysql($host, $user, $pswd, $db); $mysqldb1->connect(); $mysqldb1->select();
	
	// NOTE: Fetches a list of files for tinymce
	// MOD: Modified to show all files in the tinymce link browser
    // $query = "SELECT * FROM file WHERE type='file' AND source='".$_GET['table']."' AND record_id=".$_GET['id'];
    $query = "SELECT * FROM file WHERE source='".$_GET['table']."' AND record_id=".$_GET['id'];
	if ($_GET['id'] == 0) {
		// $query = "SELECT * FROM file WHERE type='file' AND source='".$_GET['table']."'";
        $query = "SELECT * FROM file WHERE source='".$_GET['table']."'";
	}
	$mysqldb1->query($query);
	$file_list = 'var tinyMCELinkList = new Array(';
	while ($file = $mysqldb1->fetchArray()) {
		$file_name = $file['name'];
		//if ($file['description'] != '') {
			//$file_name = $file['description'];
		//}
		$file_list .= '["'.$file_name.'", "../../'.$fileDIR.$file['name'].'"],';
	}
	$file_list = rtrim($file_list, ',').');';
	print $file_list;
?>
<?
	$mysqldb1->close();
?>
    
        
      
