Commit bcb96d59 authored by Romain Therville's avatar Romain Therville 🐭

Update to "Administration > Mail obsolete project"

New "Send mail without extension" button, that sends the purge demand
mail without the content related to retention extension.

issue#161
parent 7b958d66
......@@ -914,9 +914,16 @@ class tx_nG6_eid {
} elseif ($type == 'purge_managment_mail') {
$all_projects = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project'));
print json_encode(tx_nG6_pi6::send_purge_demand_mail($all_projects));
$with_extension = 1;
print json_encode(tx_nG6_pi6::send_purge_demand_mail($all_projects,$with_extension));
} elseif ($type == 'purge_managment_mail_without_extension') {
$all_projects = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('project'));
$with_extension = 0;
print json_encode(tx_nG6_pi6::send_purge_demand_mail($all_projects,$with_extension));
} elseif ($type == 'purge_managment_resend_mail') {
$purge_ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_demand'));
$purge_ids = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_demand'));
print json_encode(tx_nG6_pi6::resend_purge_demand_mail($purge_ids));
} elseif ($type == 'refresh_purge_demand') {
$purge_delay = trim(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('purge_delay'));
......
......@@ -215,7 +215,9 @@ class tx_nG6_utils {
<p>This purge alert No ###DEMAND_ID### corresponds to ###SIZE_STR### see list of impacted files below.</p>
<p>In ###PURGE_DELAY### days, your data will be deleted. Keep us informed if you wish to extend the storage period,
<p>In ###PURGE_DELAY### days, your data will be deleted.</p>
<p>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>
......@@ -255,6 +257,54 @@ please have a look at our storage fees (<a href="###URL_PRICE###">###URL_PRICE##
return $mail;
}
static function get_purge_mail_without_extension($project_name, $project_id, $nb_run_purgeable,$nb_analyse_purgeable, $demand_id,
$purgeable_size, $project_size, $purge_delay, $url_price, $min_extention_duration,
$min_extention_size, $emails, $runs_list, $analyse_list) {
$template_mail= '
<html>
<head>
<title>Data Purge on nG6</title>
</head>
<body>
<p>Dear user,</p>
<p>The data storage period of part or whole ###PROJECT_NAME### project (###nb_run### run(s) and ###nb_analyse### analyse(s)) is ended.</p>
<p>This purge alert No ###DEMAND_ID### corresponds to ###SIZE_STR### see list of impacted files below.</p>
<p>In ###PURGE_DELAY### days, your data will be deleted.</p>
<p>Yours sincerely</p>
<p>nG6 team (for GeT-Genotoul and Bioinfo-Genotoul facilities)</p>
<p>Files impacted of:</p>
<ul>
<li>Runs : ###RUNS_LIST###
<li>Analyzes : ###ANALYSES_LIST###</li>
</ul>
</body>
</html>
';
$size_str = $purgeable_size . " purgeable data on ". $project_size ." of whole project";
if ($purgeable_size == $project_size) {
$size_str = "whole project (".$purgeable_size . ")";
}
$search=array("###nb_run###","###nb_analyse###","###PROJECT_NAME###","###PROJET_ID###","###DEMAND_ID###",
"###EMAILS###","###RUNS_LIST###","###ANALYSES_LIST###","###SIZE_STR###",
"###EXTENSION_DURATION###","###EXTENSION_SIZE###","###URL_PRICE###","###PURGE_DELAY###");
$replace=array($nb_run_purgeable,$nb_analyse_purgeable,$project_name,$project_id, $demand_id ,
$emails, $runs_list, $analyse_list, $size_str,
$min_extention_duration, $min_extention_size, $url_price, $purge_delay);
$mail=str_replace($search, $replace, $template_mail);
return $mail;
}
/**
* hash password (using default encryption method)
* @param string $password
......
......@@ -451,6 +451,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
With selection :
<div class="btn-group">
<button id="btn_obsolete_mail" type="button" class="btn btn-sm btn-default" ><i class="glyphicon glyphicon-envelope"></i> Send mail </button>
<button id="btn_obsolete_mail_without_extension" type="button" class="btn btn-sm btn-default" ><i class="glyphicon glyphicon-envelope"></i> Send mail without extension</button>
</div>
</th>
</tr>
......
......@@ -106,7 +106,7 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
return $smarty->fetch('administration_view.tpl');
}
static function send_purge_demand_mail($project_ids) {
static function send_purge_demand_mail($project_ids, $extension_allowed = 1) {
$project_name="";
foreach(explode(",", $project_ids) as $project_id){
......@@ -197,13 +197,21 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
#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);
$mail = tx_nG6_utils::get_purge_mail($p[$project_id]["project_name"],$project_id, $nb_run_purgeable,$nb_analyse_purgeable, $purge_demand_id,
if($extension_allowed == 1){
$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(', ', $analyses_info));
}else{
$mail = tx_nG6_utils::get_purge_mail_without_extension($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(', ', $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"];
......
......@@ -567,6 +567,38 @@ $(function () {
}
});
});
$("#btn_obsolete_mail_without_extension").click(function(){
$('#data_table_obsolete_wait').show();
$('#obsolete_list').hide();
var all_project=Array();
$("#ng6modal").modal('hide');
all_project = getPurgeDatatableCheckedValue(purge_table["obsolete"], "obsolete")
$.ajax({
url: "index.php?eID=tx_nG6&type=purge_managment_mail_without_extension&project="+all_project.join(',')+"&user_id="+$('input[id=user_id]').val(),
dataType: 'json',
success: function(val, status, xhr) {
refresh_project_obsolete(purge_table["obsolete"]);
refresh_purge_demand(purge_table["demand"]);
$("#purge_demand_error").hide()
},
error: function(returnval){
alert(returnval.status)
//TODO Afficher alerte en cas d'erreur de mail
var message = 'nG6 was unable to perform your action.';
if (returnval.status == 401){
message = 'it seems your session expired. Please re-authenticate!';
}
$('#data_table_obsolete_wait').hide();
$("#data_table_obsolete_error").html("<div class='tx-nG6-pi6-error'>Error : "+message+"</div>");
$("#data_table_obsolete_error").show();
$('#obsolete_list').show();
}
});
});
/****************************************
* tab process mail demand
......
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