Commit 5dcd3225 authored by Celine Noirot's avatar Celine Noirot
Browse files

Merge branch 'dev' into 'master'

Merge branch Dev with Master

See merge request !118
parents 2c2abe02 c1bf7f3b
......@@ -1233,6 +1233,34 @@ CREATE ALGORITHM=UNDEFINED DEFINER=`ng6`@`localhost` SQL SECURITY DEFINER VIEW `
CREATE ALGORITHM=UNDEFINED DEFINER=`ng6`@`localhost` SQL SECURITY DEFINER VIEW `tx_nG6_view_project_user` AS select `tx_nG6_project`.`uid` AS `project_id`,`tx_nG6_project`.`space_id` AS `space_id`,`fe_users`.`uid` AS `user_id`, `fe_users`.`username` AS `user_name`,`fe_users`.`email` AS `email`,`fe_users`.`usergroup` AS `user_group`,`fe_rights_levels`.`right_level_label` AS `right_level_label`,`fe_groups`.`title` AS `user_group_title` from ((((`tx_nG6_project` join `fe_rights` on((`fe_rights`.`project_id` = `tx_nG6_project`.`uid`))) join `fe_users` on((`fe_rights`.`fe_user_id` = `fe_users`.`uid`))) join `fe_groups` on((`fe_users`.`usergroup` = `fe_groups`.`uid`))) join `fe_rights_levels` on((`fe_rights_levels`.`right_level_id` = `fe_rights`.`right_id`)));
--
-- Trigger check_demand_insert to prevent the insertion of a second purge demand for a single project
--
DELIMITER ;;
CREATE TRIGGER check_demand_insert BEFORE INSERT ON `tx_nG6_purge_demand`
FOR EACH ROW
BEGIN
DECLARE var_demand_state, var_project_id, var_count int;
SELECT demand_state, project_id, count(*) as count
INTO var_demand_state, var_project_id, var_count
FROM tx_nG6_purge_demand
WHERE demand_state = 'sent' AND project_id = new.project_id
GROUP BY demand_state, project_id;
IF var_count > 0 THEN
set @message_text = concat('A purge demand already exists for project ', new.project_id);
signal sqlstate '45000'
set message_text = @message_text;
END IF;
END;
;;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
......
......@@ -368,18 +368,21 @@ class tx_nG6_db {
$GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_nG6_purge_demand', $purge_data);
$purge_demand_id = $GLOBALS['TYPO3_DB']->sql_insert_id();
tx_nG6_db::update_field('tx_nG6_run', $all_runs_ids, array('mail_sent_date','purge_demand_id'),array($date,$purge_demand_id));
tx_nG6_db::update_field('tx_nG6_analyze',$all_analyses_ids,array('mail_sent_date','purge_demand_id'),array($date,$purge_demand_id));
//If the trigger "check_demand_insert" is triggered, the previous request will return 0, so we have to prevents the updates to tx_nG6_run and tx_nG6_analyzes in that case
if( $purge_demand_id > 0){
tx_nG6_db::update_field('tx_nG6_run', $all_runs_ids, array('mail_sent_date','purge_demand_id'),array($date,$purge_demand_id));
tx_nG6_db::update_field('tx_nG6_analyze',$all_analyses_ids,array('mail_sent_date','purge_demand_id'),array($date,$purge_demand_id));
foreach($user_ids as $a_id){
foreach($user_ids as $a_id){
$purge_data_user = array(
'tstamp' => $date,
'crdate' => $date,
'crdate' => $date,
'cruser_id' => $cruser_id,
'purge_demand_id' => $purge_demand_id,
'fe_users_id' => $a_id
);
$GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_nG6_purge_demand_fe_users', $purge_data_user);
}
}
return $purge_demand_id;
}
......@@ -1192,7 +1195,7 @@ INNER JOIN fe_groups ON fe_groups.uid = fe_users.usergroup',
* @param string $project_id the project id
* @return hash table with all runs information
*/
static function get_project_runs($project_id, $orderby='', $limit='') {
static function get_project_runs($project_id, $get_hidden=TRUE, $orderby='', $limit='') {
// First select all runs from the database
$queryParts = Array(
......@@ -1223,6 +1226,10 @@ static function get_project_runs($project_id, $orderby='', $limit='') {
'ORDERBY' => $orderby,
'LIMIT' => $limit
);
if(!$get_hidden){
$queryParts['WHERE'] .= ' AND tx_nG6_run.hidden = 0';
}
// Then create the result hash table
......@@ -1343,7 +1350,7 @@ static function get_project_runs($project_id, $orderby='', $limit='') {
* @param string $project_id the project id
* @return hash table with all analysis information
*/
static function get_project_analysis($project_id, $orderby='', $limit='') {
static function get_project_analysis($project_id, $get_hidden=TRUE, $orderby='', $limit='') {
// First select all analysis from the database
$queryParts = array(
......@@ -1372,6 +1379,11 @@ static function get_project_runs($project_id, $orderby='', $limit='') {
'ORDERBY' => $orderby,
'LIMIT' => $limit
);
if(!$get_hidden){
$queryParts['WHERE'] .= ' AND tx_nG6_analyze.hidden = 0';
}
// Then create the result hash table
$results = array();
$res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
......@@ -1608,19 +1620,20 @@ static function get_project_runs($project_id, $orderby='', $limit='') {
*
* @param string $p_id the project id to return the size
* @param string $data_folder the data folder
* @param boolean $get_analyzes get analyzes size ?
* @param boolean $get_analyzes get analyzes size ?
* @param boolean $get_hidden get the hidden runs and analyzes ?
*/
static function get_project_size($p_id, $get_analyzes=false) {
static function get_project_size($p_id, $get_analyzes=false, $get_hidden=true) {
$full_size = 0;
// All runs
$project_runs = tx_nG6_db::get_project_runs($p_id);
$project_runs = tx_nG6_db::get_project_runs($p_id, $get_hidden);
foreach($project_runs as $run_id => $run_values) {
$full_size += tx_nG6_db::get_run_size($run_values['id'], $get_analyzes);
}
if ($get_analyzes) {
if ($get_analyzes) {
// All analysis
$project_analysis = tx_nG6_db::get_project_analysis($p_id);
$project_analysis = tx_nG6_db::get_project_analysis($p_id, $get_hidden);
foreach($project_analysis as $analyse_id => $analyze_values) {
$full_size += tx_nG6_db::get_analysis_size($analyze_values['id']);
}
......
......@@ -266,6 +266,32 @@ $template_mail.='<p>Yours sincerely</p>
return $mail;
}
/**
* Returns the mail content to warn the nG6 admins that a purge demand already exists for the given project
* @param string $project_name
* @return $mail, a string containing the mail content
*/
static function get_multiple_purge_demand_mail($project_name) {
$template_mail='
<html>
<head>
<title>Data Purge on nG6</title>
</head>
<body>
<p>Dear nG6 admin,</p>
<p>A purge demand already exists for the project ###PROJECT_NAME###.</p>
<p>Please, purge the data corresponding to the previous purge demand before opening a new one.</p></br>
<p>Yours sincerely</p>
<p>nG6 team (for GeT-Genotoul and Bioinfo-Genotoul facilities)</p>
</body>
</html>
';
$mail = str_replace('###PROJECT_NAME###', $project_name, $template_mail);
return $mail;
}
/**
* hash password (using default encryption method)
* @param string $password
......
This diff is collapsed.
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