/** * Entry point for Problem clarifications API * * @param Request $r * @throws InvalidFilesystemOperationException * @throws InvalidDatabaseOperationException */ public static function apiClarifications(Request $r) { // Get user self::authenticateRequest($r); self::validateRuns($r); $is_problem_admin = Authorization::CanEditProblem($r['current_user_id'], $r['problem']); try { $clarifications = ClarificationsDAO::GetProblemClarifications($r['problem']->problem_id, $is_problem_admin, $r['current_user_id'], $r['offset'], $r['rowcount']); } catch (Exception $e) { // Operation failed in the data layer throw new InvalidDatabaseOperationException($e); } foreach ($clarifications as &$clar) { $clar['time'] = (int) $clar['time']; } // Add response to array $response = array(); $response['clarifications'] = $clarifications; $response['status'] = 'ok'; return $response; }