RAPPEL : Opération de maintenance > ForgeMIA indisponible le 20 Janvier entre 7h et 12h

Commit 19dd974e authored by Romain Therville's avatar Romain Therville 🐭
Browse files

Update to tx_nG6_pi6.php

The send_purge_demand_mail() is now going to send an alert mail to the
nG6 admins if a purge demand already exists for a given project, instead
of creating a new one.

Issue #192
parent 0d951e86
......@@ -107,10 +107,8 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
}
static function send_purge_demand_mail($project_ids, $extension_allowed = 1) {
$project_name="";
foreach(explode(",", $project_ids) as $project_id){
#retrieve project data
$p=tx_nG6_db::select_a_project_retention_data_info($project_id, FALSE, TRUE);
......@@ -195,6 +193,8 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
#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 the trigger check_demand_insert is triggered, add_purge_demand() returns 0 and the process has to send a mail to warn the admins instead.
if($purge_demand_id > 0){
// We remove the hidden runs and analyzes from $p so they will not appear in the purge alert mail
$p=tx_nG6_db::select_a_project_retention_data_info($project_id, FALSE, FALSE);
......@@ -221,7 +221,6 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
$analyses_info[] = '<a href="'.str_replace($search, $replace, $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["run_link_url"]).'">'.$analysis_name.' ('.$analysis_id.')</a>';
}
#Build corresponding string array
//We get the project size without any hidden run or analyze
$total_project_size = tx_nG6_db::get_project_size($project_id, true, false);
......@@ -236,8 +235,6 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
$subject = '[nG6 purge] No '.$purge_demand_id.' - Project '.$p[$project_id]["project_name"];
$headers = array();
$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';
......@@ -245,6 +242,22 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
$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{
//If the demand could not be inserted because another one already exists for the given project, we send a mail to the nG6 admins
$mail = tx_nG6_utils::get_multiple_purge_demand_mail($p[$project_id]["project_name"]);
//We send the mail to ng6-support@groupes.renater.fr and Didier (See $GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_warning"] )
$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";
}
......
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