Commit e132614c authored by Celine Noirot's avatar Celine Noirot

use user id instead of user name for purge

parent e30195fd
......@@ -303,7 +303,7 @@ class tx_nG6_db {
if (!isset ($by_project[$res_row['project_id']]["users"])) {
$by_project[$res_row['project_id']]["users"]=array();
}
array_push($by_project[$res_row['project_id']]["users"],array ('user_name' => $res_row['user_name'], 'email' =>$res_row['email'], 'groups' =>$res_row['user_group'], 'right_level_label' =>$res_row['right_level_label'], 'user_group_title' => $res_row['user_group_title']));
array_push($by_project[$res_row['project_id']]["users"],array ('user_id' => $res_row['user_id'], 'user_name' => $res_row['user_name'], 'email' =>$res_row['email'], 'groups' =>$res_row['user_group'], 'right_level_label' =>$res_row['right_level_label'], 'user_group_title' => $res_row['user_group_title']));
}
}
......@@ -317,8 +317,8 @@ class tx_nG6_db {
* @param int $total_purgeable_size size of files to purge
* @return New purge id
*/
function add_purge_demand($cruser_id, $project_id, $total_purgeable_size, $all_runs_ids, $all_analyses_ids,$managers_name){
$date= time();
function add_purge_demand($cruser_id, $project_id, $total_purgeable_size, $all_runs_ids, $all_analyses_ids,$user_ids){
$date= time();
$purge_data = array(
'cruser_id' => $cruser_id,
'project_id' => $project_id,
......@@ -336,14 +336,13 @@ class tx_nG6_db {
tx_nG6_db::update_field('tx_nG6_run', $all_runs_ids, array('mail_sent_date','purge_demand_id'),array($date,$purge_demand_id));
tx_nG6_db::update_field('tx_nG6_analyze',$all_analyses_ids,array('mail_sent_date','purge_demand_id'),array($date,$purge_demand_id));
foreach($managers_name as $user_name){
$res= tx_nG6_db::select_user_by_username($user_name);
foreach($user_ids as $a_id){
$purge_data_user = array(
'tstamp' => $date,
'crdate' => $date,
'cruser_id' => $cruser_id,
'purge_demand_id' => $purge_demand_id,
'fe_users_id' => $res['uid']
'fe_users_id' => $a_id
);
$GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_nG6_purge_demand_fe_users', $purge_data_user);
}
......
......@@ -136,33 +136,34 @@ Files impacted of:
$p=tx_nG6_db::select_a_project_retention_data_info($project_id);
#build email list of managers
$users_names=array();
$users_id=array();
$users_emails = array();
foreach ( $p[$project_id]["users"] as $u ){
if (!isset ($users_names[$u["right_level_label"]]) ){
$users_names[$u["right_level_label"]]=Array();
if (!isset ($users_id[$u["right_level_label"]]) ){
$users_id[$u["right_level_label"]]=Array();
$users_emails[$u["right_level_label"]]=Array();
}
$users_names[$u["right_level_label"]][] = $u["user_name"];
$users_id[$u["right_level_label"]][] = $u["user_id"];
$users_emails[$u["right_level_label"]][] = $u["email"];
}
#Warn if mail is sent to several manager
$email_warn="" ;
$purge_email_to="";
$purge_name_to=Array();
$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";
}
$purge_email_to=join(',', $users_emails['manager']);
$purge_name_to=$users_names['manager'];
$purge_user_id_to=$users_id['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']);
$purge_user_id_to=array_merge($users_id['administrator'],$users_id['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";
$email_warn.= " - Members(s): ".join(', ',$users_emails['member']). "\n";
}
//Retrieve purgeable information for email
$run_info=Array();
......@@ -180,7 +181,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,$purge_name_to);
$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_user_id_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