Commit 60dc52de authored by Celine Noirot's avatar Celine Noirot

add email to members if no manager, refactor code

parent 6f82456f
......@@ -845,7 +845,7 @@ class tx_nG6_eid {
$all_projects = trim(t3lib_div::_GP('project'));
print json_encode(tx_nG6_pi6::send_purge_demand_mail($user_id,$all_projects));
}
} elseif ($type == 'refresh_purge_demand') {
} elseif ($type == 'refresh_purge_demand') {
$purge_delay = trim(t3lib_div::_GP('purge_delay'));
print json_encode(tx_nG6_db::get_purge_demand_list($purge_delay));
} elseif ($type == 'refresh_purge_list') {
......
This diff is collapsed.
......@@ -136,33 +136,38 @@ Files impacted of:
$p=tx_nG6_db::select_a_project_retention_data_info($project_id);
#build email list of managers
$managers_email=Array();
$managers_name=Array();
$admin_email = Array();
$admin_name = Array();
$users_names=array();
$users_emails = array();
foreach ( $p[$project_id]["users"] as $u ){
if ( $u["right_level_label"] == "manager" ){
$managers_email[]=$u["email"];
$managers_name[]=$u["user_name"];
}elseif( $u["right_level_label"] == "administrator"){
$admin_email[] = $u["email"];
$admin_name[] = $u["user_name"];
}
if (!isset ($users_names[$u["right_level_label"]]) ){
$users_names[$u["right_level_label"]]=Array();
$users_emails[$u["right_level_label"]]=Array();
}
$users_names[$u["right_level_label"]][] = $u["user_name"];
$users_emails[$u["right_level_label"]][] = $u["email"];
}
#Warn if mail is sent to several manager
$email_warn="" ;
$purge_email_to="";
if ( count($managers_email) >= 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";
$purge_email_to=join(',', $managers_email);
}elseif ( count($managers_email ==0)) {
$email_warn="As this project do not have managers, administrators recieved this alert.\n";
$purge_email_to=join(',', $admin_email);
$managers_name=$admin_name;
}
$purge_name_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";
}
$purge_email_to=join(',', $users_emails['manager']);
$purge_name_to=$users_names['manager'];
} elseif ( count($users_emails['manager']) == 0) {
$purge_email_to=join(', ', array_merge($users_emails['administrator'],$users_emails['member']));
$purge_name_to=array_merge($users_names['administrator'],$users_names['member']);
$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";
$email_warn.= " - Members(s): ".join(', ',$users_emails['member']). "\n";
}
//Retrieve purgeable information for email
$run_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"];
......@@ -175,7 +180,7 @@ Files impacted of:
}
#Add purge demand to get id
$purge_demand_id = tx_nG6_db::add_purge_demand($user_id,$project_id,$p[$project_id]["total_purgeable_size"],$all_purgeable_runs,$all_purgeable_analysis,$managers_name);
$purge_demand_id = tx_nG6_db::add_purge_demand($user_id,$project_id,$p[$project_id]["total_purgeable_size"],$all_purgeable_runs,$all_purgeable_analysis,$purge_name_to);
#Build corresponding string array
$search=array("###nb_run###","###nb_analyse###","###PROJECT_NAME###","###PROJET_ID###","###DEMAND_ID###",
......
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