/** Get the build groups */ function GetBuildGroups() { $buildgroups = array(); $query = pdo_query("\n SELECT id FROM buildgroup\n WHERE projectid=" . qnum($this->Id) . " AND\n endtime='1980-01-01 00:00:00'"); add_last_sql_error("Project GetBuildGroups", $this->Id); while ($row = pdo_fetch_array($query)) { $buildgroup = new BuildGroup(); $buildgroup->SetId($row['id']); $buildgroups[] = $buildgroup; } return $buildgroups; }
/** Main function to send email if necessary */ function sendemail($handler, $projectid) { include 'config/config.php'; include_once 'include/common.php'; require_once 'include/pdo.php'; require_once 'models/build.php'; require_once 'models/project.php'; require_once 'models/buildgroup.php'; $Project = new Project(); $Project->Id = $projectid; $Project->Fill(); $sendEmail = null; if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/sendemail.php')) { include_once 'local/sendemail.php'; $sendEmail = new SendEmail(); $sendEmail->SetProjectId($projectid); } // If we shouldn't sent any emails we stop if ($Project->EmailBrokenSubmission == 0) { return; } // If the handler has a buildid (it should), we use it if (isset($handler->BuildId) && $handler->BuildId > 0) { $buildid = $handler->BuildId; } else { // Get the build id $name = $handler->getBuildName(); $stamp = $handler->getBuildStamp(); $sitename = $handler->getSiteName(); $buildid = get_build_id($name, $stamp, $projectid, $sitename); } if ($buildid < 0) { return; } //add_log("Buildid ".$buildid,"sendemail ".$Project->Name,LOG_INFO); // Check if the group as no email $Build = new Build(); $Build->Id = $buildid; $groupid = $Build->GetGroup(); $BuildGroup = new BuildGroup(); $BuildGroup->SetId($groupid); // If we specified no email we stop here if ($BuildGroup->GetSummaryEmail() == 2) { return; } $emailCommitters = $BuildGroup->GetEmailCommitters(); $errors = check_email_errors($buildid, $Project->EmailTestTimingChanged, $Project->TestTimeMaxStatus, !$Project->EmailRedundantFailures); // We have some fixes if ($errors['hasfixes']) { $Build->FillFromId($Build->Id); // Get the list of person who should get the email $lookup_result = lookup_emails_to_send($errors, $buildid, $projectid, $Build->Type, true, $emailCommitters); $userids = $lookup_result['userids']; foreach ($userids as $userid) { $emailtext = array(); $emailtext['nfixes'] = 0; // Check if an email has been sent already for this user foreach ($errors['fixes'] as $fixkey => $nfixes) { if ($nfixes == 0) { continue; } if (!check_email_sent($userid, $buildid, $fixkey)) { $emailtext['category'][$fixkey] = $nfixes; $emailtext['nfixes'] = 1; } } // Send the email if ($emailtext['nfixes'] == 1) { send_email_fix_to_user($userid, $emailtext, $Build, $Project); } } } // No error we return if (!$errors['errors']) { return; } if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/sendemail.php')) { $sendEmail->BuildId = $Build->Id; $sendEmail->Errors = $errors; } // If we should send a summary email if ($BuildGroup->GetSummaryEmail() == 1) { // Send the summary email sendsummaryemail($projectid, $groupid, $errors, $buildid); if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/sendemail.php')) { $sendEmail->SendSummary(); } return; } $Build->FillFromId($Build->Id); // Send build error if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/sendemail.php')) { $sendEmail->SendBuildError(); } // Lookup the list of people who should get the email, both registered // users *and* committers: // $lookup_result = lookup_emails_to_send($errors, $buildid, $projectid, $Build->Type, false, $emailCommitters); // Loop through the *registered* users: // $userids = $lookup_result['userids']; foreach ($userids as $userid) { send_error_email($userid, '', $sendEmail, $errors, $Build, $Project); } // Loop through "other" users, if necessary: // // ...people who committed code, but are *not* registered CDash users, but // only if the 'emailcommitters' field is on for this build group. // if ($emailCommitters) { $committeremails = $lookup_result['committeremails']; foreach ($committeremails as $committeremail) { send_error_email(0, $committeremail, $sendEmail, $errors, $Build, $Project, getHandlerErrorKeyPrefix($handler)); } } }
function rest_put() { global $projectid; if (isset($_GET['buildgroup'])) { // Modify an existing buildgroup. $buildgroup = json_decode($_GET['buildgroup'], true); // Deal with the fact that unchecked checkboxes will not be included // in the above array. if (!array_key_exists('emailcommitters', $buildgroup)) { $buildgroup['emailcommitters'] = 0; } if (!array_key_exists('includesubprojecttotal', $buildgroup)) { $buildgroup['includesubprojecttotal'] = 0; } $BuildGroup = new BuildGroup(); $BuildGroup->SetId(pdo_real_escape_numeric($buildgroup['id'])); $BuildGroup->SetName(pdo_real_escape_string($buildgroup['name'])); $BuildGroup->SetDescription(pdo_real_escape_string($buildgroup['description'])); $BuildGroup->SetSummaryEmail(pdo_real_escape_numeric($buildgroup['summaryemail'])); $BuildGroup->SetEmailCommitters(pdo_real_escape_numeric($buildgroup['emailcommitters'])); $BuildGroup->SetIncludeSubProjectTotal(pdo_real_escape_numeric($buildgroup['includesubprojecttotal'])); $BuildGroup->SetAutoRemoveTimeFrame(pdo_real_escape_numeric($buildgroup['autoremovetimeframe'])); if (!$BuildGroup->Save()) { echo_error('Failed to save BuildGroup'); } return; } }