function rest_post() { global $projectid; if (isset($_POST['newsubproject'])) { // Create a new subproject $SubProject = new SubProject(); $SubProject->SetProjectId($projectid); $newSubProject = htmlspecialchars(pdo_real_escape_string($_POST['newsubproject'])); $SubProject->SetName($newSubProject); if (isset($_POST['group'])) { $SubProject->SetGroup(htmlspecialchars(pdo_real_escape_string($_POST['group']))); } $SubProject->Save(); // Respond with a JSON representation of this new subproject $response = array(); $response['id'] = $SubProject->GetId(); $response['name'] = $SubProject->GetName(); $response['group'] = $SubProject->GetGroupId(); echo json_encode(cast_data_for_JSON($response)); return; } if (isset($_POST['newgroup'])) { // Create a new group $Group = new SubProjectGroup(); $Group->SetProjectId($projectid); $newGroup = htmlspecialchars(pdo_real_escape_string($_POST['newgroup'])); $Group->SetName($newGroup); if (isset($_POST['isdefault'])) { $Group->SetIsDefault($_POST['isdefault']); } $Group->SetCoverageThreshold(pdo_real_escape_numeric($_POST['threshold'])); $Group->Save(); // Respond with a JSON representation of this new group $response = array(); $response['id'] = $Group->GetId(); $response['name'] = $Group->GetName(); $response['is_default'] = $Group->GetIsDefault(); $response['coverage_threshold'] = $Group->GetCoverageThreshold(); echo json_encode(cast_data_for_JSON($response)); } if (isset($_POST['newLayout'])) { // Update the order of the SubProject groups. $inputRows = $_POST['newLayout']; foreach ($inputRows as $inputRow) { $id = qnum(pdo_real_escape_numeric($inputRow['id'])); $position = qnum(pdo_real_escape_numeric($inputRow['position'])); $query = "UPDATE subprojectgroup SET position={$position} WHERE id={$id}"; pdo_query($query); add_last_sql_error('API::subproject::newLayout::INSERT', $projectid); } return; } }
function rest_post() { global $projectid; if (isset($_POST['newsubproject'])) { // Create a new subproject $SubProject = new SubProject(); $SubProject->SetProjectId($projectid); $newSubProject = htmlspecialchars(pdo_real_escape_string($_POST['newsubproject'])); $SubProject->SetName($newSubProject); if (isset($_POST['group'])) { $SubProject->SetGroup(htmlspecialchars(pdo_real_escape_string($_POST['group']))); } $SubProject->Save(); // Respond with a JSON representation of this new subproject $response = array(); $response['id'] = $SubProject->GetId(); $response['name'] = $SubProject->GetName(); $response['group'] = $SubProject->GetGroupId(); echo json_encode($response); return; } if (isset($_POST['newgroup'])) { // Create a new group $Group = new SubProjectGroup(); $Group->SetProjectId($projectid); $newGroup = htmlspecialchars(pdo_real_escape_string($_POST['newgroup'])); $Group->SetName($newGroup); if (isset($_POST['isdefault'])) { $Group->SetIsDefault($_POST['isdefault']); } $Group->SetCoverageThreshold(pdo_real_escape_numeric($_POST['threshold'])); $Group->Save(); // Respond with a JSON representation of this new group $response = array(); $response['id'] = $Group->GetId(); $response['name'] = $Group->GetName(); $response['is_default'] = $Group->GetIsDefault(); $response['coverage_threshold'] = $Group->GetCoverageThreshold(); echo json_encode($response); } }