function privatesquare_checkins_for_user(&$user, $more = array())
{
    $cluster_id = $user['cluster_id'];
    $enc_user = AddSlashes($user['id']);
    $sql = "SELECT * FROM PrivatesquareCheckins WHERE user_id='{$enc_user}'";
    if (isset($more['when'])) {
        list($start, $stop) = datetime_when_parse($more['when']);
        $enc_start = AddSlashes(strtotime($start));
        $enc_stop = AddSlashes(strtotime($stop));
        $sql .= " AND created BETWEEN '{$enc_start}' AND '{$enc_stop}'";
    } else {
        if (isset($more['venue_id'])) {
            $enc_venue = AddSlashes($more['venue_id']);
            $sql .= " AND venue_id='{$enc_venue}'";
        } else {
            if (isset($more['locality'])) {
                $enc_locality = AddSlashes($more['locality']);
                $sql .= " AND locality='{$enc_locality}'";
            }
        }
    }
    $sql .= " ORDER BY created DESC";
    $rsp = db_fetch_paginated_users($cluster_id, $sql, $more);
    if (!$rsp['ok']) {
        return $rsp;
    }
    $count = count($rsp['rows']);
    for ($i = 0; $i < $count; $i++) {
        privatesquare_checkins_inflate_extras($rsp['rows'][$i], $more);
    }
    return $rsp;
}
예제 #2
0
$more = array();
if ($page = get_int32("page")) {
    $more['page'] = $page;
}
if ($when = get_str("when")) {
    $more['when'] = $when;
    $history_url .= urlencode($when) . "/";
    # TO DO: find some better heuristic for this number
    # besides "pull it out of my ass" (20120206/straup)
    $more['per_page'] = 100;
}
$more['inflate_locality'] = 1;
$rsp = privatesquare_checkins_for_user($owner, $more);
# TO DO: oh god...timezones :-(
if ($when) {
    list($start, $stop) = datetime_when_parse($more['when']);
    $GLOBALS['smarty']->assign("when", $when);
    $GLOBALS['smarty']->assign("start", $start);
    $GLOBALS['smarty']->assign("stop", $stop);
}
$status_map = privatesquare_checkins_status_map();
$GLOBALS['smarty']->assign_by_ref("status_map", $status_map);
$GLOBALS['smarty']->assign("pagination_url", $GLOBALS['cfg']['abs_root_url'] . $history_url);
$GLOBALS['smarty']->assign_by_ref("owner", $owner);
$GLOBALS['smarty']->assign_by_ref("is_own", $is_own);
$export_formats = privatesquare_export_valid_formats();
$GLOBALS['smarty']->assign("export_formats", array_keys($export_formats));
$geo_stats = privatesquare_checkins_utils_geo_stats($rsp['rows']);
$GLOBALS['smarty']->assign_by_ref("geo_stats", $geo_stats);
$GLOBALS['smarty']->assign_by_ref("checkins", $rsp['rows']);
$GLOBALS['smarty']->display("page_user_history.txt");