function prepareHunterProfile($dbh, $username) { // for the hunter profile page, we need // 1) the username // 2) the email // 3) the path to the profile picture // 4) all the reports this user has ever submitted // (paid and non-paid) (all info including bountyID) $args[':username'] = $username; $template_array['user'] = getHunterFromUsername($dbh, $args); $template_array['submittedReports'] = getReportsFromUsername($dbh, $args); $template_array['user']['numReportsFiled'] = sizeof($template_array['submittedReports']['result']); $template_array['reportsApproved'] = getNumberReportsApproved($dbh, $args); $template_array['user']['numReportsApproved'] = sizeof($template_array['reportsApproved']['result']); $template_array['pastBounties'] = getBountiesFromUsername($dbh, $args); return $template_array; }
$functionArray['result'] = array(); while ($row = $statement->fetch(PDO::FETCH_ASSOC)) { array_push($functionArray['result'], $row); } $functionArray['error'] = '0'; $functionArray['message'] = 'success'; } else { $functionArray['error'] = '1'; $functionArray['messageDB'] = $statement->errorInfo(); $functionArray['message'] = 'Statement not executed'; } return $functionArray; } $app->get('/api/getNumberReportsApproved/:username', function ($username) use($dbh) { $args[':username'] = $username; echo json_encode(getNumberReportsApproved($dbh, $args)); }); /* Ryan Edson getReportsFromUsernameBountyID returns all bounties a user has logged on a certain bounty Error Codes: Returns complete */ $app->get('/api/getReportsFromUsernameBountyID/:username/:bountyID', function ($username, $bountyID) use($dbh) { $args[':username'] = $username; $args[':bountyID'] = $bountyID; echo json_encode(getReportsFromUsernameBountyID($dbh, $args)); });