public static function getRecentUserCheckins($uid) { return PublicApp::getDB()->getRecords('SELECT checkins.timestamp, checkins.checkin_id, pubs.pub_id, pubs.name AS pubname, users.user_id, users.username, users.fb_uid FROM checkins INNER JOIN users ON checkins.user_id = users.user_id INNER JOIN pubs ON checkins.pub_id = pubs.pub_id where users.user_id = ' . $uid); }
// set include path ini_set("include_path", ".:../library/"); // required classes require_once 'spoon/spoon.php'; require_once 'publicApp/publicApp.php'; $tpl = new SpoonTemplate(); $tpl->setForceCompile(true); $tpl->setCompileDirectory('./compiled_templates'); // do I know you? if (SpoonSession::exists('public_uid')) { $tpl->assign('oLogout', true); $tpl->assign('oNavMe', true); $uid = SpoonSession::get('public_uid'); /*code max*/ $recentDrinks = PublicApp::getRecentUserDrinks($uid); $recent = PublicApp::getRecentUserCheckins($uid); //$recent = array_merge($recentDrinks, $recentCheckins); function compare_time($a, $b) { return strnatcmp($b['timestamp'], $a['timestamp']); } usort($recent, 'compare_time'); $test = array(); for ($i = 0; $i < 100; $i++) { if ($recent[$i] !== null) { $test[] = $recent[$i]; } } $recent = $test; for ($i = 0; $i < sizeof($recent); $i++) { $recent[$i]['timestamp'] = SpoonDate::getTimeAgo(strtotime($recent[$i]['timestamp']));
/** * Gets the number of drinks. * * @return Checkin The latest checkin of a user. */ public function getNumberTabs() { return PublicApp::getDB()->getRecord('SELECT count(drink_id) as count FROM tabs WHERE checkin_id = ' . $this->checkin_id); }
$pubs[$i]["distance"] = round($distance, 3) . ' kilometer'; } else { $pubs[$i]["distance"] = round($distance, 3) * 1000 . ' meter'; } } } else { $tpl->assign('latitude', '""'); $tpl->assign('longitude', '""'); } if ($pubs !== null) { $tpl->assign('iPubs', $pubs); } else { $tpl->assign('iPubs', array()); } $recentDrinks = PublicApp::getRecentDrinks(); $recentCheckins = PublicApp::getRecentCheckins(); $recent = array_merge($recentDrinks, $recentCheckins); function compare_time($a, $b) { return strnatcmp($b['timestamp'], $a['timestamp']); } usort($recent, 'compare_time'); $test = array(); for ($i = 0; $i < 10; $i++) { if ($recent[$i] !== null) { $test[] = $recent[$i]; } } $recent = $test; for ($i = 0; $i < sizeof($recent); $i++) { $recent[$i]['timestamp'] = SpoonDate::getTimeAgo(strtotime($recent[$i]['timestamp']));
/** * Gets the pubs within your range. * * @return array All the drinks. */ public static function getPubsByLocation($lat, $long) { return PublicApp::getDB()->getRecords('SELECT * , (latitude - ' . $lat . ') AS dif_lat, (longitude - ' . $long . ') AS dif_long FROM pubs WHERE (latitude - ' . $lat . ') < 0.02 AND(longitude - ' . $long . ') < 0.02 GROUP BY (latitude - ' . $lat . ') DESC'); }
/** * Gets the top drinkers of this drink. * * @return array All the drinks. */ function getTop() { return PublicApp::getDB()->getRecords('SELECT users.user_id, users.username, count(users.user_id) as count FROM tabs INNER JOIN checkins on tabs.checkin_id = checkins.checkin_id INNER JOIN users on checkins.user_id = users.user_id WHERE tabs.drink_id = ' . $this->drink_id . ' group by users.user_id asc LIMIT 5'); }