function send_error_email($userid, $emailaddress, $sendEmail, $errors, $Build, $Project, $prefix = 'none') { include 'config/config.php'; $emailtext = array(); $emailtext['nerror'] = 0; if ($userid != 0) { // For registered users, tune the error array based on user preferences // to make sure he doesn't get emails that are unwanted/unnecessary $UserProject = new UserProject(); $UserProject->UserId = $userid; $UserProject->ProjectId = $Project->Id; $useremailcategory = $UserProject->GetEmailCategory(); } // Check if an email has been sent already for this user foreach ($errors as $errorkey => $nerrors) { if ($nerrors == 0 || $errorkey == 'errors') { continue; } $stop = false; if ($userid != 0) { // If the user doesn't want to get the email switch ($errorkey) { case 'update_errors': if (!check_email_category('update', $useremailcategory)) { $stop = true; } break; case 'configure_errors': if (!check_email_category('configure', $useremailcategory)) { $stop = true; } break; case 'build_errors': if (!check_email_category('error', $useremailcategory)) { $stop = true; } break; case 'build_warnings': if (!check_email_category('warning', $useremailcategory)) { $stop = true; } break; case 'test_errors': if (!check_email_category('test', $useremailcategory)) { $stop = true; } break; case 'dynamicanalysis_errors': if (!check_email_category('dynamicanalysis', $useremailcategory)) { $stop = true; } break; } } else { // For committers, only send emails when the errorkey starts with the // prefix associated with the current handler calling us. // (So stop if the errorkey does not begin with the prefix...) // This minimizes sending out possibly near-duplicate emails to the // same committers... // if (0 !== strpos($errorkey, $prefix)) { $stop = true; } } if ($stop) { continue; } if (0 == $userid || !check_email_sent($userid, $Build->Id, $errorkey)) { $emailtext['summary'][$errorkey] = get_email_summary($Build->Id, $errors, $errorkey, $Project->EmailMaxItems, $Project->EmailMaxChars, $Project->TestTimeMaxStatus, $Project->EmailTestTimingChanged); $emailtext['category'][$errorkey] = $nerrors; $emailtext['nerror'] = 1; } } // Send the email if ($emailtext['nerror'] == 1) { if ($userid != 0) { send_email_to_user($userid, $emailtext, $Build, $Project); if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/sendemail.php')) { $sendEmail->UserId = $userid; $sendEmail->Text = $emailtext; $sendEmail->SendToUser(); } } else { send_email_to_address($emailaddress, $emailtext, $Build, $Project); // // Do we still need a "$sendEmail->" call here even if // there is no UserId...? // } } }
$message = $old_message; } } $count++; } } global $aid; Ecr_Log('security', "SendEmailToUser({$subject}) by AID : {$aid}", ''); global $hlpfile; include 'header.php'; GraphicAdmin($hlpfile); adminhead($f_meta_nom, $f_titre, $adminimg); echo ' <hr />'; if ($pasfin) { echo ' <div class="alert alert-success"><strong>"' . stripslashes($subject) . '"</strong> ' . adm_translate("a été envoyée") . '.</div>'; } else { echo ' <div class="alert alert-danger"><strong>"' . stripslashes($subject) . '"</strong>' . adm_translate("n'a pas été envoyée") . '.</div>'; } adminfoot('', '', '', ''); } switch ($op) { case 'send_email_to_user': send_email_to_user($username, $subject, $message, $all, $groupe, $expediteur); break; case 'email_user': email_user(); break; }