Ejemplo n.º 1
0
if ($dots) {
    $to_json = array();
    foreach ($dots as $dot) {
        $tmp = array();
        foreach ($json_fields as $fi) {
            if (isset($dot[$fi])) {
                if ($fi == "details") {
                    $_details = array();
                    foreach ($dot[$fi] as $de) {
                        $_details[] = array('label' => $de[0]['label'], 'value' => $de[0]['value']);
                    }
                    $tmp[$fi] = $_details;
                } else {
                    $tmp[$fi] = $dot[$fi];
                }
            }
        }
        $to_json[] = $tmp;
    }
    //if( isset($owner.username) )$ddd[] = array('owner'=>$owner.username);
    $smarty->assign("dots_simple", $to_json);
}
$is_own = $owner['id'] == $GLOBALS['cfg']['user']['id'] ? 1 : 0;
$smarty->assign('is_own', $is_own);
if ($is_own) {
    $smarty->assign("permissions_map", dots_permissions_map());
    $smarty->assign("geocoder_map", geo_geocode_service_map());
}
$smarty->assign("pagination_url", urls_dots_for_user($owner));
$smarty->display('page_user_dots.txt');
exit;
Ejemplo n.º 2
0
     $enc_gh = urlencode($args['gh']);
     $pagination_url = "{$GLOBALS['cfg']['abs_root_url']}nearby/{$enc_gh}/";
 } else {
     unset($args['page']);
     $query_args = http_build_query($args);
     $pagination_url = "{$GLOBALS['cfg']['abs_root_url']}search/?" . $query_args;
     $page_as_queryarg = 1;
     if ($args['u']) {
         unset($args['u']);
         $query_args = http_build_query($args);
         $smarty->assign("query_all_url", "{$GLOBALS['cfg']['abs_root_url']}search/?" . $query_args);
     }
 }
 $GLOBALS['smarty']->assign("pagination_url", $pagination_url);
 $GLOBALS['smarty']->assign("pagination_page_as_queryarg", $page_as_queryarg);
 $perms_map = dots_permissions_map();
 $GLOBALS['smarty']->assign_by_ref('permissions_map', $perms_map);
 $formats = array_values(formats_valid_export_map());
 $GLOBALS['smarty']->assign("export_formats", $formats);
 $formats_pretty_names = formats_pretty_names_map();
 $GLOBALS['smarty']->assign_by_ref("formats_pretty_names", $formats_pretty_names);
 # create a simplfied object for js
 $json_fields = array("id", "created", "details", "geohash", "is_interactive", "latitude", "longitude", "user_id", "perms", "sheet_id");
 if ($rsp['dots']) {
     $ddd = array();
     foreach ($rsp['dots'] as $dot) {
         $bb = array();
         foreach ($json_fields as $fi) {
             if (isset($dot[$fi])) {
                 if ($fi == "details") {
                     $_details = array();
Ejemplo n.º 3
0
function export_dots(&$rows, $format, $more = array())
{
    # TO DO: figure out how caching should work
    # here (20110127/straup)
    if (!isset($more['path'])) {
        $tmp = tempnam(sys_get_temp_dir(), "export-{$format}") . ".{$format}";
        $more['path'] = $tmp;
    }
    # Are you ready? This gets hairy very fast because we
    # need to not only unpack the "details" and the "index on"
    # properties for a sheet full of dots but if export for
    # search then we also need to reconcile columns across
    # all the rows. This is probably not the best way to do
    # it but a) it works and b) everything is still in flux
    # (20110114/straup)
    $keys = array();
    $details = array();
    if (!$GLOBALS['cfg']['enable_feature_search_export']) {
        $_keys = array_keys($rows[0]);
        foreach ($_keys as $k) {
            if (in_array($key, $GLOBALS['export_ignore_columns'])) {
                continue;
            }
        }
        if (isset($rows[0]['details'])) {
            $details = array_keys($rows[0]['details']);
        }
    } else {
        $seen = array();
        foreach ($rows as $row) {
            $_keys = array_keys($row);
            foreach ($_keys as $k) {
                if (in_array($k, $keys)) {
                    continue;
                }
                if (in_array($k, $GLOBALS['export_ignore_columns'])) {
                    continue;
                }
                $keys[] = $k;
            }
            if (isset($row['details'])) {
                foreach (array_keys($row['details']) as $k) {
                    if (!in_array($k, $details)) {
                        $details[] = $k;
                    }
                }
            }
            # sigh...
        }
    }
    #
    $count_rows = count($rows);
    for ($i = 0; $i < $count_rows; $i++) {
        $row = $rows[$i];
        # see above...
        if ($GLOBALS['cfg']['enable_feature_search_facets']) {
            foreach ($keys as $k) {
                if (!isset($row[$k])) {
                    $row[$k] = '';
                }
            }
        }
        foreach ($GLOBALS['export_ignore_columns'] as $key) {
            if (isset($row[$key])) {
                unset($row[$key]);
            }
        }
        # okay... first let's pull out all the 'details'
        foreach ($details as $k) {
            # assume that the data in Dots trumps all
            if ($row[$k]) {
                continue;
            }
            if (isset($row['details'][$k])) {
                $values = array();
                foreach ($row['details'][$k] as $e) {
                    $values[] = $e['value'];
                }
                $row[$k] = implode(",", $values);
            } else {
                $row[$k] = '';
            }
        }
        unset($row['details']);
        # next, make perms and timestamps pretty
        if (isset($row['perms'])) {
            $map = dots_permissions_map();
            $row['perms'] = $map[$row['perms']];
        }
        $timestamps = array('imported', 'last_modified');
        foreach ($timestamps as $ts) {
            if (isset($row[$ts])) {
                $row[$ts] = gmdate('Y-m-d\\TH:m:s e', $row[$ts]);
            }
        }
        $rows[$i] = $row;
    }
    # this sucks...
    $cols = array();
    foreach (array_merge($keys, $details) as $k) {
        if ($k == 'details') {
            continue;
        }
        if (in_array($k, $cols)) {
            continue;
        }
        $cols[] = $k;
    }
    # carry on
    $more['columns'] = $cols;
    loadlib($format);
    $exported_file = call_user_func_array("{$format}_export_dots", array(&$rows, &$more));
    return $exported_file;
}
Ejemplo n.º 4
0
function dots_can_view_dot(&$dot, $viewer_id)
{
    if ($dot['user_id'] == $viewer_id) {
        return 1;
    }
    $perms_map = dots_permissions_map();
    return $perms_map[$dot['perms']] == 'public' ? 1 : 0;
}