Exemplo n.º 1
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;
 }
Exemplo n.º 2
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;
    }
}
Exemplo n.º 3
0
 /**
  * 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;
 }