Commit d03652bf authored by Romain Therville's avatar Romain Therville 🐭
Browse files

Merge branch 'master' into 'issue#195'

# Conflicts:
#   ui/nG6/pi6/class.tx_nG6_pi6.php
parents 9c73b74d 1881ae7b
......@@ -1233,6 +1233,33 @@ 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 */;
......
......@@ -112,7 +112,7 @@ class JFlowConfigReader(object):
def get_socket_options(self):
try:
return [self.reader.get("global", "server_socket_host"), int(self.reader.get("global", "server_socket_port")), self.reader.get("global", "server_socket_protocol")]
return [self.reader.get("global", "server_socket_host"), int(self.reader.get("global", "server_socket_port")), self.reader.get("global", "server_socket_protocol"), self.reader.get("global", "server_socket_proxied")]
except:
return ["127.0.0.1", 8080,"http"]
......
......@@ -530,7 +530,7 @@ class JFlowServer (object):
socket_opt = self.jflow_config_reader.get_socket_options()
if not os.path.isdir(path):
return {
'url':socket_opt[2]+'://' + socket_opt[0] + ':' + str(socket_opt[1]) + '/' + path.replace(work_dir, web_path),
'url':socket_opt[2]+'://' + str(socket_opt[3]) + '/' + path.replace(work_dir, web_path),
'size': get_octet_string_representation(os.path.getsize(os.path.abspath(path))),
'extension': os.path.splitext(path)[1]
}
......
......@@ -538,6 +538,7 @@ class SSH(object):
x = os.read(f, 1024)
except Exception as e:
# this always fails with io error
#raise Exception(e)
pass
return x.decode()
......
......@@ -368,6 +368,8 @@ class tx_nG6_db {
$GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_nG6_purge_demand', $purge_data);
$purge_demand_id = $GLOBALS['TYPO3_DB']->sql_insert_id();
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));
......@@ -381,6 +383,7 @@ class tx_nG6_db {
);
$GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_nG6_purge_demand_fe_users', $purge_data_user);
}
}
return $purge_demand_id;
}
......
......@@ -266,6 +266,27 @@ $template_mail.='<p>Yours sincerely</p>
return $mail;
}
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
......
......@@ -207,11 +207,12 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
}
$log_file_path = tx_nG6_utils::get_log_path();
error_log(date("d/m/Y, h:i:s")." IN tx_nG6_pi6.php, 'add_purge_demand' \n all_purgeable_runs = ".print_r($all_purgeable_runs, TRUE), 3, $log_file_path);
#Add purge demand to get id
$purge_demand_id = tx_nG6_db::add_purge_demand($GLOBALS['TSFE']->fe_user->user['uid'],$project_id,$p[$project_id]["total_purgeable_size"],$all_purgeable_runs,$all_purgeable_analysis,$purge_user_id_to);
if($purge_demand_id > 0){
#Build corresponding string array
//TODO RETURN TOTAL SIZE tx_nG6_utils::get_octet_string_representation($p[$project_id]["total_size"]
$total_project_size = tx_nG6_db::get_project_size($project_id, true);
......@@ -224,8 +225,32 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
$to = $purge_email_to;
$subject = '[nG6 purge] No '.$purge_demand_id.' - Project '.$p[$project_id]["project_name"];
$headers[] = 'From: '.$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_from"];
//$headers[] = 'From: gerald.salin@inra.fr';
//$headers[] = 'Errors-To: '.$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_copy"];
$headers[] = 'Errors-To: '.$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_from"];
$headers[] = 'X-Mailer: PHP/' . phpversion();
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=utf-8';
$headers[] = 'Cc: '.$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_copy"];
mail($to, $subject, $mail, implode("\r\n", $headers));
//TODO check return function mail ok
}else{
$mail = tx_nG6_utils::get_multiple_purge_demand_mail($p[$project_id]["project_name"]);
//We send the mail to ng6-support@groupes.renater.fr
//$to = $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_from"];
$to = $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_warning"];
$subject = '[nG6 purge] Project '.$p[$project_id]["project_name"].' already has a purge demand';
$headers[] = 'From: '.$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_from"];
$headers[] = 'Errors-To: '.$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_from"];
$headers[] = 'X-Mailer: PHP/' . phpversion();
$headers[] = 'MIME-Version: 1.0';
$headers[] = 'Content-type: text/html; charset=utf-8';
$headers[] = 'Cc: '.$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_copy"];
mail($to, $subject, $mail, implode("\r\n", $headers));
}
}
return "Mail sent";
}
......
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