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

code cleaning

parent 7f7aa4dd
...@@ -52,26 +52,26 @@ class tx_nG6_eid { ...@@ -52,26 +52,26 @@ class tx_nG6_eid {
if ($type == 'project') { if ($type == 'project') {
$project_id = trim(t3lib_div::_GP('id')); $project_id = trim(t3lib_div::_GP('id'));
// Select all runs linked to the project // Select all runs linked to the project
$project_runs = tx_nG6_db::get_project_runs($user_group, $project_id); $project_runs = tx_nG6_db::get_project_runs($user_group, $project_id, 'tx_nG6_run.date DESC');
// for each run // for each run
$html_tree = ''; $html_tree = '';
foreach($project_runs as $run_id => $run_values) { 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>'; $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 // Then all project analysis
$project_analysis = tx_nG6_db::get_project_analysis($user_group, $project_id); $project_analysis = tx_nG6_db::get_project_analysis($user_group, $project_id, 'tx_nG6_analyze.name');
foreach($project_analysis as $analyse_id => $analyse_values) { 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>'; $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>';
} }
// Return the html_tree // Return the html_tree
print $html_tree; print $html_tree;
// If the type of data requested is run // If the type of data requested is run
} else if ($type == 'run'){ } else if ($type == 'run'){
$run_id = trim(t3lib_div::_GP('id')); $run_id = trim(t3lib_div::_GP('id'));
// Select all analysis linked to the run and the run information // Select all analysis linked to the run and the run information
$run_analysis = tx_nG6_db::get_run_analysis($user_group, $run_id); $run_analysis = tx_nG6_db::get_run_analysis($user_group, $run_id, 'tx_nG6_analyze.name');
$run_info = tx_nG6_db::get_run($run_id); $run_info = tx_nG6_db::select_run($run_id);
// for each analysis // for each analysis
$html_tree = ''; $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>'; $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>';
...@@ -79,7 +79,7 @@ class tx_nG6_eid { ...@@ -79,7 +79,7 @@ class tx_nG6_eid {
$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>'; $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>';
} }
// Return the html_tree // Return the html_tree
print $html_tree; print $html_tree;
// If downloading data is requested // If downloading data is requested
} else if ($type == 'download') { } else if ($type == 'download') {
...@@ -263,7 +263,7 @@ class tx_nG6_eid { ...@@ -263,7 +263,7 @@ class tx_nG6_eid {
if ($val != "undefined" && $val != "") { if ($val != "undefined" && $val != "") {
$id = preg_split("/_/", $val); $id = preg_split("/_/", $val);
if ($id[0] == "data") { if ($id[0] == "data") {
$run = tx_nG6_db::get_run($id[1]); $run = tx_nG6_db::select_run($id[1]);
if (!in_array($data_folder.$run["directory"], $src_directories)) { if (!in_array($data_folder.$run["directory"], $src_directories)) {
$src_directories[] = $data_folder.$run["directory"]; $src_directories[] = $data_folder.$run["directory"];
$ddest = $output_folder."/Project_".str_replace($char_to_replace, '_', $run["project_name"]); $ddest = $output_folder."/Project_".str_replace($char_to_replace, '_', $run["project_name"]);
...@@ -271,14 +271,14 @@ class tx_nG6_eid { ...@@ -271,14 +271,14 @@ class tx_nG6_eid {
$dest_directories[] = $ddest; $dest_directories[] = $ddest;
} }
} else if ($id[0] == "run") { } else if ($id[0] == "run") {
$run = tx_nG6_db::get_run($id[1]); $run = tx_nG6_db::select_run($id[1]);
if (!in_array($data_folder.$run["directory"], $src_directories)) { if (!in_array($data_folder.$run["directory"], $src_directories)) {
$src_directories[] = $data_folder.$run["directory"]; $src_directories[] = $data_folder.$run["directory"];
$ddest = $output_folder."/Project_".str_replace($char_to_replace, '_', $run["project_name"]); $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"; $ddest .= '.'.$run["project_id"]."/Run_".str_replace($char_to_replace, '_', $run["name"]).".".$id[1]."/RawData";
$dest_directories[] = $ddest; $dest_directories[] = $ddest;
} }
foreach(tx_nG6_db::get_run_analysis($user_group, $id[1]) as $analyse_id => $analyse_values) { foreach(tx_nG6_db::get_run_analysis($user_group, $id[1], 'tx_nG6_analyze.name') as $analyse_id => $analyse_values) {
$aid = preg_split("/_/", $analyse_id); $aid = preg_split("/_/", $analyse_id);
if (!in_array($data_folder.$analyse_values["directory"], $src_directories)) { if (!in_array($data_folder.$analyse_values["directory"], $src_directories)) {
$src_directories[] = $data_folder.$analyse_values["directory"]; $src_directories[] = $data_folder.$analyse_values["directory"];
...@@ -289,7 +289,7 @@ class tx_nG6_eid { ...@@ -289,7 +289,7 @@ class tx_nG6_eid {
} }
} }
} else if ($id[0] == "analyse") { } else if ($id[0] == "analyse") {
$analyse = tx_nG6_db::get_analyse($id[1]); $analyse = tx_nG6_db::select_analyse($id[1]);
if (!in_array($data_folder.$analyse["directory"], $src_directories)) { if (!in_array($data_folder.$analyse["directory"], $src_directories)) {
$src_directories[] = $data_folder.$analyse["directory"]; $src_directories[] = $data_folder.$analyse["directory"];
// If it's a project analyse // If it's a project analyse
......
...@@ -42,7 +42,7 @@ class tx_nG6_db { ...@@ -42,7 +42,7 @@ class tx_nG6_db {
* @param string $user_group the user group * @param string $user_group the user group
* @return table with all projects * @return table with all projects
*/ */
function select_all_user_projects($user_group) { function select_all_user_projects($user_group, $orderby='', $limit='') {
$projects = array(); $projects = array();
// If the user is not logged on display demonstration project // If the user is not logged on display demonstration project
...@@ -61,8 +61,8 @@ class tx_nG6_db { ...@@ -61,8 +61,8 @@ class tx_nG6_db {
'FROM' => 'tx_nG6_project', 'FROM' => 'tx_nG6_project',
'WHERE' => $where, 'WHERE' => $where,
'GROUPBY' => '', 'GROUPBY' => '',
'ORDERBY' => '', 'ORDERBY' => $orderby,
'LIMIT' => '' 'LIMIT' => $limit
); );
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts); $res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
$user_groups = t3lib_div::intExplode(',',tx_nG6_db::get_user_groups($user_group)); $user_groups = t3lib_div::intExplode(',',tx_nG6_db::get_user_groups($user_group));
...@@ -85,6 +85,7 @@ class tx_nG6_db { ...@@ -85,6 +85,7 @@ class tx_nG6_db {
$projects['project_'.$project_id] = array( $projects['project_'.$project_id] = array(
'id' => $project_id, 'id' => $project_id,
'name' => $row['project_name'], 'name' => $row['project_name'],
'hidden' => $row['project_hidden'],
'description' => $row['project_description']); 'description' => $row['project_description']);
} }
...@@ -118,24 +119,30 @@ class tx_nG6_db { ...@@ -118,24 +119,30 @@ class tx_nG6_db {
* @param string $project_id the project id * @param string $project_id the project id
* @return hash table with all runs information * @return hash table with all runs information
*/ */
function get_project_runs($user_group, $project_id) { function get_project_runs($user_group, $project_id, $orderby='', $limit='') {
// First select all runs from the database // First select all runs from the database
$queryParts = Array( $queryParts = Array(
'SELECT' => 'tx_nG6_run.uid AS run_id,'. 'SELECT' => 'tx_nG6_run.uid AS run_id,'.
'tx_nG6_run.directory AS run_directory,'. 'tx_nG6_run.directory AS run_directory,'.
'tx_nG6_run.species AS run_species,'. 'tx_nG6_run.species AS run_species,'.
'tx_nG6_run.description AS run_description, '. 'tx_nG6_run.description AS run_description, '.
'tx_nG6_run.data_nature AS run_data_nature, '.
'tx_nG6_run.sequencer AS run_sequencer, '.
'tx_nG6_run.type AS run_type, '.
'tx_nG6_run.name AS run_name, '. 'tx_nG6_run.name AS run_name, '.
'tx_nG6_run.nb_sequences, '. 'tx_nG6_project.uid AS project_id, '.
'tx_nG6_run.nb_sequences AS run_nb_sequences, '.
'tx_nG6_run.full_seq_size AS run_full_seq_size, '.
'tx_nG6_run.date AS run_date, '. 'tx_nG6_run.date AS run_date, '.
'tx_nG6_run.hidden AS run_hidden, '. 'tx_nG6_run.hidden AS run_hidden, '.
'tx_nG6_project.name AS project_name, '.
'tx_nG6_project.fe_group AS project_fe_group', 'tx_nG6_project.fe_group AS project_fe_group',
'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 '. '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', ' ) ON tx_nG6_project.uid=tx_nG6_project_run.project_id',
'WHERE' => 'tx_nG6_project.uid='.$project_id, 'WHERE' => 'tx_nG6_project.uid='.$project_id,
'GROUPBY' => '', 'GROUPBY' => '',
'ORDERBY' => 'tx_nG6_run.date DESC', 'ORDERBY' => $orderby,
'LIMIT' => '' 'LIMIT' => $limit
); );
// Then create the result hash table // Then create the result hash table
$results = array(); $results = array();
...@@ -158,11 +165,20 @@ class tx_nG6_db { ...@@ -158,11 +165,20 @@ class tx_nG6_db {
if (!isset($results['run_'.$run_id]) and $user_allowed) { if (!isset($results['run_'.$run_id]) and $user_allowed) {
$results['run_'.$run_id] = array( $results['run_'.$run_id] = array(
'id' => $run_id,
'directory' => $row['run_directory'], 'directory' => $row['run_directory'],
'name' => $row['run_name'], 'name' => $row['run_name'],
'project_name' => $row['project_name'],
'fe_group' => $row['project_fe_group'],
'hidden' => $row['run_hidden'],
'species' => $row['run_species'], 'species' => $row['run_species'],
'nb_sequences' => $row['nb_sequences'], 'nb_sequences' => $row['run_nb_sequences'],
'full_seq_size' => $row['run_full_seq_size'],
'project_id' => $row['project_id'],
'date' => $row['run_date'], 'date' => $row['run_date'],
'data_nature' => $row['run_data_nature'],
'sequencer' => $row['run_sequencer'],
'type' => $row['run_type'],
'description' => $row['run_description'] 'description' => $row['run_description']
); );
} }
...@@ -177,13 +193,15 @@ class tx_nG6_db { ...@@ -177,13 +193,15 @@ class tx_nG6_db {
* @param string $project_id the project id * @param string $project_id the project id
* @return hash table with all analysis information * @return hash table with all analysis information
*/ */
function get_project_analysis($user_group, $project_id) { function get_project_analysis($user_group, $project_id, $orderby, $limit) {
// First select all analysis from the database // First select all analysis from the database
$queryParts = array( $queryParts = array(
'SELECT' => 'tx_nG6_analyze.uid AS analyze_id,'. 'SELECT' => 'tx_nG6_analyze.uid AS analyze_id,'.
'tx_nG6_analyze.directory AS analyze_directory,'. 'tx_nG6_analyze.directory AS analyze_directory,'.
'tx_nG6_analyze.name AS analyze_name, '. 'tx_nG6_analyze.name AS analyze_name, '.
'tx_nG6_analyze.date AS analyze_date, '. 'tx_nG6_analyze.date AS analyze_date, '.
'tx_nG6_analyze.software AS analyze_software, '.
'tx_nG6_analyze.version AS analyze_version, '.
'tx_nG6_analyze.description AS analyze_description, '. 'tx_nG6_analyze.description AS analyze_description, '.
'tx_nG6_analyze.hidden AS analyze_hidden, '. 'tx_nG6_analyze.hidden AS analyze_hidden, '.
'tx_nG6_project.fe_group AS project_fe_group', 'tx_nG6_project.fe_group AS project_fe_group',
...@@ -191,8 +209,8 @@ class tx_nG6_db { ...@@ -191,8 +209,8 @@ class tx_nG6_db {
'tx_nG6_analyze.uid=tx_nG6_project_analyze.analyze_id) ON tx_nG6_project.uid = tx_nG6_project_analyze.project_id ', 'tx_nG6_analyze.uid=tx_nG6_project_analyze.analyze_id) ON tx_nG6_project.uid = tx_nG6_project_analyze.project_id ',
'WHERE' => 'tx_nG6_project_analyze.project_id='.$project_id, 'WHERE' => 'tx_nG6_project_analyze.project_id='.$project_id,
'GROUPBY' => '', 'GROUPBY' => '',
'ORDERBY' => 'tx_nG6_analyze.name', 'ORDERBY' => $orderby,
'LIMIT' => '' 'LIMIT' => $limit
); );
// Then create the result hash table // Then create the result hash table
$results = array(); $results = array();
...@@ -217,8 +235,12 @@ class tx_nG6_db { ...@@ -217,8 +235,12 @@ class tx_nG6_db {
$results['analyse_'.$analyze_id] = array( $results['analyse_'.$analyze_id] = array(
'directory' => $row['analyze_directory'], 'directory' => $row['analyze_directory'],
'name' => $row['analyze_name'], 'name' => $row['analyze_name'],
'id' => $row['analyze_id'],
'hidden' => $row['analyze_hidden'],
'software' => $row['analyze_software'],
'version' => $row['analyze_version'],
'date' => $row['analyze_date'], 'date' => $row['analyze_date'],
'description' => $row['analyse_description'] 'description' => $row['analyze_description']
); );
} }
} }
...@@ -230,13 +252,94 @@ class tx_nG6_db { ...@@ -230,13 +252,94 @@ class tx_nG6_db {
* Run functions * Run functions
*------------------------------------------------------------*/ *------------------------------------------------------------*/
/**
* Select all run for the specified user
*
* @param string $user_group the user group
* @return table with all projects
*/
function select_all_user_runs($user_group, $orderby='', $limit='') {
// If the user is not logged on display demonstration project
if (!$GLOBALS['TSFE']->loginUser) {
$where = 'fe_group=0';
} else {
$where = 'fe_group IN ('.tx_nG6_db::get_user_groups($user_group).')';
}
// Execute the request
$queryParts = Array(
'SELECT' => 'tx_nG6_run.uid AS run_id,'.
'tx_nG6_run.directory AS run_directory,'.
'tx_nG6_run.species AS run_species,'.
'tx_nG6_run.description AS run_description, '.
'tx_nG6_run.data_nature AS run_data_nature, '.
'tx_nG6_run.sequencer AS run_sequencer, '.
'tx_nG6_run.type AS run_type, '.
'tx_nG6_run.name AS run_name, '.
'tx_nG6_run.nb_sequences AS run_nb_sequences, '.
'tx_nG6_run.full_seq_size AS run_full_seq_size, '.
'tx_nG6_run.date AS run_date, '.
'tx_nG6_run.hidden AS run_hidden, '.
'tx_nG6_project.uid AS project_id, '.
'tx_nG6_project.name AS project_name, '.
'tx_nG6_project.fe_group AS project_fe_group',
'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' => $where,
'GROUPBY' => '',
'ORDERBY' => $orderby,
'LIMIT' => $limit
);
// Then create the result hash table
$results = array();
$user_groups = t3lib_div::intExplode(',',tx_nG6_db::get_user_groups($user_group));
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$run_id = $row['run_id'];
// Is the user allowed to see this run
$user_allowed = false;
if ($row['run_hidden'] == 0) {
$user_allowed = true;
} else {
foreach(tx_nG6_db::get_super_groups_of($row['project_fe_group']) AS $valeur) {
if (in_array($valeur, $user_groups)) {
$user_allowed = true;
}
}
}
if (!isset($results['run_'.$run_id]) and $user_allowed) {
$results['run_'.$run_id] = array(
'id' => $run_id,
'directory' => $row['run_directory'],
'name' => $row['run_name'],
'project_name' => $row['project_name'],
'fe_group' => $row['project_fe_group'],
'project_id' => $row['project_id'],
'hidden' => $row['run_hidden'],
'species' => $row['run_species'],
'nb_sequences' => $row['run_nb_sequences'],
'full_seq_size' => $row['run_full_seq_size'],
'date' => $row['run_date'],
'data_nature' => $row['run_data_nature'],
'sequencer' => $row['run_sequencer'],
'type' => $row['run_type'],
'description' => $row['run_description']
);
}
}
return $results;
}
/** /**
* Select all information for the specified run * Select all information for the specified run
* *
* @param string $run_id the run id * @param string $run_id the run id
* @return hash table with all the run information * @return hash table with all the run information
*/ */
function get_run($run_id) { function select_run($run_id) {
// First select the run from the database // First select the run from the database
...@@ -246,7 +349,12 @@ class tx_nG6_db { ...@@ -246,7 +349,12 @@ class tx_nG6_db {
'tx_nG6_run.uid AS run_id,'. 'tx_nG6_run.uid AS run_id,'.
'tx_nG6_run.directory AS run_directory,'. 'tx_nG6_run.directory AS run_directory,'.
'tx_nG6_run.description AS run_description, '. 'tx_nG6_run.description AS run_description, '.
'tx_nG6_run.species AS run_species, '.
'tx_nG6_run.name AS run_name, '. 'tx_nG6_run.name AS run_name, '.
'tx_nG6_run.data_nature AS run_data_nature, '.
'tx_nG6_run.sequencer AS run_sequencer, '.
'tx_nG6_run.type AS run_type, '.
'tx_nG6_run.full_seq_size, '.
'tx_nG6_run.nb_sequences, '. 'tx_nG6_run.nb_sequences, '.
'tx_nG6_run.date AS run_date', '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 '. '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 '.
...@@ -259,19 +367,21 @@ class tx_nG6_db { ...@@ -259,19 +367,21 @@ class tx_nG6_db {
// Then create the result hash table // Then create the result hash table
$result = array(); $result = array();
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts); $res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$run_id = $row['run_id']; $result = array(
if (!isset ($results['run_'.$run_id])) { 'project_id' => $row['project_id'],
$result = array( 'project_name' => $row['project_name'],
'project_id' => $row['project_id'], 'directory' => $row['run_directory'],
'project_name' => $row['project_name'], 'name' => $row['run_name'],
'directory' => $row['run_directory'], 'type' => $row['run_type'],
'name' => $row['run_name'], 'sequencer' => $row['run_sequencer'],
'nb_sequences' => $row['nb_sequences'], 'data_nature' => $row['run_data_nature'],
'date' => $row['run_date'], 'full_seq_size' => $row['full_seq_size'],
'description' => $row['run_description'] 'species' => $row['run_species'],
); 'nb_sequences' => $row['nb_sequences'],
} 'date' => $row['run_date'],
'description' => $row['run_description']
);
} }
return $result; return $result;
} }
...@@ -283,13 +393,15 @@ class tx_nG6_db { ...@@ -283,13 +393,15 @@ class tx_nG6_db {
* @param string $run_id the run id * @param string $run_id the run id
* @return hash table with all analysis information * @return hash table with all analysis information
*/ */
function get_run_analysis($user_group, $run_id) { function get_run_analysis($user_group, $run_id, $orderby='', $limit='') {
// First select all analysis from the database // First select all analysis from the database
$queryParts = array( $queryParts = array(
'SELECT' => 'tx_nG6_analyze.uid AS analyze_id,'. 'SELECT' => 'tx_nG6_analyze.uid AS analyze_id,'.
'tx_nG6_analyze.directory AS analyze_directory,'. 'tx_nG6_analyze.directory AS analyze_directory,'.
'tx_nG6_analyze.name AS analyze_name, '. 'tx_nG6_analyze.name AS analyze_name, '.
'tx_nG6_analyze.date AS analyze_date, '. 'tx_nG6_analyze.date AS analyze_date, '.
'tx_nG6_analyze.software AS analyze_software, '.
'tx_nG6_analyze.version AS analyze_version, '.
'tx_nG6_analyze.hidden AS analyze_hidden, '. 'tx_nG6_analyze.hidden AS analyze_hidden, '.
'tx_nG6_analyze.description AS analyze_description, '. 'tx_nG6_analyze.description AS analyze_description, '.
'tx_nG6_project.fe_group AS project_fe_group', 'tx_nG6_project.fe_group AS project_fe_group',
...@@ -298,8 +410,8 @@ class tx_nG6_db { ...@@ -298,8 +410,8 @@ class tx_nG6_db {
') ON tx_nG6_run.uid = tx_nG6_project_run.run_id) ON tx_nG6_project_run.project_id = tx_nG6_project.uid ', ') ON tx_nG6_run.uid = tx_nG6_project_run.run_id) ON tx_nG6_project_run.project_id = tx_nG6_project.uid ',
'WHERE' => 'tx_nG6_run_analyze.run_id='.$run_id, 'WHERE' => 'tx_nG6_run_analyze.run_id='.$run_id,
'GROUPBY' => '', 'GROUPBY' => '',
'ORDERBY' => 'tx_nG6_analyze.name', 'ORDERBY' => $orderby,
'LIMIT' => '' 'LIMIT' => $limit
); );
// Then create the result hash table // Then create the result hash table
$results = array(); $results = array();
...@@ -322,10 +434,14 @@ class tx_nG6_db { ...@@ -322,10 +434,14 @@ class tx_nG6_db {
if (!isset ($results['analyse_'.$analyze_id]) and $user_allowed) { if (!isset ($results['analyse_'.$analyze_id]) and $user_allowed) {
$results['analyse_'.$analyze_id] = array( $results['analyse_'.$analyze_id] = array(
'directory' => $row['analyze_directory'], 'directory' => $row['analyze_directory'],
'name' => $row['analyze_name'], 'name' => $row['analyze_name'],
'date' => $row['analyze_date'], 'id' => $row['analyze_id'],
'description' => $row['analyse_description'] 'hidden' => $row['analyze_hidden'],
'software' => $row['analyze_software'],
'version' => $row['analyze_version'],
'date' => $row['analyze_date'],
'description' => $row['analyze_description']
); );
} }
} }
...@@ -343,8 +459,8 @@ class tx_nG6_db { ...@@ -343,8 +459,8 @@ class tx_nG6_db {
* @param string $analyse_id the analyse id * @param string $analyse_id the analyse id
* @return hash table with all analyse information * @return hash table with all analyse information
*/ */
function get_analyse($analyse_id) { function select_analyse($analyse_id) {
// First select all analyse information // First select all analyse information
$queryParts = array( $queryParts = array(
'SELECT' => 'tx_nG6_project.uid AS project_id,'. 'SELECT' => 'tx_nG6_project.uid AS project_id,'.
......
...@@ -49,15 +49,20 @@ class tx_nG6_pi1 extends tslib_pibase { ...@@ -49,15 +49,20 @@ class tx_nG6_pi1 extends tslib_pibase {
if (strstr($this->cObj->currentRecord,'tt_content')) { if (strstr($this->cObj->currentRecord,'tt_content')) {
$conf['pidList'] = $this->cObj->data['pages']; $conf['pidList'] = $this->cObj->data['pages'];
} }
$this->conf=$conf; // Setting the TypoScript passed to this function in $this->conf // Setting the TypoScript passed to this function in $this->conf
$this->conf=$conf;
$this->internal['results_at_a_time'] = $conf["results_at_a_time"]; $this->internal['results_at_a_time'] = $conf["results_at_a_time"];
$this->pi_setPiVarDefaults(); $this->pi_setPiVarDefaults();
$this->pi_USER_INT_obj=1; // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object! // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object!
$this->pi_loadLL(); // Loading the LOCAL_LANG values $this->pi_USER_INT_obj=1;
// Loading the LOCAL_LANG values
$this->pi_loadLL();
// If the user is authorized to access the specified project/run, display the page
if (tx_nG6_db::user_is_authorized($GLOBALS['TSFE']->fe_user->user['usergroup'], $this->piVars['project_id'], $this->piVars['run_id'])) { if (tx_nG6_db::user_is_authorized($GLOBALS['TSFE']->fe_user->user['usergroup'], $this->piVars['project_id'], $this->piVars['run_id'])) {
switch((string)$this->conf['view']) { switch((string)$this->conf['view']) {
// If the plugin is configured to display results by project
case 'project': case 'project':
if ($this->piVars['analyze_id']) { if ($this->piVars['analyze_id']) {
return $this->pi_wrapInBaseClass($this->pi_analyze_view('analyze')); return $this->pi_wrapInBaseClass($this->pi_analyze_view('analyze'));
...@@ -69,46 +74,34 @@ class tx_nG6_pi1 extends tslib_pibase { ...@@ -69,46 +74,34 @@ class tx_nG6_pi1 extends tslib_pibase {
return $this->pi_wrapInBaseClass($this->pi_project_view()); return $this->pi_wrapInBaseClass($this->pi_project_view());
} }
break; break;
// If the plugin is configured to display results by run
case 'run': case 'run':
if ($this->piVars['analyze_id']) { if ($this->piVars['analyze_id']) {
return $this->pi_wrapInBaseClass($this->pi_analyze_view('analyze')); return $this->pi_wrapInBaseClass($this->pi_analyze_view('analyze'));
} else { } else {
return $this->pi_wrapInBaseClass($this->pi_run_view()); return $this->pi_wrapInBaseClass($this->pi_run_view());
} }
break; break;
// If the plugin is not configured, display by project is default
default: default:
return $this->pi_wrapInBaseClass($this->pi_project_view()); return $this->pi_wrapInBaseClass($this->pi_project_view());
break; break;
} }
// If the user is not authorized
} else { } else {
return $this->pi_wrapInBaseClass($this->getFieldHeader('not_authorized')); return $this->pi_wrapInBaseClass($this->pi_getLL('not_authorized','[not_authorized]'));