/** Send a summary email */
function sendsummaryemail($projectid, $groupid, $errors, $buildid)
{
include 'config/config.php';
require_once 'models/userproject.php';
require_once 'models/user.php';
require_once 'models/project.php';
require_once 'models/build.php';
require_once 'models/site.php';
$Project = new Project();
$Project->Id = $projectid;
$Project->Fill();
// Check if the email has been sent
$date = '';
// now
list($previousdate, $currentstarttime, $nextdate, $today) = get_dates($date, $Project->NightlyTime);
$dashboarddate = gmdate(FMT_DATE, $currentstarttime);
// If we already have it we return
if (pdo_num_rows(pdo_query("SELECT buildid FROM summaryemail WHERE date='{$dashboarddate}' AND groupid=" . qnum($groupid))) == 1) {
return;
}
// Update the summaryemail table to specify that we have send the email
// We also delete any previous rows from that groupid
pdo_query("DELETE FROM summaryemail WHERE groupid={$groupid}");
pdo_query("INSERT INTO summaryemail (buildid,date,groupid) VALUES ({$buildid},'{$dashboarddate}',{$groupid})");
add_last_sql_error('sendmail');
// If the trigger for SVN/CVS diff is not done yet we specify that the asynchronous trigger should
// send an email
$dailyupdatequery = pdo_query('SELECT status FROM dailyupdate WHERE projectid=' . qnum($projectid) . " AND date='{$dashboarddate}'");
add_last_sql_error('sendmail');
if (pdo_num_rows($dailyupdatequery) == 0) {
return;
}
$dailyupdate_array = pdo_fetch_array($dailyupdatequery);
$dailyupdate_status = $dailyupdate_array['status'];
if ($dailyupdate_status == 0) {
pdo_query("UPDATE dailyupdate SET status='2' WHERE projectid=" . qnum($projectid) . " AND date='{$dashboarddate}'");
return;
}
// Find the current updaters from the night using the dailyupdatefile table
$summaryEmail = '';
$query = 'SELECT ' . qid('user') . '.email,up.emailcategory,' . qid('user') . '.id
FROM ' . qid('user') . ',user2project AS up,user2repository AS ur,
dailyupdate,dailyupdatefile WHERE
up.projectid=' . qnum($projectid) . '
AND up.userid=' . qid('user') . '.id
AND ur.userid=up.userid
AND (ur.projectid=0 OR ur.projectid=' . qnum($projectid) . ")\n AND ur.credential=dailyupdatefile.author\n AND dailyupdatefile.dailyupdateid=dailyupdate.id\n AND dailyupdate.date='{$dashboarddate}'\n AND dailyupdate.projectid=" . qnum($projectid) . '
AND up.emailtype>0
';
$user = pdo_query($query);
add_last_sql_error('sendmail');
// Loop through the users and add them to the email array
while ($user_array = pdo_fetch_array($user)) {
// If the user is already in the list we quit
if (strpos($summaryEmail, $user_array['email']) !== false) {
continue;
}
// If the user doesn't want to receive email
if (!checkEmailPreferences($user_array['emailcategory'], $errors)) {
continue;
}
// Check if the labels are defined for this user
if (!checkEmailLabel($projectid, $user_array['id'], $buildid, $user_array['emailcategory'])) {
continue;
}
if ($summaryEmail != '') {
$summaryEmail .= ', ';
}
$summaryEmail .= $user_array['email'];
}
// Select the users that are part of this build
$authors = pdo_query('SELECT author FROM updatefile AS uf,build2update AS b2u
WHERE b2u.updateid=uf.updateid AND b2u.buildid=' . qnum($buildid));
add_last_sql_error('sendmail');
while ($authors_array = pdo_fetch_array($authors)) {
$author = $authors_array['author'];
if ($author == 'Local User') {
continue;
}
$UserProject = new UserProject();
$UserProject->RepositoryCredential = $author;
$UserProject->ProjectId = $projectid;
if (!$UserProject->FillFromRepositoryCredential()) {
continue;
}
// If the user doesn't want to receive email
if (!checkEmailPreferences($UserProject->EmailCategory, $errors)) {
continue;
}
// Check if the labels are defined for this user
if (!checkEmailLabel($projectid, $UserProject->UserId, $buildid, $UserProject->EmailCategory)) {
continue;
}
// Find the email
$User = new User();
$User->Id = $UserProject->UserId;
$useremail = $User->GetEmail();
// If the user is already in the list we quit
if (strpos($summaryEmail, $useremail) !== false) {
//.........这里部分代码省略.........
$Project = new Project();
$Project->Id = $projectid;
$Project->Fill();
// check if this project has subprojects.
$has_subprojects = $Project->GetNumberOfSubProjects() > 0;
// make sure the user has access to this project
checkUserPolicy(@$_SESSION['cdash']['loginid'], $projectid);
// connect to the database
$db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
pdo_select_db("{$CDASH_DB_NAME}", $db);
// handle optional date argument
@($date = $_GET["date"]);
if ($date != NULL) {
$date = htmlspecialchars(pdo_real_escape_string($date));
}
list($previousdate, $currentstarttime, $nextdate) = get_dates($date, $Project->NightlyTime);
// Date range is currently hardcoded to two weeks in the past.
// This could become a configurable value instead.
$date_range = 14;
// begin .xml that is used to render this page
$xml = begin_XML_for_XSLT();
$xml .= get_cdash_dashboard_xml($projectname, $date);
$projectname = get_project_name($projectid);
$xml .= "<title>CDash Overview : " . $projectname . "</title>";
$xml .= get_cdash_dashboard_xml_by_name($projectname, $date);
$xml .= "<menu>";
$xml .= add_XML_value("previous", "overview.php?project={$projectname}&date={$previousdate}");
$xml .= add_XML_value("current", "overview.php?project={$projectname}");
$xml .= add_XML_value("next", "overview.phpv?project={$projectname}&date={$nextdate}");
$xml .= "</menu>";
$xml .= add_XML_value("hasSubProjects", $has_subprojects);
开发者ID:rpshaw,项目名称:CDash,代码行数:31,代码来源:overview.php
示例12: get_dashboard_JSON
function get_dashboard_JSON($projectname, $date, &$response)
{
include 'config/config.php';
require_once 'include/pdo.php';
$projectid = get_project_id($projectname);
if ($projectid == -1) {
return;
}
$db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}");
if (!$db) {
echo "Error connecting to CDash database server<br>\n";
exit(0);
}
if (!pdo_select_db("{$CDASH_DB_NAME}", $db)) {
echo "Error selecting CDash database<br>\n";
exit(0);
}
$project = pdo_query("SELECT * FROM project WHERE id='{$projectid}'");
if (pdo_num_rows($project) > 0) {
$project_array = pdo_fetch_array($project);
} else {
$project_array = array();
$project_array['cvsurl'] = 'unknown';
$project_array['bugtrackerurl'] = 'unknown';
$project_array['documentationurl'] = 'unknown';
$project_array['homeurl'] = 'unknown';
$project_array['googletracker'] = 'unknown';
$project_array['name'] = $projectname;
$project_array['nightlytime'] = '00:00:00';
}
if (is_null($date)) {
$date = date(FMT_DATE);
}
list($previousdate, $currentstarttime, $nextdate) = get_dates($date, $project_array['nightlytime']);
$response['datetime'] = date('l, F d Y H:i:s', time());
$response['date'] = $date;
$response['unixtimestamp'] = $currentstarttime;
$response['startdate'] = date('l, F d Y H:i:s', $currentstarttime);
$response['vcs'] = make_cdash_url(htmlentities($project_array['cvsurl']));
$response['bugtracker'] = make_cdash_url(htmlentities($project_array['bugtrackerurl']));
$response['googletracker'] = htmlentities($project_array['googletracker']);
$response['documentation'] = make_cdash_url(htmlentities($project_array['documentationurl']));
$response['projectid'] = $projectid;
$response['projectname'] = $project_array['name'];
$response['projectname_encoded'] = urlencode($project_array['name']);
$response['public'] = $project_array['public'];
$response['previousdate'] = $previousdate;
$response['nextdate'] = $nextdate;
$response['logoid'] = getLogoID($projectid);
if (empty($project_array['homeurl'])) {
$response['home'] = 'index.php?project=' . urlencode($project_array['name']);
} else {
$response['home'] = make_cdash_url(htmlentities($project_array['homeurl']));
}
if ($CDASH_USE_LOCAL_DIRECTORY && file_exists('local/models/proProject.php')) {
include_once 'local/models/proProject.php';
$pro = new proProject();
$pro->ProjectId = $projectid;
$response['proedition'] = $pro->GetEdition(1);
}
$userid = 0;
if (isset($_SESSION['cdash']) && isset($_SESSION['cdash']['loginid'])) {
$userid = $_SESSION['cdash']['loginid'];
// Is the user an administrator of this project?
$row = pdo_single_row_query('SELECT role FROM user2project
WHERE userid=' . qnum($userid) . ' AND
projectid=' . qnum($projectid));
$response['projectrole'] = $row[0];
if ($response['projectrole'] > 1) {
$response['user']['admin'] = 1;
}
}
$response['userid'] = $userid;
}
开发者ID:kitware,项目名称:cdash,代码行数:74,代码来源:common.php
示例13: startElement
/** Start element */
public function startElement($parser, $name, $attributes)
{
parent::startElement($parser, $name, $attributes);
if ($this->UploadError) {
return;
}
if ($name == 'SITE') {
$this->Site->Name = $attributes['NAME'];
if (empty($this->Site->Name)) {
$this->Site->Name = '(empty)';
}
$this->Site->Insert();
$siteInformation = new SiteInformation();
$buildInformation = new BuildInformation();
// Fill in the attribute
foreach ($attributes as $key => $value) {
$siteInformation->SetValue($key, $value);
$buildInformation->SetValue($key, $value);
}
$this->Site->SetInformation($siteInformation);
$this->Build->SiteId = $this->Site->Id;
$this->Build->Name = $attributes['BUILDNAME'];
if (empty($this->Build->Name)) {
$this->Build->Name = '(empty)';
}
$this->Build->SetStamp($attributes['BUILDSTAMP']);
$this->Build->Generator = $attributes['GENERATOR'];
$this->Build->Information = $buildInformation;
} elseif ($name == 'UPLOAD') {
// Setting start time and end time is tricky here, since all
// we have is the build stamp. The strategy we take here is:
// Set the start time as late as possible, and set the end time
// as early as possible.
// This way we don't override any existing values for these fields
// when we call UpdateBuild() below.
//
// For end time, we use the start of the testing day.
// For start time, we use either the submit time (now) or
// one second before the start time of the *next* testing day
// (whichever is earlier).
// Yes, this means the build finished before it began.
//
// This associates the build with the correct day if it is only
// an upload. Otherwise we defer to the values set by the
// other handlers.
$row = pdo_single_row_query("SELECT nightlytime FROM project where id='{$this->projectid}'");
$nightly_time = $row['nightlytime'];
$build_date = extract_date_from_buildstamp($this->Build->GetStamp());
list($prev, $nightly_start_time, $next) = get_dates($build_date, $nightly_time);
// If the nightly start time is after noon (server time)
// and this buildstamp is on or after the nightly start time
// then this build belongs to the next testing day.
if (date(FMT_TIME, $nightly_start_time) > '12:00:00') {
$build_timestamp = strtotime($build_date);
$next_timestamp = strtotime($next);
if (strtotime(date(FMT_TIME, $build_timestamp), $next_timestamp) >= strtotime(date(FMT_TIME, $nightly_start_time), $next_timestamp)) {
$nightly_start_time += 3600 * 24;
}
}
$this->Build->EndTime = gmdate(FMT_DATETIME, $nightly_start_time);
$now = time();
$one_second_before_tomorrow = strtotime('+1 day -1 second', $nightly_start_time);
if ($one_second_before_tomorrow < time()) {
$this->Build->StartTime = gmdate(FMT_DATETIME, $one_second_before_tomorrow);
} else {
$this->Build->StartTime = gmdate(FMT_DATETIME, $now);
}
$this->Build->SubmitTime = gmdate(FMT_DATETIME, $now);
$this->Build->ProjectId = $this->projectid;
$this->Build->SetSubProject($this->SubProjectName);
$this->Build->GetIdFromName($this->SubProjectName);
$this->Build->RemoveIfDone();
// If the build doesn't exist we add it
if ($this->Build->Id == 0) {
$this->Build->Append = false;
$this->Build->InsertErrors = false;
add_build($this->Build, $this->scheduleid);
$this->UpdateEndTime = true;
} else {
// Otherwise make sure that the build is up-to-date.
$this->Build->UpdateBuild($this->Build->Id, -1, -1);
}
$GLOBALS['PHP_ERROR_BUILD_ID'] = $this->Build->Id;
} elseif ($name == 'FILE') {
$this->UploadFile = new UploadFile();
$this->UploadFile->Filename = $attributes['FILENAME'];
} elseif ($name == 'CONTENT') {
$fileEncoding = isset($attributes['ENCODING']) ? $attributes['ENCODING'] : 'base64';
if (strcmp($fileEncoding, 'base64') != 0) {
// Only base64 encoding is supported for file upload
add_log("upload_handler: Only 'base64' encoding is supported", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR);
$this->UploadError = true;
return;
}
// Create tmp file
$this->TmpFilename = tempnam($GLOBALS['CDASH_UPLOAD_DIRECTORY'], 'tmp');
// TODO Handle error
if (empty($this->TmpFilename)) {
add_log('Failed to create temporary filename', __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR);
//.........这里部分代码省略.........
请发表评论