Commit df8c8c2c authored by Jerome Mariette's avatar Jerome Mariette
Browse files

modify download + add download using symbolic links

parent 2555a1a5
<?php
/***************************************************************
* Copyright notice
*
* (c) 2009 PF bioinformatique de Toulouse <>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
// Inclusion des librairies nécessaires
require_once(PATH_t3lib.'class.t3lib_befunc.php');
require_once(PATH_t3lib.'stddb/tables.php');
require_once(t3lib_extMgm::extPath('cms','ext_tables.php'));
require_once(PATH_t3lib.'class.t3lib_db.php');
require_once(t3lib_extMgm::extPath('nG6').'/lib/class.tx_nG6_db.php');
require_once(t3lib_extMgm::extPath('nG6').'/lib/class.tx_nG6_utils.php');
require_once(t3lib_extMgm::extPath('nG6').'/lib/class.tx_nG6_process.php');
/**
* Class 'tx_nG6_eid' for the 'nG6' extension.
* This class is in charge of all communication between the client and the server using AJAX
*
* @author PF bioinformatique de Toulouse <>
*/
class tx_nG6_eid {
/* Méthode principale */
/**
* The main function of the tx_nG6_eid, this function is the one called when using ajax
*/
function main() {
/* connect to the databse */
// Connect to the databse
tslib_eidtools::connectDB();
$html = '';
$id = trim(t3lib_div::_GP('id'));
$type = trim(t3lib_div::_GP('type'));
$user_group = trim(t3lib_div::_GP('user_group'));
if ($type == 'project') {
// First all project runs
$p_runs = $this->get_project_runs($id);
foreach($p_runs as $run_id => $run_values) {
$html .= '<li class="jstree-closed" name=\''.str_replace(array('###SPAN_NAME###', '###SPAN_DATE###'), array($run_values["name"], strftime('%d-%m-%y',$run_values["date"])), trim(t3lib_div::_GP('short_run_printing'))).'\' id=\''.$run_id.'\'> <a href=\'#\'>'.str_replace(array('###SPAN_NAME###', '###SPAN_DATE###', '###SPAN_NB_SEQ###', '###SPAN_SPECIES###'), array($run_values["name"], strftime('%d-%m-%y',$run_values["date"]), $run_values["nb_sequences"], $run_values["species"]), trim(t3lib_div::_GP('run_printing'))).'</a></li>';
// If the type of data requested is project
if ($type == 'project') {
$project_id = trim(t3lib_div::_GP('id'));
// Select all runs linked to the project
$project_runs = tx_nG6_db::get_project_runs($user_group, $project_id);
// for each run
$html_tree = '';
foreach($project_runs as $run_id => $run_values) {
$html_tree .= '<li class="jstree-closed" name=\''.str_replace(array('###SPAN_NAME###', '###SPAN_DATE###'), array($run_values["name"], strftime('%d-%m-%y',$run_values["date"])), trim(t3lib_div::_GP('run_short_description'))).'\' id=\''.$run_id.'\'> <a href=\'#\'>'.str_replace(array('###SPAN_NAME###', '###SPAN_DATE###', '###SPAN_NB_SEQ###', '###SPAN_SPECIES###'), array($run_values["name"], strftime('%d-%m-%y',$run_values["date"]), $run_values["nb_sequences"], $run_values["species"]), trim(t3lib_div::_GP('run_description'))).'</a></li>';
}
// Then all project analysis
$p_analysis = $this->get_project_analysis($id);
foreach($p_analysis as $analyse_id => $analyse_values) {
$html .= '<li name=\''.str_replace(array('###SPAN_NAME###'), array($analyse_values["name"]), trim(t3lib_div::_GP('analyse_printing'))).'\' id=\''.$analyse_id.'\'> <a href=\'#\'>'.str_replace(array('###SPAN_NAME###'), array($analyse_values["name"]), trim(t3lib_div::_GP('analyse_printing'))).'</a></li>';
$project_analysis = tx_nG6_db::get_project_analysis($user_group, $project_id);
foreach($project_analysis as $analyse_id => $analyse_values) {
$html_tree .= '<li name=\''.str_replace(array('###SPAN_NAME###'), array($analyse_values["name"]), trim(t3lib_div::_GP('analyse_description'))).'\' id=\''.$analyse_id.'\'> <a href=\'#\'>'.str_replace(array('###SPAN_NAME###'), array($analyse_values["name"]), trim(t3lib_div::_GP('analyse_description'))).'</a></li>';
}
print $html;
// Return the html_tree
print $html_tree;
// If the type of data requested is run
} else if ($type == 'run'){
$r_analysis = $this->get_run_analysis($id);
$run_info = $this->get_run($id);
$html .= '<li name=\'run_'.$id.'_'.trim(t3lib_div::_GP("raw_data_label")).'\' id=\'data_'.$id.'\'> <a href=\'#\'>'.trim(t3lib_div::_GP("raw_data_label")).'</a></li>';
foreach($r_analysis as $analyse_id => $analyse_values) {
$html .= '<li name=\'run_'.$id.'_'.str_replace(array('###SPAN_NAME###'), array($analyse_values["name"]), trim(t3lib_div::_GP('analyse_printing'))).'\' id=\''.$analyse_id.'\'> <a href=\'#\'>'.str_replace(array('###SPAN_NAME###'), array($analyse_values["name"]), trim(t3lib_div::_GP('analyse_printing'))).'</a></li>';
$run_id = trim(t3lib_div::_GP('id'));
// Select all analysis linked to the run and the run information
$run_analysis = tx_nG6_db::get_run_analysis($user_group, $run_id);
$run_info = tx_nG6_db::get_run($run_id);
// for each analysis
$html_tree = '';
$html_tree .= '<li name=\'run_'.$run_id.'_'.trim(t3lib_div::_GP("raw_data_description")).'\' id=\'data_'.$run_id.'\'> <a href=\'#\'>'.trim(t3lib_div::_GP("raw_data_description")).'</a></li>';
foreach($run_analysis as $analyse_id => $analyse_values) {
$html_tree .= '<li name=\'run_'.$run_id.'_'.str_replace(array('###SPAN_NAME###'), array($analyse_values["name"]), trim(t3lib_div::_GP('analyse_description'))).'\' id=\''.$analyse_id.'\'> <a href=\'#\'>'.str_replace(array('###SPAN_NAME###'), array($analyse_values["name"]), trim(t3lib_div::_GP('analyse_description'))).'</a></li>';
}
print $html;
// Return the html_tree
print $html_tree;
// If downloading data is requested
} else if ($type == 'download') {
$ids = trim(t3lib_div::_GP('ids'));
$data_folder = trim(t3lib_div::_GP('data_folder'));
$tmp_folder = trim(t3lib_div::_GP('tmp_folder'));
print $this->get_download_file($ids, $data_folder, $tmp_folder);
} else if ($type == 'getFileSize') {
$ids = trim(t3lib_div::_GP('ids'));
$data_folder = trim(t3lib_div::_GP('data_folder'));
print $this->get_file_size($ids, $data_folder);
$format = trim(t3lib_div::_GP('format'));
// If link in home directory
if ($format == 'home_link') {
$ids = trim(t3lib_div::_GP('ids'));
$data_folder = trim(t3lib_div::_GP('data_folder'));
$user_login = trim(t3lib_div::_GP('user_login'));
$user_pwd = trim(t3lib_div::_GP('user_pwd'));
$user_directory = trim(t3lib_div::_GP('user_directory'));
$retcode = $this->create_symbolic_links($user_group, $user_login, $user_pwd, $ids, $data_folder, $user_directory);
print $retcode;
// If a .tar.gz file
} else {
$ids = trim(t3lib_div::_GP('ids'));
$data_folder = trim(t3lib_div::_GP('data_folder'));
$tmp_folder = trim(t3lib_div::_GP('tmp_folder'));
$user_email = trim(t3lib_div::_GP('user_email'));
$title_email = trim(t3lib_div::_GP('title_email'));
$msg_email = trim(t3lib_div::_GP('msg_email'));
$archive_info = $this->create_archive_script($user_group, $ids, $data_folder, $tmp_folder, "tar.gz", $user_email, $title_email, $msg_email);
$process = new Process("tcsh ".$archive_info[0]);
print "pid=".$process->getPid()."&archive_path=".$archive_info[1];
}
// If asked to check a job status
} else if($type == 'check_status') {
$pid = trim(t3lib_div::_GP('pid'));
$archive_path = trim(t3lib_div::_GP('archive_path'));
$process = new Process();
$process->setPid($pid);
// If the job is done
if ($process->status()) {
print "pid=0&archive_path=".$archive_path;
// If the job is still runing
} else {
print "pid=".$process->getPid()."&archive_path=".$archive_path;
}
// If file information is requested
} else if ($type == 'get_file_size') {
$ids = trim(t3lib_div::_GP('ids'));
$data_folder = trim(t3lib_div::_GP('data_folder'));
print $this->get_file_size($user_group, $ids, $data_folder);
}
}
/**
* Creates an archiving script to archive data from ids
*
* @param string $user_group the user group
* @param array $ids list of ids to download
* @param string $data_folder the data folder where are stored the data
* @param string $tmp_folder the output directory
* @param string $format the archiving format (tar.gz)
* @param string $user_email the user email
* @param string $title_email the email title to send
* @param string $msg_email the email message to send
* @return array (the path to the script, the url path to the final archive)
*/
private function create_archive_script($user_group, $ids, $data_folder, $tmp_folder, $format, $user_email, $title_email, $msg_email) {
// First get the archive name where will be stored the data
$random_key = tx_nG6_utils::create_random_key(10);
$archive_path = $tmp_folder."/ng6_".$random_key;
while( file_exists($archive_path) )
$archive_path = $tmp_folder."/ng6_".$random_key;
// Then get the directories structure
$directories = $this->get_directories_structure_and_content($user_group, $ids, $data_folder, $archive_path);
$archive_script_path = $tmp_folder."/ng6_".$random_key.".sh";
// And write down the script in charge to create the archive
$fp = fopen($archive_script_path, 'w');
foreach($directories[0] as $index => $src_directory) {
if (!file_exists( $directories[1][$index])) {
fwrite($fp, "mkdir -p ".$directories[1][$index]."\n");
}
// For each files in the source directory
foreach(scandir($src_directory) as $file) {
if (is_file($src_directory."/".$file) and $file != "analyse.xml" and $file != "index.html" and $file != "run.cfg") {
fwrite($fp, "cp ".$src_directory."/".$file." ".$directories[1][$index]."\n");
}
}
}
fwrite($fp, "cd ".$tmp_folder."\n");
fwrite($fp, "tar -czf ng6_".$random_key.".tar.gz ng6_".$random_key."\n");
fwrite($fp, "rm -rf ".$archive_path."\n");
fwrite($fp, 'echo "'.str_replace(array('SPAN_ARCHIVE_NAME'), array("ng6_".$random_key.".tar.gz"), $msg_email).'" | mail -s "'.$title_email.'" '.$user_email."\n");
fclose($fp);
return array($archive_script_path, "ng6_".$random_key.".tar.gz");
}
/**
* for each $id, get the total size of all files in the corresponding folder
* @param string $ids : names of run or analysis for which we want to get the sizes of the contained files
* @param string $data_folder : root directory where the folders of the runs and analysis can be found
* @return integer $fileSize : total size of the files
*/
function get_file_size($ids, $data_folder) {
$src_directories = Array();
$vals = preg_split("/;/", $ids);
$fileSize = 0;
foreach($vals as $val) {
if ($val != "undefined" && $val != "") {
$id = preg_split("/_/", $val);
if ($id[0] == "data") {
$run = $this->get_run($id[1]);
if (!in_array($data_folder.$run["directory"], $src_directories)) {
$src_directories[] = $data_folder.$run["directory"];
$fileSize += $this->getSize($data_folder.$run["directory"]);
}
} else if ($id[0] == "run") {
$run = $this->get_run($id[1]);
if (!in_array($data_folder.$run["directory"], $src_directories)) {
$src_directories[] = $data_folder.$run["directory"];
$fileSize += $this->getSize($data_folder.$run["directory"]);
}
foreach($this->get_run_analysis($id[1]) as $analyse_id => $analyse_values) {
if (!in_array($data_folder.$analyse_values["directory"], $src_directories)) {
$src_directories[] = $data_folder.$analyse_values["directory"];
$fileSize += $this->getSize($data_folder.$analyse_values["directory"]);
/**
* Creates symbolic links between ids from data_folder into user_directory
*
* @param string $user_group the user group
* @param string $user_login the user login to make ssh
* @param string $user_pwd the user pwd to make ssh
* @param array $ids list of ids to download
* @param string $data_folder the data folder where are stored the data
* @param string $user_directory the output directory
* @return 0=>everything ok, 1=>user rigth problem, 2=>wrong authentification, 3=>connection error
*/
private function create_symbolic_links($user_group, $user_login, $user_pwd, $ids, $data_folder, $user_directory) {
// First try to connect the specified user using ssh
$connection = ssh2_connect('127.0.0.1', 22);
if (!$connection) return 3;
if (!ssh2_auth_password($connection, $user_login, $user_pwd)) return 2;
// Then get the directories structure
$directories = $this->get_directories_structure_and_content($user_group, $ids, $data_folder, $user_directory);
// And process the directories structure
$creation = true;
foreach($directories[0] as $index => $src_directory) {
if (!file_exists("ssh2.sftp://".$connection.$directories[1][$index])) {
if (!mkdir("ssh2.sftp://".$connection.$directories[1][$index], 0755, true)) {
$creation = false;
break;
}
// For each files in the source directory
foreach(scandir("ssh2.sftp://".$connection.$src_directory) as $file) {
if (is_file("ssh2.sftp://".$connection.$src_directory."/".$file) and $file != "analyse.xml" and $file != "index.html" and $file != "run.cfg") {
if (!ssh2_exec($connection, 'ln -s '.$src_directory.'/'.$file.' '.$directories[1][$index].'/'.$file)) {
$creation = false;
break;
}
}
} else if ($id[0] == "analyse") {
$analyse = $this->get_analyse($id[1]);
if (!in_array($data_folder.$analyse["directory"], $src_directories)) {
$src_directories[] = $data_folder.$analyse["directory"];
$fileSize += $this->getSize($data_folder.$analyse["directory"]);
}
}
}
}
return $fileSize;
}
if (!$creation) return 1;
return 0;
}
/**
* for each $id, get the total size of all files in the corresponding folder
*
* @param string $user_group the user group
* @param string $ids names of run or analysis for which we want to get the sizes of the contained files
* @param string $data_folder root directory where the folders of the runs and analysis can be found
* @return integer total size of the files
*/
function get_file_size($user_group, $ids, $data_folder) {
// First get the directories structure
$directories = $this->get_directories_structure_and_content($user_group, $ids, $data_folder, "/");
$full_size = 0;
foreach($directories[0] as $index => $src_directory) {
// For each files in the source directory
foreach(scandir($src_directory) as $file) {
if (is_file($src_directory."/".$file) and $file != "analyse.xml" and $file != "index.html" and $file != "run.cfg") {
$full_size += filesize($src_directory."/".$file);
}
}
}
return $full_size;
}
/**
* get total size of files contained in $dir_src
* Returns a table with the right directories structure considering ids
*
* @param string $dir_src: name of a file or directory for wich we want the size
* @return integer total size of the files
* @param string $user_group the user group
* @param array $ids List of ids to download
* @param string $data_folder The data folder where are stored the data
* @param string $output_folder The output directory
* @return array [0] => source_directories, [1] => dest_directories
*/
function getSize($dir_src)
{
$filesSize = 0;
##Do an exhaustive list of files from the directories list
$iterator = new DirectoryIterator($dir_src);
foreach ($iterator as $fileinfo)
{
$filename = $fileinfo->getFilename() ;
$isNotRecursiveLink = ($filename!="." and $filename!="..") ;
$isNotCrap = ($isNotRecursiveLink and $filename!="index.html" and $filename!="run.cfg" );
if ($fileinfo->isDir() and $isNotCrap)
{ // get recursively subdirectories files
$dirpathname = $this->dirSlash($fileinfo->getPathname());
// then actualize the list of file to zip
$filesSize += $this->getSize( $dirpathname) ;
}
elseif ($fileinfo->isFile() and $isNotCrap)
{
$filesSize = $fileinfo->getSize();
//echo "Nom du fichier : " . $filename . "<br />";
//echo "taille du fichiers : $fileSize <br />";
//echo "taille des fichiers : $filesSize <br />";
}
}
private function get_directories_structure_and_content($user_group, $ids, $data_folder, $output_folder) {
return $filesSize;
}
function get_download_file($ids, $data_folder, $tmp_folder) {
$src_directories = Array();
$dest_directories = Array();
$src_directories = array();
$dest_directories = array();
$vals = preg_split("/;/", $ids);
$temporary_dir = $this->createRandomArchiveName($tmp_folder);
$charToBeSubstituted = array(' ','/'); //characters to be replaced in the names of the run, the analyses....
// Characters to be replaced in the names of the run, the analyses ...
$char_to_replace = array(' ','/');
// For each project/run/analysis
foreach($vals as $val) {
if ($val != "undefined" && $val != "") {
$id = preg_split("/_/", $val);
if ($id[0] == "data") {
$run = $this->get_run($id[1]);
$run = tx_nG6_db::get_run($id[1]);
if (!in_array($data_folder.$run["directory"], $src_directories)) {
$src_directories[] = $data_folder.$run["directory"];
$dest_directories[] = $temporary_dir."/Project_".str_replace($charToBeSubstituted, '_', $run["project_name"]).'.'.$run["project_id"]."/Run_".str_replace($charToBeSubstituted, '_', $run["name"]).".".$id[1]."/RawData";
$ddest = $output_folder."/Project_".str_replace($char_to_replace, '_', $run["project_name"]);
$ddest .= '.'.$run["project_id"]."/Run_".str_replace($char_to_replace, '_', $run["name"]).".".$id[1]."/RawData";
$dest_directories[] = $ddest;
}
} else if ($id[0] == "run") {
$run = $this->get_run($id[1]);
$run = tx_nG6_db::get_run($id[1]);
if (!in_array($data_folder.$run["directory"], $src_directories)) {
$src_directories[] = $data_folder.$run["directory"];
$dest_directories[] = $temporary_dir."/Project_".str_replace($charToBeSubstituted, '_', $run["project_name"]).'.'.$run["project_id"]."/Run_".str_replace($charToBeSubstituted, '_', $run["name"]).".".$id[1]."/RawData";
$ddest = $output_folder."/Project_".str_replace($char_to_replace, '_', $run["project_name"]);
$ddest .= '.'.$run["project_id"]."/Run_".str_replace($char_to_replace, '_', $run["name"]).".".$id[1]."/RawData";
$dest_directories[] = $ddest;
}
foreach($this->get_run_analysis($id[1]) as $analyse_id => $analyse_values) {
foreach(tx_nG6_db::get_run_analysis($user_group, $id[1]) as $analyse_id => $analyse_values) {
$aid = preg_split("/_/", $analyse_id);
if (!in_array($data_folder.$analyse_values["directory"], $src_directories)) {
$src_directories[] = $data_folder.$analyse_values["directory"];
$aid = preg_split("/_/", $analyse_id);
$dest_directories[] = $temporary_dir."/Project_".str_replace($charToBeSubstituted, '_', $run["project_name"]).'.'.$run["project_id"]."/Run_".str_replace($charToBeSubstituted, '_', $run["name"]).".".$id[1]."/Analyse_".str_replace($charToBeSubstituted, '_', $analyse_values["name"]).".".$aid;
$ddest = $output_folder."/Project_".str_replace($char_to_replace, '_', $run["project_name"]);
$ddest .= '.'.$run["project_id"]."/Run_".str_replace($char_to_replace, '_', $run["name"]);
$ddest .= ".".$id[1]."/Analyse_".str_replace($char_to_replace, '_', $analyse_values["name"]).".".$aid[1];
$dest_directories[] = $ddest;
}
}
} else if ($id[0] == "analyse") {
$analyse = $this->get_analyse($id[1]);
$analyse = tx_nG6_db::get_analyse($id[1]);
if (!in_array($data_folder.$analyse["directory"], $src_directories)) {
$src_directories[] = $data_folder.$analyse["directory"];
// If it's a project analyse
if ($analyse["run_id"] == 'None') {
$dest_directories[] = $temporary_dir."/Project_".str_replace($charToBeSubstituted, '_', $analyse["project_name"]).".".$analyse["project_id"]."/Project_analyses/".str_replace($charToBeSubstituted, '_', $analyse["name"]).".".$id[1];
$ddest = $output_folder."/Project_".str_replace($char_to_replace, '_', $analyse["project_name"]);
$ddest .= ".".$analyse["project_id"]."/Project_analyses/".str_replace($char_to_replace, '_', $analyse["name"]).".".$id[1];
$dest_directories[] = $ddest;
} else {
$dest_directories[] = $temporary_dir."/Project_".str_replace($charToBeSubstituted, '_', $analyse["project_name"]).".".$analyse["project_id"]."/Run_".str_replace($charToBeSubstituted, '_', $analyse["run_name"]).".".$analyse["run_id"]."/Analyse_".str_replace($charToBeSubstituted, '_', $analyse["name"]).".".$id[1];
$ddest = $output_folder."/Project_".str_replace($char_to_replace, '_', $analyse["project_name"]);
$ddest .= ".".$analyse["project_id"]."/Run_".str_replace($char_to_replace, '_', $analyse["run_name"]);
$ddest .= ".".$analyse["run_id"]."/Analyse_".str_replace($char_to_replace, '_', $analyse["name"]).".".$id[1];
$dest_directories[] = $ddest;
}
}
}
}
}
return $this->archiveZip($src_directories, $dest_directories, $temporary_dir, 'tar.gz');
}
function get_run_analysis($run_id) {
$results = array();
$queryParts = array(
'SELECT' => 'tx_nG6_analyze.uid AS analyze_id,'.
'tx_nG6_analyze.directory AS analyze_directory,'.
'tx_nG6_analyze.name AS analyze_name, '.
'tx_nG6_analyze.date AS analyze_date, '.
'tx_nG6_analyze.description AS analyze_description',
'FROM' => 'tx_nG6_run_analyze JOIN tx_nG6_analyze ON '.
'tx_nG6_analyze.uid=tx_nG6_run_analyze.analyze_id',
'WHERE' => 'tx_nG6_run_analyze.run_id='.$run_id,
'GROUPBY' => '',
'ORDERBY' => 'tx_nG6_analyze.name',
'LIMIT' => ''
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))
{
$analyze_id = $row['analyze_id'];
if (! isset ($results['analyse_'.$analyze_id]) )
{
$results['analyse_'.$analyze_id] = array(
'directory' => $row['analyze_directory'],
'name' => $row['analyze_name'],
'date' => $row['analyze_date'],
'description' => $row['analyse_description']
);
}
}
return $results;
return array($src_directories, $dest_directories);
}
function get_project_analysis($project_id) {
$results = array();
$queryParts = array(
'SELECT' => 'tx_nG6_analyze.uid AS analyze_id,'.
'tx_nG6_analyze.directory AS analyze_directory,'.
'tx_nG6_analyze.name AS analyze_name, '.
'tx_nG6_analyze.date AS analyze_date, '.
'tx_nG6_analyze.description AS analyze_description',
'FROM' => 'tx_nG6_project_analyze JOIN tx_nG6_analyze ON '.
'tx_nG6_analyze.uid=tx_nG6_project_analyze.analyze_id',
'WHERE' => 'tx_nG6_project_analyze.project_id='.$project_id,
'GROUPBY' => '',
'ORDERBY' => 'tx_nG6_analyze.name',
'LIMIT' => ''
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))
{
$analyze_id = $row['analyze_id'];
if (! isset ($results['analyse_'.$analyze_id]) )
{
$results['analyse_'.$analyze_id] = array(
'directory' => $row['analyze_directory'],
'name' => $row['analyze_name'],
'date' => $row['analyze_date'],
'description' => $row['analyse_description']
);
}
}
return $results;
}
function get_run($run_id) {
$result = array();
$queryParts = Array(
'SELECT' => 'tx_nG6_project.uid AS project_id,'.
'tx_nG6_project.name AS project_name,'.
'tx_nG6_run.uid AS run_id,'.
'tx_nG6_run.directory AS run_directory,'.
'tx_nG6_run.description AS run_description, '.
'tx_nG6_run.name AS run_name, '.
'tx_nG6_run.nb_sequences, '.
'tx_nG6_run.date AS run_date',
'FROM' => 'tx_nG6_project INNER JOIN ( tx_nG6_project_run INNER JOIN tx_nG6_run ON tx_nG6_project_run.run_id=tx_nG6_run.uid '.
' ) ON tx_nG6_project.uid=tx_nG6_project_run.project_id',
'WHERE' => 'tx_nG6_run.uid='.$run_id,
'GROUPBY' => '',
'ORDERBY' => 'tx_nG6_run.date DESC',
'LIMIT' => ''
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))
{
$run_id = $row['run_id'];
if (! isset ($results['run_'.$run_id]) )
{
$result = array(
'project_id' => $row['project_id'],
'project_name' => $row['project_name'],
'directory' => $row['run_directory'],
'name' => $row['run_name'],
'nb_sequences' => $row['nb_sequences'],
'date' => $row['run_date'],
'description' => $row['run_description']
);
}
}
return $result;
}
function get_analyse($analyse_id) {
$queryParts = array(
'SELECT' => 'tx_nG6_project.uid AS project_id,'.
'tx_nG6_project.name AS project_name,'.
'tx_nG6_analyze.uid AS analyze_id,'.
'tx_nG6_analyze.directory AS analyze_directory,'.
'tx_nG6_analyze.name AS analyze_name, '.
'tx_nG6_analyze.date AS analyze_date, '.
'tx_nG6_analyze.description AS analyze_description ',
'FROM' => 'tx_nG6_project INNER JOIN (tx_nG6_project_analyze INNER JOIN tx_nG6_analyze ON ' .
'tx_nG6_analyze.uid=tx_nG6_project_analyze.analyze_id) ON tx_nG6_project.uid = tx_nG6_project_analyze.project_id ',
'WHERE' => 'tx_nG6_analyze.uid='.$analyse_id,
'GROUPBY' => '',
'ORDERBY' => '',
'LIMIT' => ''
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
// If it's a project analyse
if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) {
$result = array();
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))
{
$result = array(
'project_name' => $row['project_name'],
'project_id' => $row['project_id'],
'run_name' => 'None',
'run_id' => 'None',
'directory' => $row['analyze_directory'],
'name' => $row['analyze_name'],
'date' => $row['analyze_date'],
'description' => $row['analyze_description']
);
}
return $result;
} else {
$queryParts = array(
'SELECT' => 'tx_nG6_project.name AS project_name,'.
'tx_nG6_project.uid AS project_id,'.
'tx_nG6_run.uid AS run_id,'.
'tx_nG6_run.name AS run_name,'.
'tx_nG6_analyze.uid AS analyze_id,'.
'tx_nG6_analyze.directory AS analyze_directory,'.
'tx_nG6_analyze.name AS analyze_name, '.
'tx_nG6_analyze.date AS analyze_date, '.
'tx_nG6_analyze.description AS analyze_description',