function privatesquare_export_massage_checkin(&$row, $more = array())
{
    $status_map = privatesquare_checkins_status_map();
    $row['status_name'] = $status_map[$row['status_id']];
    # prefix keys with machinetag namespaces?
    if (isset($row['venue'])) {
        $row['venue_name'] = $row['venue']['name'];
        unset($row['venue']);
    }
    if ($row['locality']) {
        $loc = reverse_geoplanet_get_by_woeid($row['locality'], 'locality');
        $row['locality_name'] = $loc['name'];
    }
    if (isset($row['weather']) && isset($more['inflate_weather'])) {
        if ($data = json_decode($row['weather'], 'as hash')) {
            foreach ($data as $k => $v) {
                $row["weather_{$k}"] = $v;
            }
        }
        unset($row['weather']);
    }
    # note the pass-by-ref
}
示例#2
0
include "include/init.php";
loadlib("foursquare_venues");
loadlib("foursquare_checkins");
loadlib("privatesquare_checkins");
loadlib("privatesquare_export");
loadlib("reverse_geoplanet");
login_ensure_loggedin($_SERVER['REQUEST_URI']);
$owner = $GLOBALS['cfg']['user'];
$GLOBALS['smarty']->assign_by_ref("owner", $owner);
$venue_id = get_str("venue_id");
$venue = foursquare_venues_get_by_venue_id($venue_id);
if (!$venue) {
    error_404();
}
$venue['data'] = json_decode($venue['data'], "as hash");
$venue['locality'] = reverse_geoplanet_get_by_woeid($venue['locality'], 'locality');
# TO DO: account for pagination and > n checkins
$more = array('venue_id' => $venue_id);
$checkins = privatesquare_checkins_for_user($owner, $more);
$venue['checkins'] = $checkins['rows'];
$status_map = privatesquare_checkins_status_map();
$broadcast_map = foursquare_checkins_broadcast_map();
$GLOBALS['smarty']->assign_by_ref("status_map", $status_map);
$GLOBALS['smarty']->assign_by_ref("broadcast_map", $broadcast_map);
$GLOBALS['smarty']->assign_by_ref("venue", $venue);
$checkin_crumb = crumb_generate("api", "privatesquare.venues.checkin");
$GLOBALS['smarty']->assign("checkin_crumb", $checkin_crumb);
# did we arrive here from a checkin page?
$success = get_str("success") ? 1 : 0;
$GLOBALS['smarty']->assign("success", $success);
$GLOBALS['smarty']->assign("venue_id", $venue_id);
function privatesquare_checkins_inflate_extras(&$row, $more = array())
{
    $venue_id = $row['venue_id'];
    $venue = foursquare_venues_get_by_venue_id($venue_id);
    $row['venue'] = $venue;
    if ($row['weather']) {
        if ($weather = json_decode($row['weather'], "as hash")) {
            $row['weather'] = $weather;
        }
    }
    # This doesn't make any sense unless you've got something
    # like memcache installed. The volume of DB calls that get
    # made relative to the actual use of any data here is out
    # of control. Leaving it as an FYI / nice to have...
    # (20120301/straup)
    if (isset($more['inflate_locality']) && ($woeid = $row['locality'])) {
        $loc = reverse_geoplanet_get_by_woeid($woeid, 'locality');
        $row['locality'] = $loc;
    }
    # note the pass by ref
}
示例#4
0
    error_404();
}
$history_url = "user/{$fsq_id}/places/{$woeid}/";
login_ensure_loggedin($history_url);
$fsq_user = foursquare_users_get_by_foursquare_id($fsq_id);
if (!$fsq_user) {
    error_404();
}
$owner = users_get_by_id($fsq_user['user_id']);
$is_own = $owner['id'] == $GLOBALS['cfg']['user']['id'] ? 1 : 0;
# for now...
if (!$is_own) {
    error_403();
}
$more = array('locality' => $woeid);
if ($page = get_int32("page")) {
    $more['page'] = $page;
}
$rsp = privatesquare_checkins_venues_for_user($owner, $more);
$GLOBALS['smarty']->assign_by_ref("venues", $rsp['rows']);
$geo_stats = privatesquare_checkins_utils_geo_stats($rsp['rows']);
$GLOBALS['smarty']->assign_by_ref("geo_stats", $geo_stats);
$locality = reverse_geoplanet_get_by_woeid($woeid, 'locality');
$GLOBALS['smarty']->assign_by_ref("locality", $locality);
$GLOBALS['smarty']->assign_by_ref("owner", $owner);
$pagination_url = urls_places_for_user($owner) . "{$woeid}/";
$GLOBALS['smarty']->assign("pagination_url", $pagination_url);
$export_formats = privatesquare_export_valid_formats();
$GLOBALS['smarty']->assign("export_formats", array_keys($export_formats));
$GLOBALS['smarty']->display("page_user_place.txt");
exit;
示例#5
0
if (!$fsq_id || !$chk_id) {
    error_404();
}
$history_url = "user/{$fsq_id}/history/";
login_ensure_loggedin($history_url);
$fsq_user = foursquare_users_get_by_foursquare_id($fsq_id);
if (!$fsq_user) {
    error_404();
}
$owner = users_get_by_id($fsq_user['user_id']);
$is_own = $GLOBALS['cfg']['user']['id'] == $owner['id'] ? 1 : 0;
# for now...
if (!$is_own) {
    error_403();
}
$checkin = privatesquare_checkins_get_by_id($owner, $chk_id);
if (!$checkin) {
    error_404();
}
$checkin['locality'] = reverse_geoplanet_get_by_woeid($checkin['locality'], 'locality');
$status_map = privatesquare_checkins_status_map();
$broadcast_map = foursquare_checkins_broadcast_map();
$GLOBALS['smarty']->assign_by_ref("owner", $owner);
$GLOBALS['smarty']->assign_by_ref("checkin", $checkin);
$GLOBALS['smarty']->assign_by_ref("status_map", $status_map);
$GLOBALS['smarty']->assign_by_ref("broadcast_map", $broadcast_map);
$GLOBALS['smarty']->assign("is_own", $is_own);
$checkin_crumb = crumb_generate("api", "privatesquare.venues.checkin");
$GLOBALS['smarty']->assign("checkin_crumb", $checkin_crumb);
$GLOBALS['smarty']->display("page_user_checkin.txt");
exit;