Example #1
0
}
$userid = $_SESSION['cdash']['loginid'];
if (!isset($userid) || !is_numeric($userid)) {
    $response['requirelogin'] = 1;
    echo json_encode($response);
    return;
}
$edit = isset($_GET['edit']) && !empty($_GET['edit']);
$projectid = null;
if (isset($_GET['projectid']) && !empty($_GET['projectid'])) {
    $projectid = pdo_real_escape_numeric($_GET['projectid']);
}
$Project = new Project();
// If the projectid is not set and there is only one project we go directly to the page
if ($edit && is_null($projectid)) {
    $projectids = $Project->GetIds();
    if (count($projectids) == 1) {
        $projectid = $projectids[0];
    }
}
// If the projectid is set, make sure that it's valid
$Project->Id = $projectid;
if (!is_null($projectid) && $projectid > 0 && !$Project->Exists()) {
    $response['error'] = 'This project does not exist.';
    echo json_encode($response);
    return;
}
$User = new User();
$User->Id = $userid;
$role = $Project->GetUserRole($userid);
// If we are editing a project make sure we have the right to do so