Commit 9c73b74d authored by Romain Therville's avatar Romain Therville 🐭
Browse files

Update to the purge process

(Same as commit 763ffb96, but for the
"send" and "resend" functions.)

issue #195
parent 2c1324f4
......@@ -109,6 +109,15 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
static function send_purge_demand_mail($project_ids, $extension_allowed = 1) {
$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"];
foreach(explode(",", $project_ids) as $project_id){
#retrieve project data
......@@ -203,41 +212,6 @@ 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);
// We remove the hidden runs and analyzes from $p so they will not appear in the purge alert mail
/*
foreach($p as $project_id_in_list => $project_item){
foreach($project_item['state']['extended']['run_ids'] as $y => $run_id){
$run = tx_nG6_db::select_run($run_id);
if($run['hidden']) == 1 {
unset($p[$project_id_in_list]['state']['extended']['run_ids'][$y]);
}
}
foreach($project_item['state']['extended']['analysis_ids'] as $y => $analyse_id){
$analysis = tx_nG6_db::select_analyse($analyse_id);
if($analysis['hidden']) == 1 {
unset($p[$project_id_in_list]['state']['extended']['analysis_ids'][$y]);
}
}
foreach($project_item['state']['stored']['run_ids'] as $y => $run_id){
$run = tx_nG6_db::select_run($run_id);
if($run['hidden']) == 1 {
unset($p[$project_id_in_list]['state']['stored']['run_ids'][$y]);
}
}
foreach($project_item['state']['stored']['analysis_ids'] as $y => $analyse_id){
$analysis = tx_nG6_db::select_analyse($analyse_id);
if($analysis['hidden']) == 1 {
unset($p[$project_id_in_list]['state']['stored']['analysis_ids'][$y]);
}
}
}
*/
#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);
......@@ -248,27 +222,25 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
$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), $extension_allowed);
//We need to set or reset the headers to prevent the previous values from staying in the next "for each project" loop
$headers = array();
$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
}
return "Mail sent";
}
static 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);
$headers[] = 'From: '.$GLOBALS['TSFE']->tmpl->setup["plugin."]["tx_nG6_pi6."]["email_from"];
//$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"];
foreach($res_demands as $res_demand){
$res_project = tx_nG6_db::select_project($res_demand["project_id"]);
$total_project_size = tx_nG6_db::get_project_size($res_demand["project_id"], true) ;
......@@ -300,18 +272,7 @@ class tx_nG6_pi6 extends \TYPO3\CMS\Frontend\Plugin\AbstractPlugin {
$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"], "This email was send to ". join(', ',$res_demand["emails"]).". ", join(', ', $run_info), join(', ', $analyses_info), $extension_allowed);
//We need to set or reset the headers to prevent the previous values from staying in the next "for each project" loop
$headers = array();
$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[] = '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"];
$to= join(",",$res_demand["emails"]);
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