/** * * Gets a list of problems where current user is the owner * * @param Request $r */ public static function apiMyList(Request $r) { self::authenticateRequest($r); self::validateList($r); $response = array(); $response['results'] = array(); try { $problems = null; if (Authorization::IsSystemAdmin($r['current_user_id'])) { $problems = ProblemsDAO::getAll(null, null, 'problem_id', 'DESC'); } else { $problem_mask = new Problems(array('author_id' => $r['current_user_id'])); $problems = ProblemsDAO::search($problem_mask, 'problem_id', 'DESC', $r['offset'], $r['rowcount']); } foreach ($problems as $problem) { $problemArray = $problem->asArray(); $problemArray['tags'] = ProblemsDAO::getTagsForProblem($problem, false); array_push($response['results'], $problemArray); } } catch (Exception $e) { throw new InvalidDatabaseOperationException($e); } $response['status'] = 'ok'; return $response; }
/** * * Gets a list of problems where current user is the owner * * @param Request $r */ public static function apiMyList(Request $r) { self::authenticateRequest($r); self::validateList($r); $response = array(); $response["results"] = array(); try { $problems = NULL; if (Authorization::IsSystemAdmin($r["current_user_id"])) { $problems = ProblemsDAO::getAll(NULL, NULL, "problem_id", 'DESC'); } else { $problem_mask = new Problems(array("author_id" => $r["current_user_id"])); $problems = ProblemsDAO::search($problem_mask, "problem_id", 'DESC', $r["offset"], $r["rowcount"]); } foreach ($problems as $problem) { $problemArray = $problem->asArray(); $problemArray['tags'] = ProblemsDAO::getTagsForProblem($problem, false); array_push($response["results"], $problemArray); } } catch (Exception $e) { throw new InvalidDatabaseOperationException($e); } $response["status"] = "ok"; return $response; }