Commit 7224cf47 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

hidden field ok -> if hidden = 1 only super groups can see the object

parent e4e8071e
......@@ -113,7 +113,7 @@ class tx_nG6_pi1 extends tslib_pibase {
return $this->pi_project_list_view($res);
} else { // If no results
return $this->getFieldHeader('no_raw');
}
}
}
}
......@@ -124,18 +124,41 @@ class tx_nG6_pi1 extends tslib_pibase {
* @return A HTML list if result items
*/
function pi_project_list_view($res) {
$nb_project = 0;
$content = '<table'.$this->pi_classParam('listrow').'>
<tr>
<th>'.$this->getFieldHeader('project_name').'</th>
<th>'.$this->getFieldHeader('description').'</th>
</tr>';
while($this->internal['currentRow'] = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$content .= '<tr>
<td>'.$this->getFieldContent('name', array('project_id'=>$this->internal['currentRow']['uid'])).'</td>
<td>'.$this->getFieldContent('description').'</td>
</tr>';
while($this->internal['currentRow'] = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
if ($this->internal['currentRow']['hidden'] == 0) { // If it's not a hidden project
$content .= '<tr>
<td>'.$this->getFieldContent('name', array('project_id'=>$this->internal['currentRow']['uid'])).'</td>
<td>'.$this->getFieldContent('description').'</td>
</tr>';
$nb_project++;
} else {
$user_groups = t3lib_div::intExplode(',',$this->getCurrentUserGroups());
$user_allowed = false;
foreach($this->getSuperGroupsOf($this->internal['currentRow']['fe_group']) AS $valeur) {
if (in_array($valeur, $user_groups)) {
$user_allowed = true;
$nb_project++;
}
}
if ($user_allowed) {
$content .= '<tr>
<td '.$this->pi_classParam('hidden').' >'.$this->getFieldContent('name', array('project_id'=>$this->internal['currentRow']['uid'])).'</td>
<td '.$this->pi_classParam('hidden').' >'.$this->getFieldContent('description').'</td>
</tr>';
}
}
}
if ($nb_project > 0) {
return $content .= '</table>';
} else {
return $this->getFieldHeader('no_raw');
}
return $content .= '</table>';
}
/**
......@@ -164,7 +187,8 @@ class tx_nG6_pi1 extends tslib_pibase {
'tx_nG6_run.date AS run_date, tx_nG6_run.species AS run_species, tx_nG6_run.data_nature AS run_data_nature,' .
'tx_nG6_run.type AS run_type, tx_nG6_run.nb_sequences AS run_nb_sequences, tx_nG6_run.full_seq_size AS run_full_seq_size,' .
'tx_nG6_run.description AS run_description, tx_nG6_run.sequencer AS run_sequencer,' .
'tx_nG6_run.directory AS run_directory, tx_nG6_project.name AS project_name',
'tx_nG6_run.directory AS run_directory, tx_nG6_run.hidden AS run_hidden, tx_nG6_project.name AS project_name,' .
'tx_nG6_project.fe_group AS project_fe_group',
'FROM' => 'tx_nG6_run INNER JOIN (tx_nG6_project_run INNER JOIN tx_nG6_project ON tx_nG6_project_run.project_id=tx_nG6_project.uid)' .
'ON tx_nG6_run.uid=tx_nG6_project_run.run_id',
'WHERE' => 'tx_nG6_run.uid='.$this->piVars['run_id'],
......@@ -192,7 +216,8 @@ class tx_nG6_pi1 extends tslib_pibase {
'SELECT' => 'tx_nG6_run.uid AS run_id, tx_nG6_run.name AS name, tx_nG6_project.name AS project_name,' .
'tx_nG6_run.date AS run_date, tx_nG6_run.species AS run_species, tx_nG6_run.data_nature AS run_data_nature,' .
'tx_nG6_run.type AS run_type, tx_nG6_run.nb_sequences AS run_nb_sequences, tx_nG6_run.full_seq_size AS run_full_seq_size,' .
'tx_nG6_run.description AS run_description, tx_nG6_run.sequencer AS run_sequencer, tx_nG6_project.name AS project_name',
'tx_nG6_run.description AS run_description, tx_nG6_run.sequencer AS run_sequencer, tx_nG6_run.hidden AS run_hidden,' .
'tx_nG6_project.name AS project_name, tx_nG6_project.fe_group AS project_fe_group',
'FROM' => 'tx_nG6_run INNER JOIN (tx_nG6_project_run INNER JOIN tx_nG6_project ON tx_nG6_project_run.project_id=tx_nG6_project.uid)' .
'ON tx_nG6_run.uid=tx_nG6_project_run.run_id',
'WHERE' => $where,
......@@ -217,7 +242,7 @@ class tx_nG6_pi1 extends tslib_pibase {
* @return A HTML list if result items
*/
function pi_run_list_view($res) {
$nb_run = 0;
if ($this->piVars['project_id']) {
$content = '<br /> <h3> '.$this->getFieldHeader('runs_done').'</h3> <br />';
}
......@@ -235,21 +260,50 @@ class tx_nG6_pi1 extends tslib_pibase {
<th>'.$this->getFieldHeader('sequencer').'</td>
</tr>';
while($this->internal['currentRow'] = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$content .= '<tr>
<td>'.$this->getFieldContent('name', array('run_id'=>$this->internal['currentRow']['run_id'], 'project_id'=>$this->piVars['project_id'])).'</td>
<td>'.$this->getFieldContent('project_name').'</td>
<td>'.$this->getFieldContent('run_date').'</td>
<td>'.$this->getFieldContent('run_species').'</td>
<td>'.$this->getFieldContent('run_data_nature').'</td>
<td>'.$this->getFieldContent('run_type').'</td>
<td>'.$this->getFieldContent('run_nb_sequences').'</td>
<td>'.$this->getFieldContent('run_full_seq_size').'</td>
<td>'.$this->getFieldContent('run_description').'</td>
<td>'.$this->getFieldContent('run_sequencer').'</td>
</tr>';
if ($this->internal['currentRow']['run_hidden'] == 0) { // If it's not a hidden run
$content .= '<tr>
<td>'.$this->getFieldContent('name', array('run_id'=>$this->internal['currentRow']['run_id'], 'project_id'=>$this->piVars['project_id'])).'</td>
<td>'.$this->getFieldContent('project_name').'</td>
<td>'.$this->getFieldContent('run_date').'</td>
<td>'.$this->getFieldContent('run_species').'</td>
<td>'.$this->getFieldContent('run_data_nature').'</td>
<td>'.$this->getFieldContent('run_type').'</td>
<td>'.$this->getFieldContent('run_nb_sequences').'</td>
<td>'.$this->getFieldContent('run_full_seq_size').'</td>
<td>'.$this->getFieldContent('run_description').'</td>
<td>'.$this->getFieldContent('run_sequencer').'</td>
</tr>';
$nb_run++;
} else {
$user_groups = t3lib_div::intExplode(',',$this->getCurrentUserGroups());
$user_allowed = false;
foreach($this->getSuperGroupsOf($this->internal['currentRow']['project_fe_group']) AS $valeur) {
if (in_array($valeur, $user_groups)) {
$user_allowed = true;
$nb_run++;
}
}
if ($user_allowed) {
$content .= '<tr>
<td '.$this->pi_classParam('hidden').' >'.$this->getFieldContent('name', array('run_id'=>$this->internal['currentRow']['run_id'], 'project_id'=>$this->piVars['project_id'])).'</td>
<td '.$this->pi_classParam('hidden').' >'.$this->getFieldContent('project_name').'</td>
<td '.$this->pi_classParam('hidden').' >'.$this->getFieldContent('run_date').'</td>
<td '.$this->pi_classParam('hidden').' >'.$this->getFieldContent('run_species').'</td>
<td '.$this->pi_classParam('hidden').' >'.$this->getFieldContent('run_data_nature').'</td>
<td '.$this->pi_classParam('hidden').' >'.$this->getFieldContent('run_type').'</td>
<td '.$this->pi_classParam('hidden').' >'.$this->getFieldContent('run_nb_sequences').'</td>
<td '.$this->pi_classParam('hidden').' >'.$this->getFieldContent('run_full_seq_size').'</td>
<td '.$this->pi_classParam('hidden').' >'.$this->getFieldContent('run_description').'</td>
<td '.$this->pi_classParam('hidden').' >'.$this->getFieldContent('run_sequencer').'</td>
</tr>';
}
}
}
if ($nb_run > 0) {
return $content .= '</table>';
} else {
return '';
}
$content .= '</table>';
return $content;
}
/**
......@@ -319,8 +373,13 @@ class tx_nG6_pi1 extends tslib_pibase {
// Selects Analyzis done on this run
$queryParts = array(
'SELECT' => 'tx_nG6_analyze.uid AS uid, tx_nG6_analyze.name AS name, tx_nG6_analyze.description AS description,' .
'tx_nG6_analyze.software AS software, tx_nG6_analyze.version AS version',
'FROM' => 'tx_nG6_analyze INNER JOIN tx_nG6_run_analyze ON tx_nG6_analyze.uid=tx_nG6_run_analyze.analyze_id',
'tx_nG6_analyze.software AS software, tx_nG6_analyze.version AS version, tx_nG6_analyze.hidden AS hidden,' .
'tx_nG6_project.fe_group AS project_fe_group',
'FROM' => 'tx_nG6_analyze INNER JOIN (tx_nG6_run_analyze INNER JOIN ( tx_nG6_run INNER JOIN ( tx_nG6_project_run INNER JOIN tx_nG6_project ' .
'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_run.uid=tx_nG6_run_analyze.run_id ) ' .
'ON tx_nG6_analyze.uid=tx_nG6_run_analyze.analyze_id ',
'WHERE' => 'tx_nG6_run_analyze.run_id = '.$this->piVars['run_id'],
'GROUPBY' => '',
'ORDERBY' => 'name',
......@@ -330,8 +389,10 @@ class tx_nG6_pi1 extends tslib_pibase {
// Selects Analyzis done on this project
$queryParts = array(
'SELECT' => 'tx_nG6_analyze.uid AS uid, tx_nG6_analyze.name AS name, tx_nG6_analyze.description AS description,' .
'tx_nG6_analyze.software AS software, tx_nG6_analyze.version AS version',
'FROM' => 'tx_nG6_analyze INNER JOIN tx_nG6_project_analyze ON tx_nG6_analyze.uid=tx_nG6_project_analyze.analyze_id',
'tx_nG6_analyze.software AS software, tx_nG6_analyze.version AS version, tx_nG6_analyze.hidden AS hidden,' .
'tx_nG6_project.fe_group AS project_fe_group',
'FROM' => 'tx_nG6_analyze INNER JOIN ( tx_nG6_project_analyze INNER JOIN tx_nG6_project ON tx_nG6_project.uid=tx_nG6_project_analyze.project_id ) ' .
'ON tx_nG6_analyze.uid=tx_nG6_project_analyze.analyze_id',
'WHERE' => 'tx_nG6_project_analyze.project_id = '.$this->piVars['project_id'],
'GROUPBY' => '',
'ORDERBY' => 'name',
......@@ -354,6 +415,7 @@ class tx_nG6_pi1 extends tslib_pibase {
* @return A HTML list if result items
*/
function pi_analyze_list_view($res) {
$nb_analyse = 0;
$content.='<br /> <h3> '.$this->getFieldHeader('analyzes_done').'</h3> <br />
<table'.$this->pi_classParam('listrow').'>
<tr>
......@@ -363,15 +425,38 @@ class tx_nG6_pi1 extends tslib_pibase {
<th>'.$this->getFieldHeader('version').'</td>
</tr>';
while($this->internal['currentRow'] = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$content .= '<tr>
<td>'.$this->getFieldContent('name', array('analyze_id'=>$this->internal['currentRow']['uid'], 'run_id'=>$this->piVars['run_id'], 'project_id'=>$this->piVars['project_id'])).'</td>
<td>'.$this->getFieldContent('description').'</td>
<td>'.$this->getFieldContent('software').'</td>
<td>'.$this->getFieldContent('version').'</td>
</tr>';
if ($this->internal['currentRow']['hidden'] == 0) { // If it's not a hidden project
$content .= '<tr>
<td>'.$this->getFieldContent('name', array('analyze_id'=>$this->internal['currentRow']['uid'], 'run_id'=>$this->piVars['run_id'], 'project_id'=>$this->piVars['project_id'])).'</td>
<td>'.$this->getFieldContent('description').'</td>
<td>'.$this->getFieldContent('software').'</td>
<td>'.$this->getFieldContent('version').'</td>
</tr>';
$nb_analyse++;
} else {
$user_groups = t3lib_div::intExplode(',',$this->getCurrentUserGroups());
$user_allowed = false;
foreach($this->getSuperGroupsOf($this->internal['currentRow']['project_fe_group']) AS $valeur) {
if (in_array($valeur, $user_groups)) {
$user_allowed = true;
$nb_analyse++;
}
}
if ($user_allowed) {
$content .= '<tr>
<td '.$this->pi_classParam('hidden').' >'.$this->getFieldContent('name', array('analyze_id'=>$this->internal['currentRow']['uid'], 'run_id'=>$this->piVars['run_id'], 'project_id'=>$this->piVars['project_id'])).'</td>
<td '.$this->pi_classParam('hidden').' >'.$this->getFieldContent('description').'</td>
<td '.$this->pi_classParam('hidden').' >'.$this->getFieldContent('software').'</td>
<td '.$this->pi_classParam('hidden').' >'.$this->getFieldContent('version').'</td>
</tr>';
}
}
}
$content .= '</table>';
return $content;
if ($nb_analyse > 0) {
return $content .= '</table>';
} else {
return '';
}
}
......@@ -601,6 +686,31 @@ class tx_nG6_pi1 extends tslib_pibase {
return in_array($authorized_group, split(",", $this->getCurrentUserGroups()));
}
}
function getSuperGroupsOf ($group) {
// First get the super group of the given group
$queryParts = array(
'SELECT' => 'uid, subgroup',
'FROM' => 'fe_groups',
'WHERE' => '',
'GROUPBY' => '',
'ORDERBY' => '',
'LIMIT' => ''
);
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
$reslist = array();
$i = 0;
while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
if (in_array($group, t3lib_div::intExplode(',',$row['subgroup']))) {
$reslist[$i] = $row['uid'];
$i++;
}
}
return $reslist;
}
}
......
Supports Markdown
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