Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
    $result = updateReport($dbh, $args, $changeCode);
    $result['post'] = $_POST;
    echo json_encode($result);
});
/*
Ryan Edson
getReportsFromUsername
Returns all reports a username has submitted
Error Codes:
Returns

complete
*/
$app->get('/api/getReportsFromUsername/:username', function ($username) use($dbh) {
    $args[':username'] = $username;
    echo json_encode(getReportsFromUsername($dbh, $args));
});
$app->get('/api/getReportFromReportID/:reportID', function ($reportID) use($dbh) {
    $args[':reportID'] = $reportID;
    $functionArray = array();
    $statement = $dbh->prepare("SELECT Report.*, DATE(Report.datePaid) as datePaid, BountyPool.bountyName FROM Report\n  WHERE reportID = :reportID\n  AND BountyPool.poolID = Report.bountyID");
    if ($statement->execute($args)) {
        $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'] = $sth->errorInfo();