Ejemplo n.º 1
0
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;
    }
}
Ejemplo n.º 2
0
 /** Function to set this subproject's group. */
 public function SetGroup($groupName)
 {
     $groupName = pdo_real_escape_string($groupName);
     $row = pdo_single_row_query("SELECT id from subprojectgroup\n            WHERE name = '{$groupName}' AND endtime='1980-01-01 00:00:00'");
     if (empty($row)) {
         // Create the group if it doesn't exist yet.
         $subprojectGroup = new SubProjectGroup();
         $subprojectGroup->SetName($groupName);
         $subprojectGroup->SetProjectId($this->ProjectId);
         if ($subprojectGroup->Save() === false) {
             return false;
         }
         $this->GroupId = $subprojectGroup->GetId();
         return true;
     }
     $this->GroupId = $row['id'];
     return true;
 }