Commit 79d52bcc authored by Gerald Salin's avatar Gerald Salin
Browse files

corrected bug displaying runs in the tree whereas they are hidden (get_project_runs)

sort the projects by their name in the tree (select_all_user_projects)
parent 4dc3449d
......@@ -38,21 +38,22 @@ class tx_nG6_db {
/**
* Select all project for the current user
*
*
* @param string $user_group the user group
* @return table with all projects
*/
function select_all_user_projects($user_group, $orderby='', $limit='') {
$projects = array();
// If the user is not logged on display demonstration project
if (!$GLOBALS['TSFE']->loginUser) {
if (!$GLOBALS['TSFE']->loginUser) {
$where = 'fe_group=0';
} else {
$where = 'fe_group IN ('.tx_nG6_db::get_user_groups($user_group).')';
$where = 'fe_group IN ('.tx_nG6_db::get_user_groups($user_group).')';
}
$orderby='tx_nG6_project.name ASC';
//First, get the analyzis project-scale
$queryParts = array(
$queryParts = array(
'SELECT' => 'tx_nG6_project.uid AS project_id, '.
'tx_nG6_project.name AS project_name, '.
'tx_nG6_project.description AS project_description, '.
......@@ -68,7 +69,7 @@ class tx_nG6_db {
$user_groups = t3lib_div::intExplode(',',tx_nG6_db::get_user_groups($user_group));
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$project_id = $row['project_id'];
// Is the user allowed to see this project
$user_allowed = false;
if ($row['project_hidden'] == 0) {
......@@ -80,15 +81,15 @@ class tx_nG6_db {
}
}
}
if (!isset ($projects['project_'.$project_id]) and $user_allowed) {
if (!isset ($projects['project_'.$project_id]) and $user_allowed) {
$projects['project_'.$project_id] = array(
'id' => $project_id,
'id' => $project_id,
'name' => $row['project_name'],
'hidden' => $row['project_hidden'],
'description' => $row['project_description']);
}
}
return $projects;
}
......@@ -121,7 +122,7 @@ class tx_nG6_db {
*/
function get_project_runs($user_group, $project_id, $orderby='', $limit='') {
// First select all runs from the database
$queryParts = Array(
$queryParts = Array(
'SELECT' => 'tx_nG6_run.uid AS run_id,'.
'tx_nG6_run.directory AS run_directory,'.
'tx_nG6_run.species AS run_species,'.
......@@ -139,18 +140,18 @@ class tx_nG6_db {
'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' => 'tx_nG6_project.uid='.$project_id,
'WHERE' => 'tx_nG6_run.hidden=0 AND tx_nG6_project.uid='.$project_id,
'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) {
......@@ -162,11 +163,11 @@ class tx_nG6_db {
}
}
}
if (!isset($results['run_'.$run_id]) and $user_allowed) {
$results['run_'.$run_id] = array(
if (!isset($results['run_'.$run_id]) and $user_allowed) {
$results['run_'.$run_id] = array(
'id' => $run_id,
'directory' => $row['run_directory'],
'directory' => $row['run_directory'],
'name' => $row['run_name'],
'project_name' => $row['project_name'],
'fe_group' => $row['project_fe_group'],
......@@ -179,9 +180,9 @@ class tx_nG6_db {
'data_nature' => $row['run_data_nature'],
'sequencer' => $row['run_sequencer'],
'type' => $row['run_type'],
'description' => $row['run_description']
'description' => $row['run_description']
);
}
}
}
return $results;
}
......@@ -195,9 +196,9 @@ class tx_nG6_db {
*/
function get_project_analysis($user_group, $project_id, $orderby, $limit) {
// First select all analysis from the database
$queryParts = array(
'SELECT' => 'tx_nG6_analyze.uid AS analyze_id,'.
'tx_nG6_analyze.directory AS analyze_directory,'.
$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.software AS analyze_software, '.
......@@ -218,7 +219,7 @@ class tx_nG6_db {
$user_groups = t3lib_div::intExplode(',',tx_nG6_db::get_user_groups($user_group));
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$analyze_id = $row['analyze_id'];
// Is the user allowed to see this analyse
$user_allowed = false;
if ($row['analyze_hidden'] == 0) {
......@@ -230,19 +231,19 @@ class tx_nG6_db {
}
}
}
if (!isset ($results['analyse_'.$analyze_id]) and $user_allowed) {
$results['analyse_'.$analyze_id] = array(
'directory' => $row['analyze_directory'],
if (!isset ($results['analyse_'.$analyze_id]) and $user_allowed) {
$results['analyse_'.$analyze_id] = array(
'directory' => $row['analyze_directory'],
'name' => $row['analyze_name'],
'id' => $row['analyze_id'],
'hidden' => $row['analyze_hidden'],
'software' => $row['analyze_software'],
'version' => $row['analyze_version'],
'date' => $row['analyze_date'],
'description' => $row['analyze_description']
'description' => $row['analyze_description']
);
}
}
}
return $results;
}
......@@ -254,20 +255,20 @@ class tx_nG6_db {
/**
* 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) {
if (!$GLOBALS['TSFE']->loginUser) {
$where = 'fe_group=0';
} else {
$where = 'fe_group IN ('.tx_nG6_db::get_user_groups($user_group).')';
$where = 'fe_group IN ('.tx_nG6_db::get_user_groups($user_group).')';
}
// Execute the request
$queryParts = Array(
$queryParts = Array(
'SELECT' => 'tx_nG6_run.uid AS run_id,'.
'tx_nG6_run.directory AS run_directory,'.
'tx_nG6_run.species AS run_species,'.
......@@ -289,14 +290,14 @@ class tx_nG6_db {
'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) {
......@@ -308,11 +309,11 @@ 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(
'id' => $run_id,
'directory' => $row['run_directory'],
'id' => $run_id,
'directory' => $row['run_directory'],
'name' => $row['run_name'],
'project_name' => $row['project_name'],
'fe_group' => $row['project_fe_group'],
......@@ -325,9 +326,9 @@ class tx_nG6_db {
'data_nature' => $row['run_data_nature'],
'sequencer' => $row['run_sequencer'],
'type' => $row['run_type'],
'description' => $row['run_description']
'description' => $row['run_description']
);
}
}
}
return $results;
......@@ -340,10 +341,10 @@ class tx_nG6_db {
* @return hash table with all the run information
*/
function select_run($run_id) {
// First select the run from the database
$queryParts = 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,'.
......@@ -363,15 +364,15 @@ class tx_nG6_db {
'GROUPBY' => '',
'ORDERBY' => 'tx_nG6_run.date DESC',
'LIMIT' => ''
);
);
// Then create the result hash table
$result = array();
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$result = array(
'project_id' => $row['project_id'],
'project_name' => $row['project_name'],
'directory' => $row['run_directory'],
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$result = array(
'project_id' => $row['project_id'],
'project_name' => $row['project_name'],
'directory' => $row['run_directory'],
'name' => $row['run_name'],
'type' => $row['run_type'],
'sequencer' => $row['run_sequencer'],
......@@ -380,12 +381,12 @@ class tx_nG6_db {
'species' => $row['run_species'],
'nb_sequences' => $row['nb_sequences'],
'date' => $row['run_date'],
'description' => $row['run_description']
);
'description' => $row['run_description']
);
}
return $result;
}
/**
* Select all analysis linked to the specified run
*
......@@ -395,9 +396,9 @@ class tx_nG6_db {
*/
function get_run_analysis($user_group, $run_id, $orderby='', $limit='') {
// First select all analysis from the database
$queryParts = array(
'SELECT' => 'tx_nG6_analyze.uid AS analyze_id,'.
'tx_nG6_analyze.directory AS analyze_directory,'.
$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.software AS analyze_software, '.
......@@ -419,7 +420,7 @@ class tx_nG6_db {
$user_groups = t3lib_div::intExplode(',',tx_nG6_db::get_user_groups($user_group));
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$analyze_id = $row['analyze_id'];
// Is the user allowed to see this analyse
$user_allowed = false;
if ($row['analyze_hidden'] == 0) {
......@@ -431,19 +432,19 @@ class tx_nG6_db {
}
}
}
if (!isset ($results['analyse_'.$analyze_id]) and $user_allowed) {
$results['analyse_'.$analyze_id] = array(
'directory' => $row['analyze_directory'],
if (!isset ($results['analyse_'.$analyze_id]) and $user_allowed) {
$results['analyse_'.$analyze_id] = array(
'directory' => $row['analyze_directory'],
'name' => $row['analyze_name'],
'id' => $row['analyze_id'],
'hidden' => $row['analyze_hidden'],
'software' => $row['analyze_software'],
'version' => $row['analyze_version'],
'date' => $row['analyze_date'],
'description' => $row['analyze_description']
'description' => $row['analyze_description']
);
}
}
}
return $results;
}
......@@ -452,7 +453,7 @@ class tx_nG6_db {
/*
* Run functions
*------------------------------------------------------------*/
/**
* Select all information on an analyse
*
......@@ -462,11 +463,11 @@ class tx_nG6_db {
function select_analyse($analyse_id) {
// First select all analyse information
$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,'.
$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 ',
......@@ -477,33 +478,33 @@ class tx_nG6_db {
'ORDERBY' => '',
'LIMIT' => ''
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
// If it's a project analyse, add project information
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'],
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'],
'run_name' => 'None',
'run_id' => 'None',
'directory' => $row['analyze_directory'],
'name' => $row['analyze_name'],
'date' => $row['analyze_date'],
'description' => $row['analyze_description']
);
'description' => $row['analyze_description']
);
}
return $result;
} else { // If it's a run analyse, add run information
$queryParts = array(
$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.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.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',
......@@ -517,22 +518,22 @@ class tx_nG6_db {
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
$result = array();
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$result = array(
'project_name' => $row['project_name'],
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$result = array(
'project_name' => $row['project_name'],
'project_id' => $row['project_id'],
'run_name' => $row['run_name'],
'run_id' => $row['run_id'],
'directory' => $row['analyze_directory'],
'run_name' => $row['run_name'],
'run_id' => $row['run_id'],
'directory' => $row['analyze_directory'],
'name' => $row['analyze_name'],
'date' => $row['analyze_date'],
'description' => $row['analyze_description']
);
'description' => $row['analyze_description']
);
}
return $result;
}
}
/*
* User functions
......@@ -540,10 +541,10 @@ class tx_nG6_db {
/**
* Return the supergroups list of the specified group
*
*
* @param string $group the group
* @return array
*/
*/
function get_super_groups_of ($group) {
// First get the super group of the given group
$queryParts = array(
......@@ -565,10 +566,10 @@ class tx_nG6_db {
}
return $reslist;
}
/**
* Returns a string with user groups separated by comas
*
*
* @param string $user_group the user group
* @return string list of user groups splited by a coma
*/
......@@ -577,7 +578,7 @@ class tx_nG6_db {
tx_nG6_db::get_sub_groups($user_group, '', $tab_groups);
$groups = '';
foreach($tab_groups as $valeur) { $groups .= $valeur.','; }
return substr($groups, 0, -1);
return substr($groups, 0, -1);
}
/**
......@@ -615,7 +616,7 @@ class tx_nG6_db {
}
}
}
/**
* Return if the user is authorized or not to access the specified project and run
*
......@@ -668,7 +669,7 @@ class tx_nG6_db {
return in_array($authorized_group, preg_split("/,/", tx_nG6_db::get_user_groups($user_group)));
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment