function prepareHome($dbh) { if ($_SESSION['userType'] === "hunter") { $template_array["username"] = $_SESSION['userLogin']; $template_array['preferredBounties'] = getPreferredBounties($dbh); $template_array['messageOfDay'] = getMessageOfDayHunter($dbh); $args[':username'] = $_SESSION['userLogin']; $template_array['trackBounties'] = getBountiesFromUsernameRecentReports($dbh, $args); $template_array['subscriptions'] = getRSSSubscription($dbh); return $template_array; } else { if ($_SESSION['userType'] === "marshal") { $template_array['username'] = $_SESSION['userLogin']; $template_array['rssExists'] = rssExists($dbh); $template_array['subscriptions'] = getRSSSubscription($dbh); $dummy = getMessageOfDayMarshal($dbh); $template_array["messageOfDay"] = getMessageOfDayMarshal($dbh); $args[':username'] = $_SESSION['userLogin']; $template_array['activeBounties'] = getActiveBounties($dbh, $args); $template_array['subscriptions'] = getRSSSubscription($dbh); return $template_array; } else { $template_array = getPreferredBounties($dbh); return $template_array; } } }
function prepareCompanyProfilePage($dbh, $companyUsername) { // for discover, the template array must contain // 1) the username // 2) the email of the username // 3) the top 10 bounties $template_array = array("username" => $_SESSION['userLogin'], "email" => $_SESSION['email']); $args[':username'] = $companyUsername; $template_array['company'] = getMarshalFromUsername($dbh, $args); if ($template_array['company']['error'] == 2) { return $template_array; } $template_array['company']['name'] = $companyUsername; $template_array['company']['active'] = getActiveBounties($dbh, $args); $template_array['company']['inactive'] = getPastBounties($dbh, $args); $template_array['company']['numActive'] = sizeof($template_array['company']['active']['result']); $template_array['company']['numBounties'] = $template_array['company']['numActive'] + sizeof($template_array['company']['inactive']['result']); return $template_array; }
function prepareMarshallProfile($dbh, $username) { // for marshall profile we need // 1) email // 2) company name // 3) username // 4) all bounties currently active for user // 5) all bounties that have expired //call for current bounties in database //call for past bounties in database //call for profile picture $template_array["error"] = 0; //for time being $args[':username'] = $username; $template_array['user'] = getMarshalFromUsername($dbh, $args); $template_array['activeBounties'] = getActiveBounties($dbh, $args); $template_array['pastBounties'] = getPastBounties($dbh, $args); $template_array['user']['numActive'] = sizeof($template_array['activeBounties']['result']); $template_array['user']['numTotal'] = sizeof($template_array['activeBounties']['result']) + sizeof($template_array['pastBounties']['result']); return $template_array; }
/* Andre Gras getActiveBounties returns active bounties for logged in Marshall Error Codes: 0 - profile path returned 1 - logged in user is a hunter 2 - statement did not execute Returns All active bounties with all fields from BountyPool complete */ $app->get('/api/getActiveBounties/:username', function ($username) use($dbh) { $args[':username'] = $username; echo json_encode(getActiveBounties($dbh, $args)); }); /* Andre Gras getPastBounties returns past bounties for logged in Marshall Error Codes: 0 - profile path returned 1 - logged in user is a hunter 2 - statement did not execute Returns All past bounties with all fields from BountyPool complete */ $app->get('/api/getPastBounties/:username', function ($username) use($dbh) {