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; } }
/** * Return the list of subproject groups that belong to this project. */ function GetSubProjectGroups() { if (!$this->Id) { add_log('Id not set', 'Project::GetSubProjectGroups', LOG_ERR); return false; } include_once 'models/subprojectgroup.php'; $query = pdo_query("SELECT id FROM subprojectgroup WHERE projectid=" . qnum($this->Id) . "\n AND endtime='1980-01-01 00:00:00'"); if (!$query) { add_last_sql_error("Project::GetSubProjectGroups", $this->Id); return false; } $subProjectGroups = array(); while ($result = pdo_fetch_array($query)) { $subProjectGroup = new SubProjectGroup(); // SetId automatically loads the rest of the group's data. $subProjectGroup->SetId($result['id']); $subProjectGroups[] = $subProjectGroup; } return $subProjectGroups; }