function flickr_photos_utils_assign_can_view_geo(&$photos, $viewer_id = 0)
{
    $count = count($photos);
    for ($i = 0; $i < $count; $i++) {
        $ph = $photos[$i];
        $ph['can_view_geo'] = $ph['hasgeo'] && flickr_geo_permissions_can_view_photo($ph, $viewer_id) ? 1 : 0;
        $photos[$i] = $ph;
    }
    # Note the pass-by-ref
}
function flickr_photos_search(&$query, $more = array())
{
    if (!$GLOBALS['cfg']['enable_feature_solr']) {
        return not_okay('search indexing is disabled');
    }
    # OMGWTF: When sorting by date_taken|posted the results
    # are basically anything but sorted. It's unclear to me
    # whether this is a known Lucene thing or ... what? I
    # suppose it might make sense to store dates as INTs but
    # then we lose the ability to do date facteing, for calendar
    # pages sometime in the future. So for now we'll just sort
    # by photo ID since it accomplishes the same thing...
    # (20111121/straup)
    #
    # see also: http://phatness.com/2009/11/sorting-by-date-with-solr/
    $defaults = array('viewer_id' => 0, 'sort' => 'id desc');
    $more = array_merge($defaults, $more);
    $q = solr_utils_hash2query($query, " AND ");
    $params = array('q' => $q, 'sort' => $more['sort']);
    $owner_id = isset($query['user_id']) ? $query['user_id'] : 0;
    if ($fq = _flickr_photos_search_perms_fq($owner_id, $more['viewer_id'], $more)) {
        $params['fq'] = $fq;
    }
    $rsp = solr_select($params, $more);
    if (!$rsp['ok']) {
        return $rsp;
    }
    $photos = array();
    foreach ($rsp['rows'] as $row) {
        $photo = flickr_photos_get_by_id($row['id']);
        $can_view_geo = $photo['hasgeo'] && flickr_geo_permissions_can_view_photo($photo, $more['viewer_id']) ? 1 : 0;
        $photo['can_view_geo'] = $can_view_geo;
        $photos[] = $photo;
    }
    $rsp['rows'] = $photos;
    return $rsp;
}
Exemplo n.º 3
0
if ($context == 'faves') {
    # please write me
} else {
    if ($context == 'place') {
        # please write me
    } else {
        $more = array('viewer_id' => $GLOBALS['cfg']['user']['id']);
        $bookends = flickr_photos_get_bookends($photo, $more);
    }
}
$GLOBALS['smarty']->assign_by_ref("before", $bookends['before']);
$GLOBALS['smarty']->assign_by_ref("after", $bookends['after']);
# meta, geo, etc.
# $meta = flickr_photos_metadata_load($photo);
# $GLOBALS['smarty']->assign_by_ref("metadata", $meta['data']);
$photo['can_view_geo'] = $photo['hasgeo'] && flickr_geo_permissions_can_view_photo($photo, $GLOBALS['cfg']['user']['id']) ? 1 : 0;
if ($photo['can_view_geo']) {
    $geo_perms_map = flickr_geo_permissions_map();
    $photo['str_geoperms'] = $geo_perms_map[$photo['geoperms']];
    # NOTE: this has the potential to slow things down if the
    # Flickr API is being wonky. On the other hand if you're
    # just running this for yourself (or maybe a handful of
    # friends) it shouldn't be a big deal. Also, caching.
    if ($place = flickr_places_get_by_woeid($photo['woeid'])) {
        $GLOBALS['smarty']->assign_by_ref("place", $place);
    }
}
if ($GLOBALS['cfg']['user']['id']) {
    $perms_map = flickr_api_authtoken_perms_map();
    # the currently logged in viewer
    $_flickr_user = flickr_users_get_by_user_id($GLOBALS['cfg']['user']['id']);