function generate_graph($channel) { $filename = make_db_filename($channel); $dates = get_dates($filename); $start_date = $dates['start']['date']; $end_date = $dates['end']['date']; $start = $dates['start_format']; $end = $dates['end_format']; return make_gnuplot_input($start_date, $end_date, $start, $end, $channel, $filename); }
function echo_main_dashboard_JSON($project_instance, $date) { $start = microtime_float(); $noforcelogin = 1; include_once dirname(dirname(dirname(__DIR__))) . '/config/config.php'; require_once 'include/pdo.php'; include 'public/login.php'; include_once 'models/banner.php'; include_once 'models/build.php'; include_once 'models/subproject.php'; $response = array(); $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}"); if (!$db) { $response['error'] = 'Error connecting to CDash database server'; echo json_encode($response); return; } if (!pdo_select_db("{$CDASH_DB_NAME}", $db)) { $response['error'] = 'Error selecting CDash database'; echo json_encode($response); return; } $projectid = $project_instance->Id; $project = pdo_query("SELECT * FROM project WHERE id='{$projectid}'"); if (pdo_num_rows($project) > 0) { $project_array = pdo_fetch_array($project); $projectname = $project_array['name']; if (isset($project_array['testingdataurl']) && $project_array['testingdataurl'] != '') { $testingdataurl = make_cdash_url(htmlentities($project_array['testingdataurl'])); } } else { $response['error'] = "This project doesn't exist. Maybe the URL you are trying to access is wrong."; echo json_encode($response); return; } if (!checkUserPolicy(@$_SESSION['cdash']['loginid'], $project_array['id'], 1)) { $response['requirelogin'] = 1; echo json_encode($response); return; } $response = begin_JSON_response(); $response['title'] = "CDash - {$projectname}"; $response['feed'] = $CDASH_ENABLE_FEED; $response['showcalendar'] = 1; $Banner = new Banner(); $Banner->SetProjectId(0); $text = $Banner->GetText(); $banners = array(); if ($text !== false) { $banners[] = $text; } $Banner->SetProjectId($projectid); $text = $Banner->GetText(); if ($text !== false) { $banners[] = $text; } $response['banners'] = $banners; $site_response = array(); // If parentid is set we need to lookup the date for this build // because it is not specified as a query string parameter. if (isset($_GET['parentid'])) { $parentid = pdo_real_escape_numeric($_GET['parentid']); $parent_build = new Build(); $parent_build->Id = $parentid; $date = $parent_build->GetDate(); $response['parentid'] = $parentid; } else { $response['parentid'] = -1; } list($previousdate, $currentstarttime, $nextdate) = get_dates($date, $project_array['nightlytime']); // Main dashboard section get_dashboard_JSON($projectname, $date, $response); $response['displaylabels'] = $project_array['displaylabels']; $page_id = 'index.php'; $response['childview'] = 0; 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); } if ($currentstarttime > time() && !isset($_GET['parentid'])) { $response['error'] = 'CDash cannot predict the future (yet)'; echo json_encode($response); return; } // Menu definition $response['menu'] = array(); $beginning_timestamp = $currentstarttime; $end_timestamp = $currentstarttime + 3600 * 24; $beginning_UTCDate = gmdate(FMT_DATETIME, $beginning_timestamp); $end_UTCDate = gmdate(FMT_DATETIME, $end_timestamp); if ($project_instance->GetNumberOfSubProjects($end_UTCDate) > 0) { $response['menu']['subprojects'] = 1; } if (isset($_GET['parentid'])) { $page_id = 'indexchildren.php'; $response['childview'] = 1; // When a parentid is specified, we should link to the next build, // not the next day. $previous_buildid = $parent_build->GetPreviousBuildId(); $current_buildid = $parent_build->GetCurrentBuildId(); $next_buildid = $parent_build->GetNextBuildId(); $base_url = 'index.php?project=' . urlencode($projectname); if ($previous_buildid > 0) { $response['menu']['previous'] = "{$base_url}&parentid={$previous_buildid}"; } else { $response['menu']['noprevious'] = '1'; } $response['menu']['current'] = "{$base_url}&parentid={$current_buildid}"; if ($next_buildid > 0) { $response['menu']['next'] = "{$base_url}&parentid={$next_buildid}"; } else { $response['menu']['nonext'] = '1'; } } elseif (!has_next_date($date, $currentstarttime)) { $response['menu']['nonext'] = 1; } // Check if a SubProject parameter was specified. $subproject_name = @$_GET['subproject']; $subprojectid = false; if ($subproject_name) { $SubProject = new SubProject(); $subproject_name = htmlspecialchars(pdo_real_escape_string($subproject_name)); $SubProject->SetName($subproject_name); $SubProject->SetProjectId($projectid); $subprojectid = $SubProject->GetId(); if ($subprojectid) { // Add an extra URL argument for the menu $response['extraurl'] = '&subproject=' . urlencode($subproject_name); $response['subprojectname'] = $subproject_name; $subproject_response = array(); $subproject_response['name'] = $SubProject->GetName(); $dependencies = $SubProject->GetDependencies(); if ($dependencies) { $dependencies_response = array(); foreach ($dependencies as $dependency) { $dependency_response = array(); $DependProject = new SubProject(); $DependProject->SetId($dependency); $dependency_response['name'] = $DependProject->GetName(); $dependency_response['name_encoded'] = urlencode($DependProject->GetName()); $dependency_response['nbuilderror'] = $DependProject->GetNumberOfErrorBuilds($beginning_UTCDate, $end_UTCDate); $dependency_response['nbuildwarning'] = $DependProject->GetNumberOfWarningBuilds($beginning_UTCDate, $end_UTCDate); $dependency_response['nbuildpass'] = $DependProject->GetNumberOfPassingBuilds($beginning_UTCDate, $end_UTCDate); $dependency_response['nconfigureerror'] = $DependProject->GetNumberOfErrorConfigures($beginning_UTCDate, $end_UTCDate); $dependency_response['nconfigurewarning'] = $DependProject->GetNumberOfWarningConfigures($beginning_UTCDate, $end_UTCDate); $dependency_response['nconfigurepass'] = $DependProject->GetNumberOfPassingConfigures($beginning_UTCDate, $end_UTCDate); $dependency_response['ntestpass'] = $DependProject->GetNumberOfPassingTests($beginning_UTCDate, $end_UTCDate); $dependency_response['ntestfail'] = $DependProject->GetNumberOfFailingTests($beginning_UTCDate, $end_UTCDate); $dependency_response['ntestnotrun'] = $DependProject->GetNumberOfNotRunTests($beginning_UTCDate, $end_UTCDate); if (strlen($DependProject->GetLastSubmission()) == 0) { $dependency_response['lastsubmission'] = 'NA'; } else { $dependency_response['lastsubmission'] = $DependProject->GetLastSubmission(); } $dependencies_response[] = $dependency_response; } $subproject_response['dependencies'] = $dependencies_response; } $response['subproject'] = $subproject_response; } else { add_log("SubProject '{$subproject_name}' does not exist", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_WARNING); } } if (isset($testingdataurl)) { $response['testingdataurl'] = $testingdataurl; } // updates $updates_response = array(); $gmdate = gmdate(FMT_DATE, $currentstarttime); $updates_response['url'] = 'viewChanges.php?project=' . urlencode($projectname) . '&date=' . $gmdate; $dailyupdate = pdo_query("SELECT count(ds.dailyupdateid),count(distinct ds.author)\n FROM dailyupdate AS d LEFT JOIN dailyupdatefile AS ds ON (ds.dailyupdateid = d.id)\n WHERE d.date='{$gmdate}' and d.projectid='{$projectid}' GROUP BY ds.dailyupdateid"); if (pdo_num_rows($dailyupdate) > 0) { $dailupdate_array = pdo_fetch_array($dailyupdate); $updates_response['nchanges'] = $dailupdate_array[0]; $updates_response['nauthors'] = $dailupdate_array[1]; } else { $updates_response['nchanges'] = -1; } $updates_response['timestamp'] = date('l, F d Y - H:i T', $currentstarttime); $response['updates'] = $updates_response; // This array is used to track if expected builds are found or not. $received_builds = array(); // Get info about our buildgroups. $buildgroups_response = array(); $buildgroup_result = pdo_query("SELECT bg.id, bg.name, bgp.position FROM buildgroup AS bg\n LEFT JOIN buildgroupposition AS bgp ON (bgp.buildgroupid=bg.id)\n WHERE bg.projectid={$projectid} AND bg.starttime < '{$beginning_UTCDate}' AND\n (bg.endtime > '{$beginning_UTCDate}' OR\n bg.endtime='1980-01-01 00:00:00')"); while ($buildgroup_array = pdo_fetch_array($buildgroup_result)) { $buildgroup_response = array(); $groupname = $buildgroup_array['name']; $buildgroup_response['id'] = $buildgroup_array['id']; $buildgroup_response['name'] = $groupname; $buildgroup_response['linkname'] = str_replace(' ', '_', $groupname); $buildgroup_response['position'] = $buildgroup_array['position']; $buildgroup_response['numupdatedfiles'] = 0; $buildgroup_response['numupdateerror'] = 0; $buildgroup_response['numupdatewarning'] = 0; $buildgroup_response['updateduration'] = 0; $buildgroup_response['configureduration'] = 0; $buildgroup_response['numconfigureerror'] = 0; $buildgroup_response['numconfigurewarning'] = 0; $buildgroup_response['numbuilderror'] = 0; $buildgroup_response['numbuildwarning'] = 0; $buildgroup_response['numtestnotrun'] = 0; $buildgroup_response['numtestfail'] = 0; $buildgroup_response['numtestpass'] = 0; $buildgroup_response['testduration'] = 0; $buildgroup_response['hasupdatedata'] = false; $buildgroup_response['hasconfiguredata'] = false; $buildgroup_response['hascompilationdata'] = false; $buildgroup_response['hastestdata'] = false; $buildgroup_response['hasnormalbuilds'] = false; $buildgroup_response['hasparentbuilds'] = false; $buildgroup_response['builds'] = array(); $received_builds[$groupname] = array(); $buildgroups_response[] = $buildgroup_response; } // Filters: // $filterdata = get_filterdata_from_request($page_id); $filter_sql = $filterdata['sql']; $limit_sql = ''; if ($filterdata['limit'] > 0) { $limit_sql = ' LIMIT ' . $filterdata['limit']; } unset($filterdata['xml']); $response['filterdata'] = $filterdata; $response['filterurl'] = get_filterurl(); // Check if we should be excluding some SubProjects from our // build results. $include_subprojects = false; $exclude_subprojects = false; $included_subprojects = array(); $excluded_subprojects = array(); $selected_subprojects = ''; $num_selected_subprojects = 0; $filter_on_labels = false; $share_label_filters = false; foreach ($filterdata['filters'] as $filter) { if ($filter['field'] == 'subprojects') { if ($filter['compare'] == 92) { $excluded_subprojects[] = $filter['value']; } elseif ($filter['compare'] == 93) { $included_subprojects[] = $filter['value']; } } elseif ($filter['field'] == 'label') { $filter_on_labels = true; } } if ($filter_on_labels && $project_instance->ShareLabelFilters) { $share_label_filters = true; $response['sharelabelfilters'] = true; $label_ids_array = get_label_ids_from_filterdata($filterdata); $label_ids = '(' . implode(', ', $label_ids_array) . ')'; } // Include takes precedence over exclude. if (!empty($included_subprojects)) { $num_selected_subprojects = count($included_subprojects); $selected_subprojects = implode("','", $included_subprojects); $selected_subprojects = "('" . $selected_subprojects . "')"; $include_subprojects = true; } elseif (!empty($excluded_subprojects)) { $num_selected_subprojects = count($excluded_subprojects); $selected_subprojects = implode("','", $excluded_subprojects); $selected_subprojects = "('" . $selected_subprojects . "')"; $exclude_subprojects = true; } // add a request for the subproject $subprojectsql = ''; if ($subproject_name && is_numeric($subprojectid)) { $subprojectsql = ' AND sp2b.subprojectid=' . $subprojectid; } // Use this as the default date clause, but if $filterdata has a date clause, // then cancel this one out: // $date_clause = "AND b.starttime<'{$end_UTCDate}' AND b.starttime>='{$beginning_UTCDate}' "; if ($filterdata['hasdateclause']) { $date_clause = ''; } $parent_clause = ''; if (isset($_GET['parentid'])) { // If we have a parentid, then we should only show children of that build. // Date becomes irrelevant in this case. $parent_clause = 'AND (b.parentid = ' . qnum($_GET['parentid']) . ') '; $date_clause = ''; } elseif (empty($subprojectsql)) { // Only show builds that are not children. $parent_clause = 'AND (b.parentid = -1 OR b.parentid = 0) '; } $build_rows = array(); // If the user is logged in we display if the build has some changes for him $userupdatesql = ''; if (isset($_SESSION['cdash']) && array_key_exists('loginid', $_SESSION['cdash'])) { $userupdatesql = "(SELECT count(updatefile.updateid) FROM updatefile,build2update,user2project,\n user2repository\n WHERE build2update.buildid=b.id\n AND build2update.updateid=updatefile.updateid\n AND user2project.projectid=b.projectid\n AND user2project.userid='" . $_SESSION['cdash']['loginid'] . "'\n AND user2repository.userid=user2project.userid\n AND (user2repository.projectid=0 OR user2repository.projectid=b.projectid)\n AND user2repository.credential=updatefile.author) AS userupdates,"; } $sql = get_index_query(); $sql .= "WHERE b.projectid='{$projectid}' AND g.type='Daily'\n {$parent_clause} {$date_clause} {$subprojectsql} {$filter_sql} {$limit_sql}"; // We shouldn't get any builds for group that have been deleted (otherwise something is wrong) $builds = pdo_query($sql); // Log any errors $pdo_error = pdo_error(); if (strlen($pdo_error) > 0) { add_log('SQL error: ' . $pdo_error, 'Index.php', LOG_ERR); } // Gather up results from this query. $build_data = array(); while ($build_row = pdo_fetch_array($builds)) { $build_data[] = $build_row; } $dynamic_builds = array(); if (empty($filter_sql)) { $dynamic_builds = get_dynamic_builds($projectid, $end_UTCDate); $build_data = array_merge($build_data, $dynamic_builds); } // Check if we need to summarize coverage by subproject groups. // This happens when we have subprojects and we're looking at the children // of a specific build. $coverage_groups = array(); if (isset($_GET['parentid']) && $_GET['parentid'] > 0 && $project_instance->GetNumberOfSubProjects($end_UTCDate) > 0) { $groups = $project_instance->GetSubProjectGroups(); foreach ($groups as $group) { // Keep track of coverage info on a per-group basis. $groupId = $group->GetId(); $coverage_groups[$groupId] = array(); $coverageThreshold = $group->GetCoverageThreshold(); $coverage_groups[$groupId]['thresholdgreen'] = $coverageThreshold; $coverage_groups[$groupId]['thresholdyellow'] = $coverageThreshold * 0.7; $coverage_groups[$groupId]['label'] = $group->GetName(); $coverage_groups[$groupId]['loctested'] = 0; $coverage_groups[$groupId]['locuntested'] = 0; $coverage_groups[$groupId]['position'] = $group->GetPosition(); $coverage_groups[$groupId]['coverages'] = array(); } if (count($groups) > 1) { // Add a Total group too. $coverage_groups[0] = array(); $coverageThreshold = $project_array['coveragethreshold']; $coverage_groups[0]['thresholdgreen'] = $coverageThreshold; $coverage_groups[0]['thresholdyellow'] = $coverageThreshold * 0.7; $coverage_groups[0]['label'] = 'Total'; $coverage_groups[0]['loctested'] = 0; $coverage_groups[0]['locuntested'] = 0; $coverage_groups[0]['position'] = 0; } } // Fetch all the rows of builds into a php array. // Compute additional fields for each row that we'll need to generate the xml. // $build_rows = array(); foreach ($build_data as $build_row) { // Fields that come from the initial query: // id // sitename // stamp // name // siteid // type // generator // starttime // endtime // submittime // groupname // position // groupid // countupdatefiles // updatestatus // countupdatewarnings // countbuildwarnings // countbuilderrors // countbuilderrordiff // countbuildwarningdiff // configureduration // countconfigureerrors // countconfigurewarnings // countconfigurewarningdiff // counttestsnotrun // counttestsnotrundiff // counttestsfailed // counttestsfaileddiff // counttestspassed // counttestspasseddiff // countteststimestatusfailed // countteststimestatusfaileddiff // testduration // // Fields that we add within this loop: // maxstarttime // buildids (array of buildids for summary rows) // countbuildnotes (added by users) // labels // updateduration // countupdateerrors // test // $buildid = $build_row['id']; $groupid = $build_row['groupid']; $siteid = $build_row['siteid']; $parentid = $build_row['parentid']; $build_row['buildids'][] = $buildid; $build_row['maxstarttime'] = $build_row['starttime']; // Updates if (!empty($build_row['updatestarttime'])) { $build_row['updateduration'] = round((strtotime($build_row['updateendtime']) - strtotime($build_row['updatestarttime'])) / 60, 1); } else { $build_row['updateduration'] = 0; } if (strlen($build_row['updatestatus']) > 0 && $build_row['updatestatus'] != '0') { $build_row['countupdateerrors'] = 1; } else { $build_row['countupdateerrors'] = 0; } // Error/Warnings differences if (empty($build_row['countbuilderrordiffp'])) { $build_row['countbuilderrordiffp'] = 0; } if (empty($build_row['countbuilderrordiffn'])) { $build_row['countbuilderrordiffn'] = 0; } if (empty($build_row['countbuildwarningdiffp'])) { $build_row['countbuildwarningdiffp'] = 0; } if (empty($build_row['countbuildwarningdiffn'])) { $build_row['countbuildwarningdiffn'] = 0; } $build_row['hasconfigure'] = 0; if ($build_row['countconfigureerrors'] != -1 || $build_row['countconfigurewarnings'] != -1) { $build_row['hasconfigure'] = 1; } if ($build_row['countconfigureerrors'] < 0) { $build_row['countconfigureerrors'] = 0; } if ($build_row['countconfigurewarnings'] < 0) { $build_row['countconfigurewarnings'] = 0; } if (empty($build_row['countconfigurewarningdiff'])) { $build_row['countconfigurewarningdiff'] = 0; } $build_row['hastest'] = 0; if ($build_row['counttestsfailed'] != -1) { $build_row['hastest'] = 1; } if (empty($build_row['testduration'])) { $time_array = pdo_fetch_array(pdo_query("SELECT SUM(time) FROM build2test WHERE buildid='{$buildid}'")); $build_row['testduration'] = round($time_array[0], 1); } else { $build_row['testduration'] = round($build_row['testduration'], 1); } $build_rows[] = $build_row; } // Generate the JSON response from the rows of builds. $response['coverages'] = array(); $response['dynamicanalyses'] = array(); $num_nightly_coverages_builds = 0; $show_aggregate = false; $response['comparecoverage'] = 0; foreach ($build_rows as $build_array) { $groupid = $build_array['groupid']; // Find the buildgroup array for this build. $i = -1; for ($j = 0; $j < count($buildgroups_response); $j++) { if ($buildgroups_response[$j]['id'] == $groupid) { $i = $j; break; } } if ($i == -1) { add_log("BuildGroup '{$groupid}' not found for build #" . $build_array['id'], __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_WARNING); continue; } $groupname = $buildgroups_response[$i]['name']; $build_response = array(); $received_builds[$groupname][] = $build_array['sitename'] . '_' . $build_array['name']; $buildid = $build_array['id']; $siteid = $build_array['siteid']; $countChildrenResult = pdo_single_row_query('SELECT count(id) AS numchildren FROM build WHERE parentid=' . qnum($buildid)); $numchildren = $countChildrenResult['numchildren']; $build_response['numchildren'] = $numchildren; $child_builds_hyperlink = ''; $selected_configure_errors = 0; $selected_configure_warnings = 0; $selected_configure_duration = 0; $selected_build_errors = 0; $selected_build_warnings = 0; $selected_build_duration = 0; $selected_tests_not_run = 0; $selected_tests_failed = 0; $selected_tests_passed = 0; $selected_test_duration = 0; if ($numchildren > 0) { $child_builds_hyperlink = get_child_builds_hyperlink($build_array['id'], $filterdata); $build_response['multiplebuildshyperlink'] = $child_builds_hyperlink; $buildgroups_response[$i]['hasparentbuilds'] = true; // Compute selected (excluded or included) SubProject results. if ($selected_subprojects) { $select_query = "\n SELECT configureerrors, configurewarnings, configureduration,\n builderrors, buildwarnings, buildduration,\n b.starttime, b.endtime, testnotrun, testfailed, testpassed,\n btt.time AS testduration, sb.name\n FROM build AS b\n INNER JOIN subproject2build AS sb2b ON (b.id = sb2b.buildid)\n INNER JOIN subproject AS sb ON (sb2b.subprojectid = sb.id)\n LEFT JOIN buildtesttime AS btt ON (b.id=btt.buildid)\n WHERE b.parentid={$buildid}\n AND sb.name IN {$selected_subprojects}"; $select_results = pdo_query($select_query); while ($select_array = pdo_fetch_array($select_results)) { $selected_configure_errors += max(0, $select_array['configureerrors']); $selected_configure_warnings += max(0, $select_array['configurewarnings']); $selected_configure_duration += max(0, $select_array['configureduration']); $selected_build_errors += max(0, $select_array['builderrors']); $selected_build_warnings += max(0, $select_array['buildwarnings']); $selected_build_duration += max(0, $select_array['buildduration']); $selected_tests_not_run += max(0, $select_array['testnotrun']); $selected_tests_failed += max(0, $select_array['testfailed']); $selected_tests_passed += max(0, $select_array['testpassed']); $selected_test_duration += max(0, $select_array['testduration']); } } } else { $buildgroups_response[$i]['hasnormalbuilds'] = true; } if (strtolower($build_array['type']) == 'continuous') { $buildgroups_response[$i]['sorttype'] = 'time'; } // Attempt to determine the platform based on the OSName and the buildname $buildplatform = ''; if (strtolower(substr($build_array['osname'], 0, 7)) == 'windows') { $buildplatform = 'windows'; } elseif (strtolower(substr($build_array['osname'], 0, 8)) == 'mac os x') { $buildplatform = 'mac'; } elseif (strtolower(substr($build_array['osname'], 0, 5)) == 'linux' || strtolower(substr($build_array['osname'], 0, 3)) == 'aix') { $buildplatform = 'linux'; } elseif (strtolower(substr($build_array['osname'], 0, 7)) == 'freebsd') { $buildplatform = 'freebsd'; } elseif (strtolower(substr($build_array['osname'], 0, 3)) == 'gnu') { $buildplatform = 'gnu'; } // Add link based on changeid if appropriate. $changelink = null; $changeicon = null; if ($build_array['changeid'] && $project_instance->CvsViewerType === 'github') { $changelink = $project_instance->CvsUrl . '/pull/' . $build_array['changeid']; $changeicon = 'img/Octocat.png'; } if (isset($_GET['parentid'])) { if (empty($site_response)) { $site_response['site'] = $build_array['sitename']; $site_response['siteoutoforder'] = $build_array['siteoutoforder']; $site_response['siteid'] = $siteid; $site_response['buildname'] = $build_array['name']; $site_response['buildplatform'] = $buildplatform; $site_response['generator'] = $build_array['generator']; if (!is_null($changelink)) { $site_response['changelink'] = $changelink; $site_response['changeicon'] = $changeicon; } } } else { $build_response['site'] = $build_array['sitename']; $build_response['siteoutoforder'] = $build_array['siteoutoforder']; $build_response['siteid'] = $siteid; $build_response['buildname'] = $build_array['name']; $build_response['buildplatform'] = $buildplatform; if (!is_null($changelink)) { $build_response['changelink'] = $changelink; $build_response['changeicon'] = $changeicon; } } if (isset($build_array['userupdates'])) { $build_response['userupdates'] = $build_array['userupdates']; } $build_response['id'] = $build_array['id']; $build_response['done'] = $build_array['done']; $build_response['uploadfilecount'] = $build_array['builduploadfiles']; $build_response['buildnotes'] = $build_array['countbuildnotes']; $build_response['notes'] = $build_array['countnotes']; // Figure out how many labels to report for this build. if (!array_key_exists('numlabels', $build_array) || $build_array['numlabels'] == 0) { $num_labels = 0; } else { $num_labels = $build_array['numlabels']; } $label_query = 'SELECT l.text FROM label AS l INNER JOIN label2build AS l2b ON (l.id=l2b.labelid) INNER JOIN build AS b ON (l2b.buildid=b.id) WHERE b.id=' . qnum($buildid); $build_labels = array(); if ($num_selected_subprojects > 0) { // Special handling for whitelisting/blacklisting SubProjects. if ($include_subprojects) { $num_labels = 0; } $labels_result = pdo_query($label_query); while ($label_row = pdo_fetch_array($labels_result)) { // Whitelist case if ($include_subprojects && in_array($label_row['text'], $included_subprojects)) { $num_labels++; $build_labels[] = $label_row['text']; } // Blacklist case if ($exclude_subprojects) { if (in_array($label_row['text'], $excluded_subprojects)) { $num_labels--; } else { $build_labels[] = $label_row['text']; } } } if ($num_labels === 0) { // Skip this build entirely if none of its SubProjects // survived filtering. continue; } } // Assign a label to this build based on how many labels it has. if ($num_labels == 0) { $build_label = '(none)'; } elseif ($num_labels == 1) { // Exactly one label for this build if (!empty($build_labels)) { // If we're whitelisting or blacklisting we've already figured // out what this label is. $build_label = $build_labels[0]; } else { // Otherwise we look it up here. $label_result = pdo_single_row_query($label_query); $build_label = $label_result['text']; } } else { // More than one label, just report the number. $build_label = "({$num_labels} labels)"; } $build_response['label'] = $build_label; // Calculate this build's total duration. $duration = strtotime($build_array['endtime']) - strtotime($build_array['starttime']); $build_response['time'] = time_difference($duration, true); $build_response['timefull'] = $duration; $update_response = array(); $countupdatefiles = $build_array['countupdatefiles']; $update_response['files'] = $countupdatefiles; $buildgroups_response[$i]['numupdatedfiles'] += $countupdatefiles; $build_response['hasupdate'] = false; if (!empty($build_array['updatestarttime'])) { $build_response['hasupdate'] = true; if ($build_array['countupdateerrors'] > 0) { $update_response['errors'] = 1; $buildgroups_response[$i]['numupdateerror'] += 1; } else { $update_response['errors'] = 0; if ($build_array['countupdatewarnings'] > 0) { $update_response['warning'] = 1; $buildgroups_response[$i]['numupdatewarning'] += 1; } } $duration = $build_array['updateduration']; $update_response['time'] = time_difference($duration * 60.0, true); $update_response['timefull'] = $duration; $buildgroups_response[$i]['updateduration'] += $duration; $buildgroups_response[$i]['hasupdatedata'] = true; $build_response['update'] = $update_response; } $compilation_response = array(); if ($build_array['countbuilderrors'] >= 0) { if ($include_subprojects) { $nerrors = $selected_build_errors; $nwarnings = $selected_build_warnings; $buildduration = $selected_build_duration; } else { $nerrors = $build_array['countbuilderrors'] - $selected_build_errors; $nwarnings = $build_array['countbuildwarnings'] - $selected_build_warnings; $buildduration = $build_array['buildduration'] - $selected_build_duration; } $compilation_response['error'] = $nerrors; $buildgroups_response[$i]['numbuilderror'] += $nerrors; $compilation_response['warning'] = $nwarnings; $buildgroups_response[$i]['numbuildwarning'] += $nwarnings; $compilation_response['time'] = time_difference($buildduration, true); $compilation_response['timefull'] = $buildduration; if (!$include_subprojects && !$exclude_subprojects) { // Don't show diff when filtering by SubProject. $compilation_response['nerrordiffp'] = $build_array['countbuilderrordiffp']; $compilation_response['nerrordiffn'] = $build_array['countbuilderrordiffn']; $compilation_response['nwarningdiffp'] = $build_array['countbuildwarningdiffp']; $compilation_response['nwarningdiffn'] = $build_array['countbuildwarningdiffn']; } } $build_response['hascompilation'] = false; if (!empty($compilation_response)) { $build_response['hascompilation'] = true; $build_response['compilation'] = $compilation_response; $buildgroups_response[$i]['hascompilationdata'] = true; } $build_response['hasconfigure'] = false; if ($build_array['hasconfigure'] != 0) { $build_response['hasconfigure'] = true; $configure_response = array(); if ($include_subprojects) { $nconfigureerrors = $selected_configure_errors; $nconfigurewarnings = $selected_configure_warnings; $configureduration = $selected_configure_duration; } else { $nconfigureerrors = $build_array['countconfigureerrors'] - $selected_configure_errors; $nconfigurewarnings = $build_array['countconfigurewarnings'] - $selected_configure_warnings; $configureduration = $build_array['configureduration'] - $selected_configure_duration; } $configure_response['error'] = $nconfigureerrors; $buildgroups_response[$i]['numconfigureerror'] += $nconfigureerrors; $configure_response['warning'] = $nconfigurewarnings; $buildgroups_response[$i]['numconfigurewarning'] += $nconfigurewarnings; if (!$include_subprojects && !$exclude_subprojects) { $configure_response['warningdiff'] = $build_array['countconfigurewarningdiff']; } $configure_response['time'] = time_difference($configureduration, true); $configure_response['timefull'] = $configureduration; $build_response['configure'] = $configure_response; $buildgroups_response[$i]['hasconfiguredata'] = true; $buildgroups_response[$i]['configureduration'] += $configureduration; } $build_response['hastest'] = false; if ($build_array['hastest'] != 0) { $build_response['hastest'] = true; $buildgroups_response[$i]['hastestdata'] = true; $test_response = array(); if ($include_subprojects) { $nnotrun = $selected_tests_not_run; $nfail = $selected_tests_failed; $npass = $selected_tests_passed; $testduration = $selected_test_duration; } else { $nnotrun = $build_array['counttestsnotrun'] - $selected_tests_not_run; $nfail = $build_array['counttestsfailed'] - $selected_tests_failed; $npass = $build_array['counttestspassed'] - $selected_tests_passed; $testduration = $build_array['testduration'] - $selected_test_duration; } if (!$include_subprojects && !$exclude_subprojects) { $test_response['nnotrundiffp'] = $build_array['counttestsnotrundiffp']; $test_response['nnotrundiffn'] = $build_array['counttestsnotrundiffn']; $test_response['nfaildiffp'] = $build_array['counttestsfaileddiffp']; $test_response['nfaildiffn'] = $build_array['counttestsfaileddiffn']; $test_response['npassdiffp'] = $build_array['counttestspasseddiffp']; $test_response['npassdiffn'] = $build_array['counttestspasseddiffn']; } if ($project_array['showtesttime'] == 1) { $test_response['timestatus'] = $build_array['countteststimestatusfailed']; $test_response['ntimediffp'] = $build_array['countteststimestatusfaileddiffp']; $test_response['ntimediffn'] = $build_array['countteststimestatusfaileddiffn']; } if ($share_label_filters) { $label_query_base = "SELECT b2t.status, b2t.newstatus\n FROM build2test AS b2t\n INNER JOIN label2test AS l2t ON\n (l2t.testid=b2t.testid AND l2t.buildid=b2t.buildid)\n WHERE b2t.buildid = '{$buildid}' AND\n l2t.labelid IN {$label_ids}"; $label_filter_query = $label_query_base . $limit_sql; $labels_result = pdo_query($label_filter_query); $nnotrun = 0; $nfail = 0; $npass = 0; $test_response['nfaildiffp'] = 0; $test_response['nfaildiffn'] = 0; $test_response['npassdiffp'] = 0; $test_response['npassdiffn'] = 0; $test_response['nnotrundiffp'] = 0; $test_response['nnotrundiffn'] = 0; while ($label_row = pdo_fetch_array($labels_result)) { switch ($label_row['status']) { case 'passed': $npass++; if ($label_row['newstatus'] == 1) { $test_response['npassdiffp']++; } break; case 'failed': $nfail++; if ($label_row['newstatus'] == 1) { $test_response['nfaildiffp']++; } break; case 'notrun': $nnotrun++; if ($label_row['newstatus'] == 1) { $test_response['nnotrundiffp']++; } break; } } } $test_response['notrun'] = $nnotrun; $test_response['fail'] = $nfail; $test_response['pass'] = $npass; $buildgroups_response[$i]['numtestnotrun'] += $nnotrun; $buildgroups_response[$i]['numtestfail'] += $nfail; $buildgroups_response[$i]['numtestpass'] += $npass; $test_response['time'] = time_difference($testduration, true); $test_response['timefull'] = $testduration; $buildgroups_response[$i]['testduration'] += $testduration; $build_response['test'] = $test_response; } $starttimestamp = strtotime($build_array['starttime'] . ' UTC'); $submittimestamp = strtotime($build_array['submittime'] . ' UTC'); // Use the default timezone. $build_response['builddatefull'] = $starttimestamp; // If the data is more than 24h old then we switch from an elapsed to a normal representation if (time() - $starttimestamp < 86400) { $build_response['builddate'] = date(FMT_DATETIMEDISPLAY, $starttimestamp); $build_response['builddateelapsed'] = time_difference(time() - $starttimestamp, false, 'ago'); } else { $build_response['builddateelapsed'] = date(FMT_DATETIMEDISPLAY, $starttimestamp); $build_response['builddate'] = time_difference(time() - $starttimestamp, false, 'ago'); } $build_response['submitdate'] = date(FMT_DATETIMEDISPLAY, $submittimestamp); // Generate a string summarizing this build's timing. $timesummary = $build_response['builddate']; if ($build_response['hasupdate'] && array_key_exists('time', $build_response['update'])) { $timesummary .= ', Update time: ' . $build_response['update']['time']; } if ($build_response['hasconfigure'] && array_key_exists('time', $build_response['configure'])) { $timesummary .= ', Configure time: ' . $build_response['configure']['time']; } if ($build_response['hascompilation'] && array_key_exists('time', $build_response['compilation'])) { $timesummary .= ', Build time: ' . $build_response['compilation']['time']; } if ($build_response['hastest'] && array_key_exists('time', $build_response['test'])) { $timesummary .= ', Test time: ' . $build_response['test']['time']; } $timesummary .= ', Total time: ' . $build_response['time']; $build_response['timesummary'] = $timesummary; if ($include_subprojects || $exclude_subprojects) { // Check if this build should be filtered out now that its // numbers have been updated by the SubProject include/exclude // filter. if (!build_survives_filter($build_response, $filterdata)) { continue; } } if ($build_array['name'] != 'Aggregate Coverage') { $buildgroups_response[$i]['builds'][] = $build_response; } // Coverage // // Determine if this is a parent build with no actual coverage of its own. $linkToChildCoverage = false; if ($numchildren > 0) { $countChildrenResult = pdo_single_row_query('SELECT count(fileid) AS nfiles FROM coverage WHERE buildid=' . qnum($buildid)); if ($countChildrenResult['nfiles'] == 0) { $linkToChildCoverage = true; } } $coverageIsGrouped = false; $loctested = $build_array['loctested']; $locuntested = $build_array['locuntested']; if ($loctested + $locuntested > 0) { $coverage_response = array(); $coverage_response['buildid'] = $build_array['id']; if ($linkToChildCoverage) { $coverage_response['childlink'] = "{$child_builds_hyperlink}##Coverage"; } if ($build_array['type'] === 'Nightly' && $build_array['name'] !== 'Aggregate Coverage') { $num_nightly_coverages_builds++; if ($num_nightly_coverages_builds > 1) { $show_aggregate = true; if ($linkToChildCoverage) { $response['comparecoverage'] = 1; } } } $percent = round(compute_percentcoverage($loctested, $locuntested), 2); if ($build_array['subprojectgroup']) { $groupId = $build_array['subprojectgroup']; if (array_key_exists($groupId, $coverage_groups)) { $coverageIsGrouped = true; $coverageThreshold = $coverage_groups[$groupId]['thresholdgreen']; $coverage_groups[$groupId]['loctested'] += $loctested; $coverage_groups[$groupId]['locuntested'] += $locuntested; if (count($coverage_groups) > 1) { // Add to Total. $coverage_groups[0]['loctested'] += $loctested; $coverage_groups[0]['locuntested'] += $locuntested; } } } $coverage_response['percentage'] = $percent; $coverage_response['locuntested'] = intval($locuntested); $coverage_response['loctested'] = intval($loctested); // Compute the diff if (!empty($build_array['loctesteddiff'])) { $loctesteddiff = $build_array['loctesteddiff']; $locuntesteddiff = $build_array['locuntesteddiff']; @($previouspercent = round(($loctested - $loctesteddiff) / ($loctested - $loctesteddiff + $locuntested - $locuntesteddiff) * 100, 2)); $percentdiff = round($percent - $previouspercent, 2); $coverage_response['percentagediff'] = $percentdiff; $coverage_response['locuntesteddiff'] = $locuntesteddiff; $coverage_response['loctesteddiff'] = $loctesteddiff; } $starttimestamp = strtotime($build_array['starttime'] . ' UTC'); $coverage_response['datefull'] = $starttimestamp; // If the data is more than 24h old then we switch from an elapsed to a normal representation if (time() - $starttimestamp < 86400) { $coverage_response['date'] = date(FMT_DATETIMEDISPLAY, $starttimestamp); $coverage_response['dateelapsed'] = time_difference(time() - $starttimestamp, false, 'ago'); } else { $coverage_response['dateelapsed'] = date(FMT_DATETIMEDISPLAY, $starttimestamp); $coverage_response['date'] = time_difference(time() - $starttimestamp, false, 'ago'); } // Are there labels for this build? // $coverage_response['label'] = $build_label; if ($coverageIsGrouped) { $coverage_groups[$groupId]['coverages'][] = $coverage_response; } else { $coverage_response['site'] = $build_array['sitename']; $coverage_response['buildname'] = $build_array['name']; $response['coverages'][] = $coverage_response; } } if (!$coverageIsGrouped) { $coverageThreshold = $project_array['coveragethreshold']; $response['thresholdgreen'] = $coverageThreshold; $response['thresholdyellow'] = $coverageThreshold * 0.7; } // Dynamic Analysis // if (!empty($build_array['checker'])) { // Determine if this is a parent build with no dynamic analysis // of its own. $linkToChildren = false; if ($numchildren > 0) { $countChildrenResult = pdo_single_row_query('SELECT count(id) AS num FROM dynamicanalysis WHERE buildid=' . qnum($build_array['id'])); if ($countChildrenResult['num'] == 0) { $linkToChildren = true; } } $DA_response = array(); $DA_response['site'] = $build_array['sitename']; $DA_response['buildname'] = $build_array['name']; $DA_response['buildid'] = $build_array['id']; $DA_response['checker'] = $build_array['checker']; $DA_response['defectcount'] = $build_array['numdefects']; $starttimestamp = strtotime($build_array['starttime'] . ' UTC'); $DA_response['datefull'] = $starttimestamp; if ($linkToChildren) { $DA_response['childlink'] = "{$child_builds_hyperlink}##DynamicAnalysis"; } // If the data is more than 24h old then we switch from an elapsed to a normal representation if (time() - $starttimestamp < 86400) { $DA_response['date'] = date(FMT_DATETIMEDISPLAY, $starttimestamp); $DA_response['dateelapsed'] = time_difference(time() - $starttimestamp, false, 'ago'); } else { $DA_response['dateelapsed'] = date(FMT_DATETIMEDISPLAY, $starttimestamp); $DA_response['date'] = time_difference(time() - $starttimestamp, false, 'ago'); } // Are there labels for this build? // $DA_response['label'] = $build_label; $response['dynamicanalyses'][] = $DA_response; } } // Put some finishing touches on our buildgroups now that we're done // iterating over all the builds. $addExpected = empty($filter_sql) && pdo_num_rows($builds) + count($dynamic_builds) > 0; for ($i = 0; $i < count($buildgroups_response); $i++) { $buildgroups_response[$i]['testduration'] = time_difference($buildgroups_response[$i]['testduration'], true); $num_expected_builds = 0; if (!$filter_sql) { $groupname = $buildgroups_response[$i]['name']; $expected_builds = add_expected_builds($buildgroups_response[$i]['id'], $currentstarttime, $received_builds[$groupname]); if (is_array($expected_builds)) { $num_expected_builds = count($expected_builds); $buildgroups_response[$i]['builds'] = array_merge($buildgroups_response[$i]['builds'], $expected_builds); } } // Show how many builds this group has. $num_builds = count($buildgroups_response[$i]['builds']); $num_builds_label = ''; if ($num_expected_builds > 0) { $num_actual_builds = $num_builds - $num_expected_builds; $num_builds_label = "{$num_actual_builds} of {$num_builds} builds"; } else { if ($num_builds === 1) { $num_builds_label = '1 build'; } else { $num_builds_label = "{$num_builds} builds"; } } $buildgroups_response[$i]['numbuildslabel'] = $num_builds_label; } // Create a separate "all buildgroups" section of our response. // This is used to allow project admins to move builds between groups. $response['all_buildgroups'] = array(); foreach ($buildgroups_response as $group) { $response['all_buildgroups'][] = array('id' => $group['id'], 'name' => $group['name']); } // At this point it is safe to remove any empty buildgroups from our response. function is_buildgroup_nonempty($group) { return !empty($group['builds']); } $buildgroups_response = array_filter($buildgroups_response, 'is_buildgroup_nonempty'); // Report buildgroups as a list, not an associative array. // Otherwise any missing buildgroups will cause our view to // not honor the order specified by the project admins. $buildgroups_response = array_values($buildgroups_response); // Remove Aggregate Coverage if it should not be displayed. if (!$show_aggregate) { for ($i = 0; $i < count($response['coverages']); $i++) { if ($response['coverages'][$i]['buildname'] === 'Aggregate Coverage') { unset($response['coverages'][$i]); } } $response['coverages'] = array_values($response['coverages']); } if ($response['childview'] == 1) { // Report number of children. if (!empty($buildgroups_response)) { $numchildren = count($buildgroups_response[0]['builds']); } else { $row = pdo_single_row_query('SELECT count(id) AS numchildren FROM build WHERE parentid=' . qnum($parentid)); $numchildren = $row['numchildren']; } $response['numchildren'] = $numchildren; } // Generate coverage by group here. if (!empty($coverage_groups)) { $response['coveragegroups'] = array(); foreach ($coverage_groups as $groupid => $group) { $loctested = $group['loctested']; $locuntested = $group['locuntested']; if ($loctested == 0 && $locuntested == 0) { continue; } $percentage = round($loctested / ($loctested + $locuntested) * 100, 2); $group['percentage'] = $percentage; $group['id'] = $groupid; $response['coveragegroups'][] = $group; } } $response['buildgroups'] = $buildgroups_response; $response['enableTestTiming'] = $project_array['showtesttime']; $end = microtime_float(); $response['generationtime'] = round($end - $start, 3); if (!empty($site_response)) { $response = array_merge($response, $site_response); } echo json_encode(cast_data_for_JSON($response)); }
echo "This project doesn't exist."; exit; } $project_array = pdo_fetch_array($project); $projectname = $project_array["name"]; $role = 0; $user2project = pdo_query("SELECT role FROM user2project WHERE userid='{$userid}' AND projectid='{$projectid}'"); if (pdo_num_rows($user2project) > 0) { $user2project_array = pdo_fetch_array($user2project); $role = $user2project_array["role"]; } if (!$project_array["showcoveragecode"] && $role < 2) { echo "This project doesn't allow display of coverage code. Contact the administrator of the project."; exit; } list($previousdate, $currenttime, $nextdate) = get_dates($date, $project_array["nightlytime"]); $logoid = getLogoID($projectid); $xml = begin_XML_for_XSLT(); $xml .= "<title>CDash : " . $projectname . "</title>"; $xml .= get_cdash_dashboard_xml_by_name($projectname, $date); // Build $xml .= "<build>"; $build = pdo_query("SELECT * FROM build WHERE id='{$buildid}'"); $build_array = pdo_fetch_array($build); $siteid = $build_array["siteid"]; $site_array = pdo_fetch_array(pdo_query("SELECT name FROM site WHERE id='{$siteid}'")); $xml .= add_XML_value("site", $site_array["name"]); $xml .= add_XML_value("buildname", $build_array["name"]); $xml .= add_XML_value("buildid", $build_array["id"]); $xml .= add_XML_value("buildtime", $build_array["starttime"]); $xml .= "</build>";
/** Generate the subprojects dashboard */ function generate_subprojects_dashboard_XML($project_instance, $date) { $start = microtime_float(); $noforcelogin = 1; include_once "cdash/config.php"; require_once "cdash/pdo.php"; include 'login.php'; include_once "models/banner.php"; include_once "models/subproject.php"; $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}"); if (!$db) { echo "Error connecting to CDash database server<br>\n"; return; } if (!pdo_select_db("{$CDASH_DB_NAME}", $db)) { echo "Error selecting CDash database<br>\n"; return; } $Project = $project_instance; $projectid = $project_instance->Id; $homeurl = make_cdash_url(htmlentities($Project->HomeUrl)); checkUserPolicy(@$_SESSION['cdash']['loginid'], $projectid); $xml = begin_XML_for_XSLT(); $xml .= "<title>CDash - " . $Project->Name . "</title>"; $Banner = new Banner(); $Banner->SetProjectId(0); $text = $Banner->GetText(); if ($text !== false) { $xml .= "<banner>"; $xml .= add_XML_value("text", $text); $xml .= "</banner>"; } $Banner->SetProjectId($projectid); $text = $Banner->GetText(); if ($text !== false) { $xml .= "<banner>"; $xml .= add_XML_value("text", $text); $xml .= "</banner>"; } global $CDASH_SHOW_LAST_SUBMISSION; if ($CDASH_SHOW_LAST_SUBMISSION) { $xml .= "<showlastsubmission>1</showlastsubmission>"; } list($previousdate, $currentstarttime, $nextdate) = get_dates($date, $Project->NightlyTime); $svnurl = make_cdash_url(htmlentities($Project->CvsUrl)); $homeurl = make_cdash_url(htmlentities($Project->HomeUrl)); $bugurl = make_cdash_url(htmlentities($Project->BugTrackerUrl)); $googletracker = htmlentities($Project->GoogleTracker); $docurl = make_cdash_url(htmlentities($Project->DocumentationUrl)); // Main dashboard section $xml .= "<dashboard>\n <datetime>" . date("l, F d Y H:i:s T", time()) . "</datetime>\n <date>" . $date . "</date>\n <unixtimestamp>" . $currentstarttime . "</unixtimestamp>\n <svn>" . $svnurl . "</svn>\n <bugtracker>" . $bugurl . "</bugtracker>\n <googletracker>" . $googletracker . "</googletracker>\n <documentation>" . $docurl . "</documentation>\n <logoid>" . $Project->getLogoID() . "</logoid>\n <projectid>" . $projectid . "</projectid>\n <projectname>" . $Project->Name . "</projectname>\n <projectname_encoded>" . urlencode($Project->Name) . "</projectname_encoded>\n <previousdate>" . $previousdate . "</previousdate>\n <projectpublic>" . $Project->Public . "</projectpublic>\n <nextdate>" . $nextdate . "</nextdate>"; if (empty($Project->HomeUrl)) { $xml .= "<home>index.php?project=" . urlencode($Project->Name) . "</home>"; } else { $xml .= "<home>" . $homeurl . "</home>"; } if ($CDASH_USE_LOCAL_DIRECTORY && file_exists("local/models/proProject.php")) { include_once "local/models/proProject.php"; $pro = new proProject(); $pro->ProjectId = $projectid; $xml .= "<proedition>" . $pro->GetEdition(1) . "</proedition>"; } if ($currentstarttime > time()) { $xml .= "<future>1</future>"; } else { $xml .= "<future>0</future>"; } $xml .= "</dashboard>"; // Menu definition $xml .= "<menu>"; if (!has_next_date($date, $currentstarttime)) { $xml .= add_XML_value("nonext", "1"); } $xml .= "</menu>"; $beginning_timestamp = $currentstarttime; $end_timestamp = $currentstarttime + 3600 * 24; $beginning_UTCDate = gmdate(FMT_DATETIME, $beginning_timestamp); $end_UTCDate = gmdate(FMT_DATETIME, $end_timestamp); // User if (isset($_SESSION['cdash'])) { $xml .= "<user>"; $userid = $_SESSION['cdash']['loginid']; $user2project = pdo_query("SELECT role FROM user2project WHERE userid='{$userid}' and projectid='{$projectid}'"); $user2project_array = pdo_fetch_array($user2project); $user = pdo_query("SELECT admin FROM " . qid("user") . " WHERE id='{$userid}'"); $user_array = pdo_fetch_array($user); $xml .= add_XML_value("id", $userid); $isadmin = 0; if ($user2project_array["role"] > 1 || $user_array["admin"]) { $isadmin = 1; } $xml .= add_XML_value("admin", $isadmin); $xml .= add_XML_value("projectrole", $user2project_array['role']); $xml .= "</user>"; } // Get some information about the project $xml .= "<project>"; $xml .= add_XML_value("nbuilderror", $Project->GetNumberOfErrorBuilds($beginning_UTCDate, $end_UTCDate, true)); $xml .= add_XML_value("nbuildwarning", $Project->GetNumberOfWarningBuilds($beginning_UTCDate, $end_UTCDate, true)); $xml .= add_XML_value("nbuildpass", $Project->GetNumberOfPassingBuilds($beginning_UTCDate, $end_UTCDate, true)); $xml .= add_XML_value("nconfigureerror", $Project->GetNumberOfErrorConfigures($beginning_UTCDate, $end_UTCDate, true)); $xml .= add_XML_value("nconfigurewarning", $Project->GetNumberOfWarningConfigures($beginning_UTCDate, $end_UTCDate, true)); $xml .= add_XML_value("nconfigurepass", $Project->GetNumberOfPassingConfigures($beginning_UTCDate, $end_UTCDate, true)); $xml .= add_XML_value("ntestpass", $Project->GetNumberOfPassingTests($beginning_UTCDate, $end_UTCDate, true)); $xml .= add_XML_value("ntestfail", $Project->GetNumberOfFailingTests($beginning_UTCDate, $end_UTCDate, true)); $xml .= add_XML_value("ntestnotrun", $Project->GetNumberOfNotRunTests($beginning_UTCDate, $end_UTCDate, true)); if (strlen($Project->GetLastSubmission()) == 0) { $xml .= add_XML_value("lastsubmission", "NA"); } else { $xml .= add_XML_value("lastsubmission", $Project->GetLastSubmission()); } $xml .= "</project>"; // Look for the subproject $row = 0; $subprojectids = $Project->GetSubProjects(); $subprojProp = array(); foreach ($subprojectids as $subprojectid) { $SubProject = new SubProject(); $SubProject->SetId($subprojectid); $subprojProp[$subprojectid] = array('name' => $SubProject->GetName()); } $testSubProj = new SubProject(); $result = $testSubProj->GetNumberOfErrorBuilds($beginning_UTCDate, $end_UTCDate, True); if ($result) { foreach ($result as $row) { $subprojProp[$row['subprojectid']]['nbuilderror'] = $row[1]; } } $result = $testSubProj->GetNumberOfWarningBuilds($beginning_UTCDate, $end_UTCDate, True); if ($result) { foreach ($result as $row) { $subprojProp[$row['subprojectid']]['nbuildwarning'] = $row[1]; } } $result = $testSubProj->GetNumberOfPassingBuilds($beginning_UTCDate, $end_UTCDate, True); if ($result) { foreach ($result as $row) { $subprojProp[$row['subprojectid']]['nbuildpass'] = $row[1]; } } $result = $testSubProj->GetNumberOfErrorConfigures($beginning_UTCDate, $end_UTCDate, True); if ($result) { foreach ($result as $row) { $subprojProp[$row['subprojectid']]['nconfigureerror'] = $row[1]; } } $result = $testSubProj->GetNumberOfWarningConfigures($beginning_UTCDate, $end_UTCDate, True); if ($result) { foreach ($result as $row) { $subprojProp[$row['subprojectid']]['nconfigurewarning'] = $row[1]; } } $result = $testSubProj->GetNumberOfPassingConfigures($beginning_UTCDate, $end_UTCDate, True); if ($result) { foreach ($result as $row) { $subprojProp[$row['subprojectid']]['nconfigurepass'] = $row[1]; } } $result = $testSubProj->GetNumberOfPassingTests($beginning_UTCDate, $end_UTCDate, True); if ($result) { foreach ($result as $row) { $subprojProp[$row['subprojectid']]['ntestpass'] = $row[1]; } } $result = $testSubProj->GetNumberOfFailingTests($beginning_UTCDate, $end_UTCDate, True); if ($result) { foreach ($result as $row) { $subprojProp[$row['subprojectid']]['ntestfail'] = $row[1]; } } $result = $testSubProj->GetNumberOfNotRunTests($beginning_UTCDate, $end_UTCDate, True); if ($result) { foreach ($result as $row) { $subprojProp[$row['subprojectid']]['ntestnotrun'] = $row[1]; } } $reportArray = array('nbuilderror', 'nbuildwarning', 'nbuildpass', 'nconfigureerror', 'nconfigurewarning', 'nconfigurepass', 'ntestpass', 'ntestfail', 'ntestnotrun'); foreach ($subprojectids as $subprojectid) { $SubProject = new SubProject(); $SubProject->SetId($subprojectid); $xml .= "<subproject>"; $xml .= add_XML_value("name", $SubProject->GetName()); $xml .= add_XML_value("name_encoded", urlencode($SubProject->GetName())); foreach ($reportArray as $reportnum) { $reportval = array_key_exists($reportnum, $subprojProp[$subprojectid]) ? $subprojProp[$subprojectid][$reportnum] : 0; $xml .= add_XML_value($reportnum, $reportval); } if (strlen($SubProject->GetLastSubmission()) == 0) { $xml .= add_XML_value("lastsubmission", "NA"); } else { $xml .= add_XML_value("lastsubmission", $SubProject->GetLastSubmission()); } $xml .= "</subproject>"; if ($row == 1) { $row = 0; } else { $row = 1; } } // end for each subproject $end = microtime_float(); $xml .= "<generationtime>" . round($end - $start, 3) . "</generationtime>"; $xml .= "</cdash>"; return $xml; }
public function ComputeTestingDayBounds() { if ($this->ProjectId < 1) { return false; } if (isset($this->BeginningOfDay) && isset($this->EndOfDay)) { return true; } $build_date = $this->GetDate(); list($previousdate, $currentstarttime, $nextdate) = get_dates($build_date, $this->NightlyStartTime); $beginning_timestamp = $currentstarttime; $end_timestamp = $currentstarttime + 3600 * 24; $this->BeginningOfDay = gmdate(FMT_DATETIME, $beginning_timestamp); $this->EndOfDay = gmdate(FMT_DATETIME, $end_timestamp); return true; }
function second_try($found, $post_title_param, $destination_title, $destination_dates) { echo "\nfound : [{$found}]"; echo "\npost_title : [{$post_title_param}]"; echo "\ndestination_title : [{$destination_title}]\n"; $post_titles = get_post_titles(); // $post_titles = array("\(Biodiversity\)"); //debug $post_titles = array_diff($post_titles, array($post_title_param)); //exclude the $post_title_param foreach ($post_titles as $post_title) { $title = $destination_title . "_" . $post_title; if ($wiki_path = get_wiki_text($title)) { $title_dates = get_dates($wiki_path); if ($destination_dates == $title_dates) { //start saving... $temp_write_file = $GLOBALS['doc_root'] . "/eoearth/Custom/temp/write.wiki"; $handle = fopen($temp_write_file, "w"); fwrite($handle, "#REDIRECT [[" . str_replace("\\", "", $found) . "]]"); fclose($handle); echo "\n saving redirect on title: [{$title}]\n"; shell_exec("php " . $GLOBALS['doc_root'] . "/eoearth/maintenance/edit.php -m " . $title . " < {$temp_write_file}"); } } } }
if (pdo_num_rows($project) > 0) { $project_array = pdo_fetch_array($project); $svnurl = make_cdash_url(htmlentities($project_array['cvsurl'])); $homeurl = make_cdash_url(htmlentities($project_array['homeurl'])); $bugurl = make_cdash_url(htmlentities($project_array['bugtrackerurl'])); $googletracker = htmlentities($project_array['googletracker']); $docurl = make_cdash_url(htmlentities($project_array['documentationurl'])); $projectpublic = $project_array['public']; $projectname = $project_array['name']; } else { $projectname = 'NA'; } checkUserPolicy(@$_SESSION['cdash']['loginid'], $project_array['id']); $xml = begin_XML_for_XSLT(); $xml .= '<title>CDash - SubProject dependencies Graph - ' . $projectname . '</title>'; list($previousdate, $currentstarttime, $nextdate) = get_dates($date, $project_array['nightlytime']); $logoid = getLogoID($projectid); // Main dashboard section $xml .= '<dashboard> <datetime>' . date('l, F d Y H:i:s T', time()) . '</datetime> <date>' . $date . '</date> <unixtimestamp>' . $currentstarttime . '</unixtimestamp> <svn>' . $svnurl . '</svn> <bugtracker>' . $bugurl . '</bugtracker> <googletracker>' . $googletracker . '</googletracker> <documentation>' . $docurl . '</documentation> <logoid>' . $logoid . '</logoid> <projectid>' . $projectid . '</projectid> <projectname>' . $projectname . '</projectname> <projectname_encoded>' . urlencode($projectname) . '</projectname_encoded> <previousdate>' . $previousdate . '</previousdate>
/** 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) { continue; } if ($summaryEmail != '') { $summaryEmail .= ', '; } $summaryEmail .= $useremail; } // In the case of asynchronous submission, the serverURI contains /cdash // we need to remove it $currentURI = get_server_URI(); if ($CDASH_BASE_URL == '' && $CDASH_ASYNCHRONOUS_SUBMISSION) { $currentURI = substr($currentURI, 0, strrpos($currentURI, '/')); } // Select the users who want to receive all emails $user = pdo_query('SELECT ' . qid('user') . '.email,user2project.emailtype,' . qid('user') . '.id FROM ' . qid('user') . ',user2project WHERE user2project.projectid=' . qnum($projectid) . ' AND user2project.userid=' . qid('user') . '.id AND user2project.emailtype>1'); add_last_sql_error('sendsummaryemail'); 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; } // Check if the labels are defined for this user if (!checkEmailLabel($projectid, $user_array['id'], $buildid)) { continue; } if ($summaryEmail != '') { $summaryEmail .= ', '; } $summaryEmail .= $user_array['email']; } // Send the email if ($summaryEmail != '') { $Build = new Build(); $Build->FillFromId($buildid); $Site = new Site(); $Site->Id = $Build->SiteId; $summaryemail_array = pdo_fetch_array(pdo_query("SELECT name FROM buildgroup WHERE id={$groupid}")); add_last_sql_error('sendsummaryemail'); $title = 'CDash [' . $Project->Name . '] - ' . $summaryemail_array['name'] . ' Failures'; $messagePlainText = 'The "' . $summaryemail_array['name'] . "\" group has either errors, warnings or test failures.\n"; $messagePlainText .= 'You have been identified as one of the authors who have checked in changes that are part of this submission '; $messagePlainText .= "or you are listed in the default contact list.\n\n"; $messagePlainText .= 'Site name: ' . $Site->GetName() . "\n"; $messagePlainText .= 'Build name: ' . $Build->Name . ' (' . $Build->Type . ")\n"; $messagePlainText .= "To see this dashboard:\n"; $messagePlainText .= $currentURI; $messagePlainText .= '/index.php?project=' . urlencode($Project->Name) . '&date=' . $today; $messagePlainText .= "\n\n"; $messagePlainText .= "Summary of the first build failure:\n"; // Check if an email has been sent already for this user foreach ($errors as $errorkey => $nerrors) { $messagePlainText .= get_email_summary($buildid, $errors, $errorkey, $Project->EmailMaxItems, $Project->EmailMaxChars, $Project->TestTimeMaxStatus, $Project->EmailTestTimingChanged); } $messagePlainText .= "\n\n"; $serverName = $CDASH_SERVER_NAME; if (strlen($serverName) == 0) { $serverName = $_SERVER['SERVER_NAME']; } $messagePlainText .= "\n-CDash on " . $serverName . "\n"; // If this is the testing if ($CDASH_TESTING_MODE) { add_log($summaryEmail, 'TESTING: EMAIL', LOG_DEBUG); add_log($title, 'TESTING: EMAILTITLE', LOG_DEBUG); add_log($messagePlainText, 'TESTING: EMAILBODY', LOG_DEBUG); } else { // Send the email if (cdashmail("{$summaryEmail}", $title, $messagePlainText)) { add_log('summary email sent to: ' . $summaryEmail, 'sendemail ' . $Project->Name, LOG_INFO); return; } else { add_log('cannot send summary email to: ' . $summaryEmail, 'sendemail ' . $Project->Name, LOG_ERR); } } } }
foreach ($assignments as $event) { array_push($rows, $event); } } $testsmod = $moduleFactory->getModule("_standard/tests"); $tests = $testsmod->extend_date(); if ($tests != "") { foreach ($tests as $event) { array_push($rows, $event); } } } if (isset($_SESSION['valid_user'])) { if ($_SESSION['valid_user']) { /* check if the user is enrolled in the course */ $sql = "SELECT COUNT(*) FROM\r\n\t\t\t\t `" . TABLE_PREFIX . "course_enrollment`\r\n\t\t\t\t\tWHERE `member_id`='" . $_SESSION['member_id'] . "'\r\n\t\t\t\t\tAND `course_id`='" . $_SESSION['course_id'] . "'"; $result = mysql_query($sql, $db); $row = mysql_fetch_row($result); if ($row[0] > 0) { $dates = get_dates(); } else { } } } //Encode in JSON format. $str = json_encode($rows); //Replace "true","false" with true,false for javascript. $str = str_replace('"true"', 'true', $str); $str = str_replace('"false"', 'false', $str); //Return the events in the JSON format. echo $str;
$adviser = array(); $supervisor = array(); $course = array(); $not_enroled = array(); $enroled = array(); $study_mode = array(); $reason = array(); $addition_reason = array(); $deletion_reason = array(); $selects = template_selects($template->data); foreach ($selects as $select) { switch ($select) { case 'start_dates': if (empty($start_dates)) { // Get an array of possible module start dates (6 months back and 12 months forward from today) $start_dates = get_dates(date('m'), date('y'), 6, 12); $start_selected = 6; } break; case 'adviser': if (empty($adviser)) { $adviser = get_advisers($USER->id); } break; case 'supervisor': if (empty($supervisor)) { $supervisor = get_supervisors($USER->id); } break; case 'course': if (empty($course)) {
$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);
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; }
/** 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); $this->UploadError = true; return; } $this->Base64TmpFilename = $this->TmpFilename . '-base64'; // Open base64 temporary file for writting $this->Base64TmpFileWriteHandle = fopen($this->Base64TmpFilename, 'w'); if (!$this->Base64TmpFileWriteHandle) { add_log("Failed to open file '" . $this->Base64TmpFilename . "' for writting", __FILE__ . ':' . __LINE__ . ' - ' . __FUNCTION__, LOG_ERR); $this->UploadError = true; return; } } }
$end_timestamp += 3600 * 24; $end_date = gmdate(FMT_DATETIME, $end_timestamp); $response['to_date'] = $date; } else { // If not, just use whichever one was set. if (isset($_GET['from'])) { $date = $_GET['from']; } else { $date = $_GET['to']; } } } elseif (isset($_GET['date'])) { $date = $_GET['date']; } if (is_null($begin_date)) { list($previousdate, $beginning_timestamp, $nextdate, $d) = get_dates($date, $Project->NightlyTime); if (is_null($date)) { $date = $d; } $end_timestamp = $beginning_timestamp + 3600 * 24; $begin_date = gmdate(FMT_DATETIME, $beginning_timestamp); $end_date = gmdate(FMT_DATETIME, $end_timestamp); } // Check if the user specified a buildgroup. $groupid = 0; $group_join = ''; $group_clause = "b.type != 'Experimental'"; $group_link = ''; if (isset($_GET['group']) && is_numeric($_GET['group']) && $_GET['group'] > 0) { $groupid = $_GET['group']; $group_join = 'JOIN build2group b2g ON (b2g.buildid=b.id)';
" /> <input type="hidden" name="category" value="<?php echo $category; ?> " /> <div style="margin: 10px 0; vertical-align:middle;" class="sowcal"> <?php echo form_error('delivery_date'); ?> <select name="upcoming" id="upcoming" onchange="upcoming_date(this.value);" style="width:185px; vertical-align:top;"> <option value=""><?php echo lang('Choose delivery date'); ?> </option> <?php $dates = get_dates($product->delivery_method_id, 10); foreach ($dates as $day) { ?> <option value="<?php echo date('d-m-Y', strtotime($day)); ?> "><?php echo date('l, d F', strtotime($day)); ?> </option> <?php } ?> <optgroup label="....................................." class="vical"></optgroup> <option value="cal"><?php echo lang('View calendar');
$id = $argv[1]; } // No data, no report to run, bail! if (!isset($id)) { exit; } // No reports to run, bail! if (!is_array($config['mailreports']['schedule'])) { exit; } // The Requested report doesn't exist, bail! if (!$config['mailreports']['schedule'][$id]) { exit; } $thisreport = $config['mailreports']['schedule'][$id]; $graphs = $thisreport['row']; // No graphs on the report, bail! if (!is_array($graphs) || !(count($graphs) > 0)) { exit; } // Print report header // For each graph, print a header and the graph $attach = array(); $idx = 0; foreach ($graphs as $thisgraph) { $dates = get_dates($thisgraph['period'], $thisgraph['timespan']); $start = $dates['start']; $end = $dates['end']; $attach[] = mail_report_generate_graph($thisgraph['graph'], $thisgraph['style'], $thisgraph['timespan'], $start, $end); } mail_report_send($thisreport['descr'], $attach);
function get_dashboard_JSON($projectname, $date, &$response) { include "cdash/config.php"; require_once "cdash/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"; } 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['svn'] = 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['projectpublic'] = $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'])) { $userid = $_SESSION['cdash']['loginid']; // Is the user super administrator $userquery = pdo_query("SELECT admin FROM " . qid('user') . " WHERE id='{$userid}'"); $user_array = pdo_fetch_array($userquery); $response['admin'] = $user_array[0]; // Is the user administrator of the project $userquery = pdo_query("SELECT role FROM user2project WHERE userid=" . qnum($userid) . " AND projectid=" . qnum($projectid)); $user_array = pdo_fetch_array($userquery); $response['projectrole'] = $user_array[0]; } $response['userid'] = $userid; }
function echo_subprojects_dashboard_JSON($project_instance, $date) { $start = microtime_float(); $noforcelogin = 1; include_once dirname(dirname(dirname(__DIR__))) . '/config/config.php'; require_once 'include/pdo.php'; include 'public/login.php'; include_once 'models/banner.php'; include_once 'models/subproject.php'; $response = array(); $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}"); if (!$db) { $response['error'] = 'Error connecting to CDash database server'; echo json_encode($response); return; } if (!pdo_select_db("{$CDASH_DB_NAME}", $db)) { $response['error'] = 'Error selecting CDash database'; echo json_encode($response); return; } $Project = $project_instance; $projectid = $project_instance->Id; if (!checkUserPolicy(@$_SESSION['cdash']['loginid'], $projectid, 1)) { $response['requirelogin'] = 1; echo json_encode($response); return; } $response = begin_JSON_response(); $response['title'] = 'CDash - ' . $Project->Name; $response['showcalendar'] = 1; $banners = array(); $Banner = new Banner(); $Banner->SetProjectId(0); $text = $Banner->GetText(); if ($text !== false) { $banners[] = $text; } $Banner->SetProjectId($projectid); $text = $Banner->GetText(); if ($text !== false) { $banners[] = $text; } $response['banners'] = $banners; global $CDASH_SHOW_LAST_SUBMISSION; if ($CDASH_SHOW_LAST_SUBMISSION) { $response['showlastsubmission'] = 1; } list($previousdate, $currentstarttime, $nextdate) = get_dates($date, $Project->NightlyTime); // Main dashboard section get_dashboard_JSON($Project->GetName(), $date, $response); $projectname_encoded = urlencode($Project->Name); if ($currentstarttime > time()) { $response['error'] = 'CDash cannot predict the future (yet)'; echo json_encode($response); return; } $linkparams = 'project=' . urlencode($Project->Name); if (!empty($date)) { $linkparams .= "&date={$date}"; } $response['linkparams'] = $linkparams; // Menu definition $menu_response = array(); $menu_response['subprojects'] = 1; $menu_response['previous'] = "viewSubProjects.php?project={$projectname_encoded}&date={$previousdate}"; $menu_response['current'] = "viewSubProjects.php?project={$projectname_encoded}"; if (!has_next_date($date, $currentstarttime)) { $menu_response['nonext'] = 1; } else { $menu_response['next'] = "viewSubProjects.php?project={$projectname_encoded}&date={$nextdate}"; } $response['menu'] = $menu_response; $beginning_timestamp = $currentstarttime; $end_timestamp = $currentstarttime + 3600 * 24; $beginning_UTCDate = gmdate(FMT_DATETIME, $beginning_timestamp); $end_UTCDate = gmdate(FMT_DATETIME, $end_timestamp); // Get some information about the project $project_response = array(); $project_response['nbuilderror'] = $Project->GetNumberOfErrorBuilds($beginning_UTCDate, $end_UTCDate, true); $project_response['nbuildwarning'] = $Project->GetNumberOfWarningBuilds($beginning_UTCDate, $end_UTCDate, true); $project_response['nbuildpass'] = $Project->GetNumberOfPassingBuilds($beginning_UTCDate, $end_UTCDate, true); $project_response['nconfigureerror'] = $Project->GetNumberOfErrorConfigures($beginning_UTCDate, $end_UTCDate, true); $project_response['nconfigurewarning'] = $Project->GetNumberOfWarningConfigures($beginning_UTCDate, $end_UTCDate, true); $project_response['nconfigurepass'] = $Project->GetNumberOfPassingConfigures($beginning_UTCDate, $end_UTCDate, true); $project_response['ntestpass'] = $Project->GetNumberOfPassingTests($beginning_UTCDate, $end_UTCDate, true); $project_response['ntestfail'] = $Project->GetNumberOfFailingTests($beginning_UTCDate, $end_UTCDate, true); $project_response['ntestnotrun'] = $Project->GetNumberOfNotRunTests($beginning_UTCDate, $end_UTCDate, true); if (strlen($Project->GetLastSubmission()) == 0) { $project_response['lastsubmission'] = 'NA'; } else { $project_response['lastsubmission'] = $Project->GetLastSubmission(); } $response['project'] = $project_response; // Look for the subproject $row = 0; $subprojectids = $Project->GetSubProjects(); $subprojProp = array(); foreach ($subprojectids as $subprojectid) { $SubProject = new SubProject(); $SubProject->SetId($subprojectid); $subprojProp[$subprojectid] = array('name' => $SubProject->GetName()); } $testSubProj = new SubProject(); $result = $testSubProj->GetNumberOfErrorBuilds($beginning_UTCDate, $end_UTCDate, true); if ($result) { foreach ($result as $row) { $subprojProp[$row['subprojectid']]['nbuilderror'] = intval($row[1]); } } $result = $testSubProj->GetNumberOfWarningBuilds($beginning_UTCDate, $end_UTCDate, true); if ($result) { foreach ($result as $row) { $subprojProp[$row['subprojectid']]['nbuildwarning'] = intval($row[1]); } } $result = $testSubProj->GetNumberOfPassingBuilds($beginning_UTCDate, $end_UTCDate, true); if ($result) { foreach ($result as $row) { $subprojProp[$row['subprojectid']]['nbuildpass'] = intval($row[1]); } } $result = $testSubProj->GetNumberOfErrorConfigures($beginning_UTCDate, $end_UTCDate, true); if ($result) { foreach ($result as $row) { $subprojProp[$row['subprojectid']]['nconfigureerror'] = intval($row[1]); } } $result = $testSubProj->GetNumberOfWarningConfigures($beginning_UTCDate, $end_UTCDate, true); if ($result) { foreach ($result as $row) { $subprojProp[$row['subprojectid']]['nconfigurewarning'] = intval($row[1]); } } $result = $testSubProj->GetNumberOfPassingConfigures($beginning_UTCDate, $end_UTCDate, true); if ($result) { foreach ($result as $row) { $subprojProp[$row['subprojectid']]['nconfigurepass'] = intval($row[1]); } } $result = $testSubProj->GetNumberOfPassingTests($beginning_UTCDate, $end_UTCDate, true); if ($result) { foreach ($result as $row) { $subprojProp[$row['subprojectid']]['ntestpass'] = intval($row[1]); } } $result = $testSubProj->GetNumberOfFailingTests($beginning_UTCDate, $end_UTCDate, true); if ($result) { foreach ($result as $row) { $subprojProp[$row['subprojectid']]['ntestfail'] = intval($row[1]); } } $result = $testSubProj->GetNumberOfNotRunTests($beginning_UTCDate, $end_UTCDate, true); if ($result) { foreach ($result as $row) { $subprojProp[$row['subprojectid']]['ntestnotrun'] = intval($row[1]); } } $reportArray = array('nbuilderror', 'nbuildwarning', 'nbuildpass', 'nconfigureerror', 'nconfigurewarning', 'nconfigurepass', 'ntestpass', 'ntestfail', 'ntestnotrun'); $subprojects_response = array(); foreach ($subprojectids as $subprojectid) { $SubProject = new SubProject(); $SubProject->SetId($subprojectid); $subproject_response = array(); $subproject_response['name'] = $SubProject->GetName(); $subproject_response['name_encoded'] = urlencode($SubProject->GetName()); foreach ($reportArray as $reportnum) { $reportval = array_key_exists($reportnum, $subprojProp[$subprojectid]) ? $subprojProp[$subprojectid][$reportnum] : 0; $subproject_response[$reportnum] = $reportval; } if (strlen($SubProject->GetLastSubmission()) == 0) { $subproject_response['lastsubmission'] = 'NA'; } else { $subproject_response['lastsubmission'] = $SubProject->GetLastSubmission(); } $subprojects_response[] = $subproject_response; } $response['subprojects'] = $subprojects_response; $end = microtime_float(); $response['generationtime'] = round($end - $start, 3); echo json_encode(cast_data_for_JSON($response)); }
<strong style="display:block; clear: left; text-align:left;">Today</strong> <input type="hidden" name="delivery_date" id="delivery_date" value="<?php echo date('d-m-Y', strtotime($row->delivery_date)); ?> " /> <?php } else { ?> <input type="hidden" name="delivery_date" id="delivery_date" value="<?php echo date('d-m-Y', strtotime($row->delivery_date)); ?> " /> <select name="upcoming" id="upcoming" onchange="upcoming_date(this.value);" style="width:170px; vertical-align:text-middle;"> <?php $dates = get_dates($row->delivery_method_id, 10); $found = FALSE; foreach ($dates as $day) { ?> <option value="<?php echo date('d-m-Y', strtotime($day)); ?> " <?php if ($_POST) { if ($p->delivery_date == $day) { echo 'selected="selected"'; $found = TRUE; } } else { if ($row->delivery_date == $day) { echo 'selected="selected"';
/** Return an array with two sub arrays: * array1: id, buildname, os, bits, memory, frequency * array2: array1_id, test_fullname */ private function ListSiteTestFailure() { include "cdash/config.php"; include_once 'cdash/common.php'; if (!isset($this->Parameters['project'])) { echo "Project not set"; return; } $projectid = get_project_id($this->Parameters['project']); if (!is_numeric($projectid) || $projectid <= 0) { echo "Project not found"; return; } $group = 'Nightly'; if (isset($this->Parameters['group'])) { $group = pdo_real_escape_string($this->Parameters['group']); } // Get first all the unique builds for today's dashboard and group $query = pdo_query("SELECT nightlytime FROM project WHERE id=" . qnum($projectid)); $project_array = pdo_fetch_array($query); $date = date("Y-m-d"); list($previousdate, $currentstarttime, $nextdate) = get_dates($date, $project_array["nightlytime"]); $currentUTCTime = date(FMT_DATETIME, $currentstarttime); // Get all the unique builds for the section of the dashboard if ($CDASH_DB_TYPE == "pgsql") { $query = pdo_query("SELECT max(b.id) AS buildid,s.name || '-' || b.name AS fullname,s.name AS sitename,b.name,\n si.totalphysicalmemory,si.processorclockfrequency\n FROM build AS b, site AS s, siteinformation AS si, buildgroup AS bg, build2group AS b2g\n WHERE b.projectid=" . $projectid . " AND b.siteid=s.id AND si.siteid=s.id\n AND bg.name='" . $group . "' AND b.testfailed>0 AND b2g.buildid=b.id AND b2g.groupid=bg.id\n AND b.starttime>'{$currentUTCTime}' AND b.starttime<NOW() GROUP BY fullname,\n s.name,b.name,si.totalphysicalmemory,si.processorclockfrequency\n ORDER BY buildid"); } else { $query = pdo_query("SELECT max(b.id) AS buildid,CONCAT(s.name,'-',b.name) AS fullname,s.name AS sitename,b.name,\n si.totalphysicalmemory,si.processorclockfrequency\n FROM build AS b, site AS s, siteinformation AS si, buildgroup AS bg, build2group AS b2g\n WHERE b.projectid=" . $projectid . " AND b.siteid=s.id AND si.siteid=s.id\n AND bg.name='" . $group . "' AND b.testfailed>0 AND b2g.buildid=b.id AND b2g.groupid=bg.id\n AND b.starttime>'{$currentUTCTime}' AND b.starttime<UTC_TIMESTAMP() GROUP BY fullname ORDER BY buildid"); } $sites = array(); $buildids = ''; while ($query_array = pdo_fetch_array($query)) { if ($buildids != '') { $buildids .= ","; } $buildids .= $query_array['buildid']; $site = array(); $site['name'] = $query_array['sitename']; $site['buildname'] = $query_array['name']; $site['cpu'] = $query_array['processorclockfrequency']; $site['memory'] = $query_array['totalphysicalmemory']; $sites[$query_array['buildid']] = $site; } if (empty($sites)) { return $sites; } $query = pdo_query("SELECT bt.buildid AS buildid,t.name AS testname,t.id AS testid\n FROM build2test AS bt,test as t\n WHERE bt.buildid IN (" . $buildids . ") AND bt.testid=t.id AND bt.status='failed'"); $tests = array(); while ($query_array = pdo_fetch_array($query)) { $test = array(); $test['id'] = $query_array['testid']; $test['name'] = $query_array['testname']; $sites[$query_array['buildid']]['tests'][] = $test; } return $sites; }
die("Error: project not specified<br>\n"); } @($date = $_GET["date"]); if ($date != NULL) { $date = htmlspecialchars(pdo_real_escape_string($date)); } $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}"); pdo_select_db("{$CDASH_DB_NAME}", $db); $project = pdo_query("SELECT id,nightlytime FROM project WHERE name='{$projectname}'"); $project_array = pdo_fetch_array($project); $xml = begin_XML_for_XSLT(); $xml .= "<title>" . $projectname . " : Test Overview</title>"; $xml .= get_cdash_dashboard_xml_by_name($projectname, $date); $nightlytime = $project_array["nightlytime"]; // We select the builds list($previousdate, $currentstarttime, $nextdate, $today) = get_dates($date, $nightlytime); $xml .= "<menu>"; $xml .= add_XML_value("previous", "testOverview.php?project=" . urlencode($projectname) . "&date=" . $previousdate); if ($date != "" && date(FMT_DATE, $currentstarttime) != date(FMT_DATE)) { $xml .= add_XML_value("next", "testOverview.php?project=" . urlencode($projectname) . "&date=" . $nextdate); } else { $xml .= add_XML_value("nonext", "1"); } $xml .= add_XML_value("current", "testOverview.php?project=" . urlencode($projectname) . "&date="); $xml .= add_XML_value("back", "index.php?project=" . urlencode($projectname) . "&date=" . get_dashboard_date_from_project($projectname, $date)); $xml .= "</menu>"; // Get some information about the specified project $projectname = pdo_real_escape_string($projectname); $projectQuery = "SELECT id, nightlytime FROM project WHERE name = '{$projectname}'"; $projectResult = pdo_query($projectQuery); if (!($projectRow = pdo_fetch_array($projectResult))) {
/** Add daily changes if necessary */ function addDailyChanges($projectid) { include "cdash/config.php"; include_once "cdash/common.php"; include_once "cdash/sendemail.php"; $db = pdo_connect("{$CDASH_DB_HOST}", "{$CDASH_DB_LOGIN}", "{$CDASH_DB_PASS}"); pdo_select_db("{$CDASH_DB_NAME}", $db); $project_array = pdo_fetch_array(pdo_query("SELECT nightlytime,name,autoremovetimeframe,autoremovemaxbuilds,emailadministrator\n FROM project WHERE id='{$projectid}'")); $date = ""; // now list($previousdate, $currentstarttime, $nextdate) = get_dates($date, $project_array["nightlytime"]); $date = gmdate(FMT_DATE, $currentstarttime); // Check if we already have it somwhere $query = pdo_query("SELECT id FROM dailyupdate WHERE projectid='{$projectid}' AND date='{$date}'"); if (pdo_num_rows($query) == 0) { $cvsauthors = array(); pdo_query("INSERT INTO dailyupdate (projectid,date,command,type,status)\n VALUES ({$projectid},'{$date}','NA','NA','0')"); $updateid = pdo_insert_id("dailyupdate"); $dates = get_related_dates($project_array["nightlytime"], $date); $commits = get_repository_commits($projectid, $dates); // Insert the commits foreach ($commits as $commit) { $filename = $commit['directory'] . "/" . $commit['filename']; $checkindate = $commit['time']; $author = addslashes($commit['author']); $email = ''; if (isset($commit['email'])) { $email = addslashes($commit['email']); } $log = addslashes($commit['comment']); $revision = $commit['revision']; $priorrevision = $commit['priorrevision']; // Check if we have a robot file for this build $robot = pdo_query("SELECT authorregex FROM projectrobot\n WHERE projectid=" . qnum($projectid) . " AND robotname='" . $author . "'"); if (pdo_num_rows($robot) > 0) { $robot_array = pdo_fetch_array($robot); $regex = $robot_array['authorregex']; preg_match($regex, $commit['comment'], $matches); if (isset($matches[1])) { $author = addslashes($matches[1]); } } if (!in_array(stripslashes($author), $cvsauthors)) { $cvsauthors[] = stripslashes($author); } pdo_query("INSERT INTO dailyupdatefile (dailyupdateid,filename,checkindate,author,email,log,revision,priorrevision)\n VALUES ({$updateid},'{$filename}','{$checkindate}','{$author}','{$email}','{$log}','{$revision}','{$priorrevision}')"); add_last_sql_error("addDailyChanges", $projectid); } // end foreach commit // If the project has the option to send an email to the author if ($project_array['emailadministrator']) { sendEmailUnregisteredUsers($projectid, $cvsauthors); } // Send an email if some expected builds have not been submitting sendEmailExpectedBuilds($projectid, $currentstarttime); // cleanBuildEmail cleanBuildEmail(); cleanUserTemp(); // If the status of daily update is set to 2 that means we should send an email $query = pdo_query("SELECT status FROM dailyupdate WHERE projectid='{$projectid}' AND date='{$date}'"); $dailyupdate_array = pdo_fetch_array($query); $dailyupdate_status = $dailyupdate_array["status"]; if ($dailyupdate_status == 2) { // Find the groupid $group_query = pdo_query("SELECT buildid,groupid FROM summaryemail WHERE date='{$date}'"); while ($group_array = pdo_fetch_array($group_query)) { $groupid = $group_array["groupid"]; $buildid = $group_array["buildid"]; // Find if the build has any errors $builderror = pdo_query("SELECT count(buildid) FROM builderror WHERE buildid='{$buildid}' AND type='0'"); $builderror_array = pdo_fetch_array($builderror); $nbuilderrors = $builderror_array[0]; // Find if the build has any warnings $buildwarning = pdo_query("SELECT count(buildid) FROM builderror WHERE buildid='{$buildid}' AND type='1'"); $buildwarning_array = pdo_fetch_array($buildwarning); $nbuildwarnings = $buildwarning_array[0]; // Find if the build has any test failings if ($project_emailtesttimingchanged) { $sql = "SELECT count(testid) FROM build2test WHERE buildid='{$buildid}' AND (status='failed' OR timestatus>" . qnum($project_testtimemaxstatus) . ")"; } else { $sql = "SELECT count(testid) FROM build2test WHERE buildid='{$buildid}' AND status='failed'"; } $nfail_array = pdo_fetch_array(pdo_query($sql)); $nfailingtests = $nfail_array[0]; sendsummaryemail($projectid, $groupid, $nbuildwarnings, $nbuilderrors, $nfailingtests); } } pdo_query("UPDATE dailyupdate SET status='1' WHERE projectid='{$projectid}' AND date='{$date}'"); // Remove the old logs include_once "models/errorlog.php"; $ErrorLog = new ErrorLog(); $ErrorLog->Clean(10); // 10 days // Clean the backup directory clean_backup_directory(); // Remove the first builds of the project include_once "cdash/autoremove.php"; removeFirstBuilds($projectid, $project_array["autoremovetimeframe"], $project_array["autoremovemaxbuilds"]); removeBuildsGroupwise($projectid, $project_array["autoremovemaxbuilds"]); } }
continue 2; } break; case "allgraphs": /* make sure we do not show the placeholder databases in the all view */ if (stristr($curdatabase, "outbound") || stristr($curdatabase, "allgraphs")) { continue 2; } break; default: /* just use the name here */ if (!preg_match("/(^{$curoption}-|-{$curoption}\\.)/i", $curdatabase)) { continue 2; } } $dates = get_dates($curperiod, $graph); $start = $dates['start']; if ($curperiod == "current") { $end = $dates['end']; } /* generate update events utilizing jQuery('') feature */ $id = "{$graph}-{$curoption}-{$curdatabase}"; $id = preg_replace('/\\./', '_', $id); echo "\n"; echo "\t\tjQuery('#{$id}').attr('src','status_rrd_graph_img.php?start={$start}&graph={$graph}&database={$curdatabase}&style={$curstyle}&tmp=' + randomid);\n"; } } ?> window.setTimeout('update_graph_images()', 355000); } window.setTimeout('update_graph_images()', 355000);
function validation($data, $files) { $errors = parent::validation($data, $files); // Ensure we don't miss errors from any higher-level validation // Get valid dates for +- 5 years (MMMYY format) $start_dates = get_dates(date('m'), date('y'), 60, 60); // Check if at least one field in a required group has an entry if (empty($this->required_group)) { $group_entry = true; } else { $group_entry = false; foreach ($this->required_group as $key) { if ($data[$key] != '') { $group_entry = true; } } } // Do our own validation and add errors to array $required_value = false; foreach ($data as $key => $value) { if ($value == '' && in_array($key, $this->required_field, true)) { $required_value = true; // Leave the field error display to Moodle } else { if (!$group_entry && in_array($key, $this->required_group, true)) { // One of a required group with no entries $errors[$key] = get_string('group_required', 'local_obu_forms'); } else { if ($value == '' && in_array($key, $this->set_group, true) && (array_key_exists($this->check_id, $data) && $data[$this->check_id] == '1')) { // Controlled by a check box $errors[$key] = get_string('value_required', 'local_obu_forms'); } else { if ($value == '' && in_array($key, $this->unset_group, true) && (array_key_exists($this->check_id, $data) && $data[$this->check_id] == '0')) { // Controlled by a check box $errors[$key] = get_string('value_required', 'local_obu_forms'); } else { if ($key == 'adviser') { // They must have selected one if ($value == '0') { // Oh No! They haven't! $errors[$key] = get_string('value_required', 'local_obu_forms'); } } else { if ($key == 'supervisor') { // They must have selected one if ($value == '0') { // Oh No! They haven't! $errors[$key] = get_string('value_required', 'local_obu_forms'); } } else { if ($key == 'course') { // Exact match - should be a current course (programme) code if ($value != '') { // Might not be mandatory $current_courses = get_current_courses(0, $this->_customdata['modular']); if (!in_array(strtoupper($value), $current_courses, true)) { $errors[$key] = get_string('course_not_found', 'local_obu_forms'); } } } else { if (strpos($key, 'module') !== false) { // Validate module code format etcetera if ($value != '') { // Only validate if the field was completed $prefix = strtoupper(substr($value, 0, 1)); $suffix = substr($value, 1); if (strlen($value) != 6 || $prefix != 'C' && $prefix != 'F' && $prefix != 'P' && $prefix != 'U' || !is_numeric($suffix)) { $errors[$key] = get_string('invalid_module_code', 'local_obu_forms'); } else { if ($this->_customdata['modular'] && $prefix != 'U') { $errors[$key] = get_string('invalid_module_code', 'local_obu_forms'); } else { if ($key == 'module') { // Exact match - should be a current module $current_modules = get_current_modules(); if (!in_array($prefix . $suffix, $current_modules, true)) { $errors[$key] = get_string('module_not_found', 'local_obu_forms'); } } } } // Check that any associated module fields have also been completed $pos = strpos($key, 'module'); $prefix = substr($key, 0, $pos); $suffix = substr($key, $pos + 6); $key = $prefix . 'title' . $suffix; if (array_key_exists($key, $data) && $data[$key] == '') { $errors[$key] = get_string('value_required', 'local_obu_forms'); } $key = $prefix . 'start' . $suffix; if (array_key_exists($key, $data) && $data[$key] == '') { $errors[$key] = get_string('value_required', 'local_obu_forms'); } $key = $prefix . 'mark' . $suffix; if (array_key_exists($key, $data) && $data[$key] == '') { $errors[$key] = get_string('value_required', 'local_obu_forms'); } $key = $prefix . 'credit' . $suffix; if (array_key_exists($key, $data) && $data[$key] == '') { $errors[$key] = get_string('value_required', 'local_obu_forms'); } } } else { if (strpos($key, 'start') !== false) { // Validate start date format if ($value != '') { // Only validate if the field was completed $month = strtoupper(substr($value, 0, 3)); $year = substr($value, 3); if (strlen($value) != 5 || is_numeric($month) || !is_numeric($year)) { $errors[$key] = get_string('invalid_date_format', 'local_obu_forms'); } else { if (!in_array($month . $year, $start_dates, true)) { $errors[$key] = get_string('invalid_start_date', 'local_obu_forms'); } } } } } } } } } } } } } if ($required_value || !empty($errors)) { $errors['form_error'] = get_string('form_error', 'local_obu_forms'); } return $errors; }