/** Set the subproject id */ function SetSubProject($subproject) { if (!empty($this->SubProjectId)) { return $this->SubProjectId; } if (empty($subproject)) { return false; } if (empty($this->ProjectId)) { add_log('ProjectId not set' . $subproject, 'Build::SetSubProject', LOG_ERR, $this->ProjectId, $this->Id, CDASH_OBJECT_BUILD, $this->Id); return false; } $query = pdo_query("SELECT id FROM subproject WHERE name='{$subproject}' AND " . "projectid=" . qnum($this->ProjectId) . " AND endtime='1980-01-01 00:00:00'"); if (!$query) { add_last_sql_error("Build:SetSubProject()", $this->ProjectId); return false; } $this->SubProjectName = $subproject; if (pdo_num_rows($query) > 0) { $query_array = pdo_fetch_array($query); $this->SubProjectId = $query_array['id']; return $this->SubProjectId; } // If the subproject wasn't found, add it here. // A proper Project.xml file will still need to be uploaded later to // load dependency data. $subProject = new SubProject(); $subProject->SetProjectId($this->ProjectId); $subProject->SetName($subproject); $subProject->Save(); // Insert the label too. $Label = new Label(); $Label->Text = $subProject->GetName(); $Label->Insert(); add_log('New subproject detected: ' . $subproject, 'Build::SetSubProject', LOG_WARNING, $this->ProjectId, $this->Id, CDASH_OBJECT_BUILD, $this->Id); return true; }
function rest_put() { global $projectid; if (isset($_GET['threshold'])) { // Modify an existing subproject group. $groupid = pdo_real_escape_numeric($_GET['groupid']); $Group = new SubProjectGroup(); $Group->SetProjectId($projectid); $Group->SetId($groupid); $name = pdo_real_escape_string($_GET['name']); $Group->SetName($name); $threshold = pdo_real_escape_numeric($_GET['threshold']); $Group->SetCoverageThreshold($threshold); $Group->SetIsDefault($_GET['is_default']); $Group->Save(); return; } $subprojectid = get_subprojectid(); if ($subprojectid === false) { return; } $SubProject = new SubProject(); $SubProject->SetId($subprojectid); if (isset($_GET['dependencyid'])) { // Add dependency to existing subproject. $dependencyid = pdo_real_escape_numeric($_GET['dependencyid']); $SubProject->AddDependency($dependencyid); return; } if (isset($_GET['groupname'])) { // Change which group a subproject belongs to. $groupName = pdo_real_escape_string($_GET['groupname']); $SubProject->SetGroup($groupName); $SubProject->Save(); return; } }
/** Set the subproject id */ public function SetSubProject($subproject) { if (!empty($this->SubProjectId)) { return $this->SubProjectId; } if (empty($subproject)) { return false; } if (empty($this->ProjectId)) { add_log('ProjectId not set' . $subproject, 'Build::SetSubProject', LOG_ERR, $this->ProjectId, $this->Id, CDASH_OBJECT_BUILD, $this->Id); return false; } $query = pdo_query("SELECT id FROM subproject WHERE name='{$subproject}' AND " . 'projectid=' . qnum($this->ProjectId) . " AND endtime='1980-01-01 00:00:00'"); if (!$query) { add_last_sql_error('Build:SetSubProject()', $this->ProjectId); return false; } $this->SubProjectName = $subproject; $label = new Label(); $label->Text = $subproject; $this->AddLabel($label); // Add this subproject as a label on the parent build. $this->SetParentId($this->LookupParentBuildId()); if ($this->ParentId > 0) { $parent = new Build(); $parent->Id = $this->ParentId; $parent->AddLabel($label); $parent->InsertLabelAssociations(); } if (pdo_num_rows($query) > 0) { $query_array = pdo_fetch_array($query); $this->SubProjectId = $query_array['id']; return $this->SubProjectId; } // If the subproject wasn't found, add it here. // A proper Project.xml file will still need to be uploaded later to // load dependency data. $subProject = new SubProject(); $subProject->SetProjectId($this->ProjectId); $subProject->SetName($subproject); $subProject->Save(); // Insert the label too. $Label = new Label(); $Label->Text = $subProject->GetName(); $Label->Insert(); add_log('New subproject detected: ' . $subproject, 'Build::SetSubProject', LOG_INFO, $this->ProjectId, $this->Id, CDASH_OBJECT_BUILD, $this->Id); return true; }