Commit 4a5039b7 authored by Gerald Salin's avatar Gerald Salin

#75 : correct bug in purge management with new version of typo3

parent 6e956829
......@@ -567,7 +567,7 @@ class CasavaNG6Workflow(NG6Workflow):
# contamination_search
if contam :
if self.contamination_databank: contam.extend(self.contamination_databank)
contamination_search = self.add_component("ContaminationSearch", [filtered_read1_files+filtered_read2_files, contam, reads_prefixes], parent = fastqilluminafilter)
contamination_search = self.add_component("ContaminationSearch", [filtered_read1_files, contam, list((Utils.get_group_basenames(filtered_read1_files, "read")).keys())], parent = fastqilluminafilter)
# make some statistics on raw file
fastqc = self.add_component("FastQC", [filtered_read1_files+filtered_read2_files, (self.group_prefix is not None), self.no_group, "fastqc.tar.gz"], parent = fastqilluminafilter)
......
......@@ -48,7 +48,7 @@ class tx_nG6_eid {
//\TYPO3\CMS\Frontend\Utility\EidUtility::connectDB();
$type = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('type'));
$user_id = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('user_id'));
$GLOBALS['TSFE'] = $tsfe = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'), '');
$GLOBALS['TSFE'] = $tsfe = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id'), '');
/** @var \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController $tsfe */
$tsfe->connectToDB();
$tsfe->initFEuser();
......
......@@ -203,30 +203,39 @@ class tx_nG6_utils {
$purgeable_size, $project_size, $purge_delay, $url_price, $min_extention_duration,
$min_extention_size, $emails, $runs_list, $analyse_list) {
$template_mail= 'Mail automatique / en phase de TEST
Dear user,
$template_mail= '
<html>
<head>
<title>Data Purge on nG6</title>
</head>
<body><p>Mail automatique / en phase de TEST</p>
<p>Dear user,</p>
The two years data storage period of your ###PROJECT_NAME### project (###nb_run### run(s) and ###nb_analyse### analyse(s)) is ended.
<p>The two years data storage period of part or whole ###PROJECT_NAME### project (###nb_run### run(s) and ###nb_analyse### analyse(s)) is ended.</p>
This purge alert No ###DEMAND_ID### corresponds to ###SIZE_STR### see list of impacted files below.
<p>This purge alert No ###DEMAND_ID### corresponds to ###SIZE_STR### see list of impacted files below.</p>
In ###PURGE_DELAY### days, your data will be deleted. Keep us informed if you wish to extend the storage period,
please have a look at our storage fees (###URL_PRICE###) and reply to this email with the following information:
----------------------------------------------
Demand number: ###DEMAND_ID###
Request for extension term: XXX (minimal unit: ###EXTENSION_DURATION###)
Request for extension size: XXX (mininal unit: ###EXTENSION_SIZE###)
Laboratory name/Institution:
----------------------------------------------
<p>In ###PURGE_DELAY### days, your data will be deleted. Keep us informed if you wish to extend the storage period,
please have a look at our storage fees (<a href="###URL_PRICE###">###URL_PRICE###</a>) and reply to this email with the following information:</p>
<p>----------------------------------------------</p>
<ul><li>Demand number: ###DEMAND_ID###</li>
<li>Request for extension term: XXX (minimal unit: ###EXTENSION_DURATION###)</li>
<li>Request for extension size: XXX (mininal unit: ###EXTENSION_SIZE###)</li>
<li>Laboratory name/Institution: </li></ul>
<p>----------------------------------------------</p>
###EMAILS###We would appreciate if you could group your demands by laboratory.
<p>###EMAILS###We would appreciate if you could group your demands by laboratory.</p>
Yours sincerely
nG6 team (for GeT-Genotoul and Bioinfo-Genotoul facilities)
<p>Yours sincerely</p>
<p>nG6 team (for GeT-Genotoul and Bioinfo-Genotoul facilities)</p>
Files impacted of:
- runs names: ###RUNS_LIST###
- analyses ids: ###ANALYSES_LIST###
<p>Files impacted of:</p>
<ul>
<li>Runs : ###RUNS_LIST###
<li>analyses ids: ###ANALYSES_LIST###</li>
</ul>
</body>
</html>
';
$size_str = $purgeable_size . " purgeable data on ". $project_size ." of whole project";
......
......@@ -101,7 +101,7 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
return $smarty->fetch('administration_view.tpl');
}
function send_purge_demand_mail($project_ids) {
static function send_purge_demand_mail($project_ids) {
$project_name="";
foreach(explode(",", $project_ids) as $project_id){
......@@ -127,7 +127,7 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
$purge_user_id_to=Array();
if ( count( $users_emails['manager']) >= 1 ) {
if ( count( $users_emails['manager']) > 1 ) {
$email_warn="Be aware that this project is associated to several managers (all recieved this email), please send only one answer per purge alert number.\n";
$email_warn="Be aware that this project is associated to several managers (all received this email), please send only one answer per purge alert number.\n";
}
$purge_email_to=join(',', $users_emails['manager']);
$purge_user_id_to=$users_id['manager'];
......@@ -139,7 +139,7 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
$users_emails_to = $users_emails['administrator'];
$purge_user_id_to=array_merge($users_id['administrator']);
}
$purge_email_to=join(', ',$users_emails_to );
$purge_email_to=join(', ',$users_emails_to );
$email_warn="As this project do not have managers, administrators and members recieved this alert.\n";
$email_warn.= " - Administrator(s): ".join(', ',$users_emails['administrator']). "\n";
......@@ -148,44 +148,52 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
}
//Retrieve purgeable information for email
$run_info=Array();
$analyses_info=Array();
//ici bug car on prend l'ensemble des runs/analyses du projets
$all_purgeable_runs=array_merge($p[$project_id]["state"]["stored"]["run_ids"],$p[$project_id]["state"]["extended"]["run_ids"]);
$all_purgeable_analysis=array_merge($p[$project_id]["state"]["stored"]["analysis_ids"],$p[$project_id]["state"]["extended"]["analysis_ids"]);
$nb_run_purgeable = $p[$project_id]["state"]["stored"]["nb_run"]+ $p[$project_id]["state"]["extended"]["nb_run"];
$nb_analyse_purgeable = $p[$project_id]["state"]["stored"]["nb_analyze"]+ $p[$project_id]["state"]["extended"]["nb_analyze"];
//Retrieve run name
$search=array("###TYPE_OBJECT###","###RUN_ID###","###PROJECT_ID###");
foreach($all_purgeable_runs as $run_id ){
$run = tx_nG6_db::select_run($run_id);
$run_name = $run["name"];
$run_info[]= $run["name"]." ($run_id)";
$replace=array("run_id",$run_id,$project_id);
$run_info[] = '<a href="'.str_replace($search, $replace, $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["run_link_url"]).'">'.$run["name"].' ('.$run_id.')</a>';
}
foreach($all_purgeable_analysis as $analysis_id ){
$replace=array("analyze_id",$analysis_id,$project_id);
$analyses_info[] = '<a href="'.str_replace($search, $replace, $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["run_link_url"]).'">'.$analysis_id.'</a>';
}
#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);
#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) ;
$total_project_size = tx_nG6_db::get_project_size($project_id, true);
$mail = tx_nG6_utils::get_purge_mail($p[$project_id]["project_name"],$project_id, $nb_run_purgeable,$nb_analyse_purgeable, $purge_demand_id,
tx_nG6_utils::get_octet_string_representation($p[$project_id]["total_purgeable_size"]), tx_nG6_utils::get_octet_string_representation($total_project_size),
$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["delay_purge"],
$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["extension_url_price"], $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["min_extension_duration"],
$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["min_extension_size"], $email_warn, join(', ', $run_info), join(', ', $all_purgeable_analysis));
$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["min_extension_size"], $email_warn, join(', ', $run_info), join(', ', $analyses_info));
$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[] = 'X-Mailer: PHP/' . phpversion();
#TODO Uncomment
#$to = "celine.noirot@inra.fr";
$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
}
return "Mail sent";
}
function resend_purge_demand_mail ($demands_id) {
static function resend_purge_demand_mail ($demands_id) {
$res_demands = tx_nG6_db::get_purge_demand_from_id($demands_id);
foreach($res_demands as $res_demand){
$res_project = tx_nG6_db::select_project($res_demand["project_id"]);
......@@ -200,12 +208,12 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
$subject = '[nG6 purge / reminder] No '.$res_demand["demand_id"].' - Project '.$res_project["name"];
$headers[] = 'From: '.$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"];
$to= join(",",$res_demand["emails"]);
#TODO Uncomment
#$to = "celine.noirot@inra.fr";
mail($to, $subject, $mail, implode("\r\n", $headers));
}
}
}
......
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