Exemplo n.º 1
0
function rest_get()
{
    global $projectid;
    $buildgroupid = get_buildgroupid();
    if ($buildgroupid === false) {
        return;
    }
    $start = microtime_float();
    $response = begin_JSON_response();
    $response['projectid'] = $projectid;
    $response['buildgroupid'] = $buildgroupid;
    $BuildGroup = new BuildGroup();
    $BuildGroup->SetId($buildgroupid);
    $response['name'] = $BuildGroup->GetName();
    $response['group'] = $BuildGroup->GetGroupId();
    $query = pdo_query("\n    SELECT id, name FROM buildgroup WHERE projectid=" . qnum($projectid) . "\n    AND endtime='1980-01-01 00:00:00'");
    if (!$query) {
        add_last_sql_error("getBuildGroup Select");
        return false;
    }
    $dependencies = $BuildGroup->GetDependencies();
    $dependencies_response = array();
    $available_dependencies_response = array();
    while ($row = pdo_fetch_array($query)) {
        if ($row['id'] == $buildgroupid) {
            continue;
        }
        if (is_array($dependencies) && in_array($row['id'], $dependencies)) {
            $dep = array();
            $dep['id'] = $row['id'];
            $dep['name'] = $row['name'];
            $dependencies_response[] = $dep;
        } else {
            $avail = array();
            $avail['id'] = $row['id'];
            $avail['name'] = $row['name'];
            $available_dependencies_response[] = $avail;
        }
    }
    $response['dependencies'] = $dependencies_response;
    $response['available_dependencies'] = $available_dependencies_response;
    $end = microtime_float();
    $response['generationtime'] = round($end - $start, 3);
    echo json_encode($response);
}