Пример #1
0
    }
} else {
    if ($by_nsid = get_str("by_nsid")) {
        if ($by_flickr_user = flickr_users_get_by_nsid($by_nsid)) {
            $more['by_owner'] = users_get_by_id($by_flickr_user['user_id']);
        }
    } else {
    }
}
$by_owner = isset($more['by_owner']) ? $more['by_owner'] : null;
$faves = flickr_faves_for_user($owner, $more);
$photos = array();
foreach ($faves['rows'] as $f) {
    $photo = flickr_photos_get_by_id($f['photo_id']);
    $photo['owner'] = users_get_by_id($photo['user_id']);
    # quick hack until perms are denormalized into the FlickrFaves table
    $photo['canview'] = flickr_photos_permissions_can_view_photo($photo, $viewer['id']);
    # going to leave this disable until I figure out what to
    # do about reciprical contacts hoohah...
    if ($is_own) {
        $photo['canview'] = 1;
    }
    $photos[] = $photo;
}
$GLOBALS['smarty']->assign_by_ref("owner", $owner);
$GLOBALS['smarty']->assign_by_ref("by_owner", $by_owner);
$GLOBALS['smarty']->assign_by_ref("photos", $photos);
$pagination_url = flickr_urls_faves_user($owner, $by_owner);
$GLOBALS['smarty']->assign("pagination_url", $pagination_url);
$GLOBALS['smarty']->display("page_flickr_faves_user.txt");
exit;
Пример #2
0
}
# This is two things. One, a quick and dirty hack to ensure
# that we display a notice if the path alias (on Flickr) has
# been taken by a local user. See notes in flickr_users_get_by_url
# and note that we are explicitly setting the "do not 404" flag
# here. Two, make sure the photo is actually owned by the user
# pointed to by the path alias or NSID. (20111203/straup)
$flickr_user = flickr_users_get_by_url(0);
if ($flickr_user['user_id'] != $photo['user_id']) {
    error_404();
}
if ($photo['deleted']) {
    $GLOBALS['smarty']->display("page_photo_deleted.txt");
    exit;
}
if (!flickr_photos_permissions_can_view_photo($photo, $GLOBALS['cfg']['user']['id'])) {
    error_403();
}
$perms_map = flickr_photos_permissions_map();
$photo['str_perms'] = $perms_map[$photo['perms']];
$GLOBALS['smarty']->assign_by_ref("photo", $photo);
$owner = users_get_by_id($photo['user_id']);
$GLOBALS['smarty']->assign_by_ref("owner", $owner);
$is_own = $owner['id'] == $GLOBALS['cfg']['user']['id'] ? 1 : 0;
$GLOBALS['smarty']->assign("is_own", $is_own);
# context (next and previous)
$context = get_str("context");
if ($context == 'faves') {
    # please write me
} else {
    if ($context == 'place') {
function flickr_photos_for_user(&$user, $more = array())
{
    $defaults = array('viewer_id' => 0);
    $more = array_merge($defaults, $more);
    $cluster_id = $user['cluster_id'];
    $enc_user = AddSlashes($user['id']);
    $extra = array();
    if ($perms = flickr_photos_permissions_photos_where($user['id'], $more['viewer_id'])) {
        $str_perms = implode(",", $perms);
        $extra[] = "perms IN ({$str_perms})";
    }
    $extra = implode(" AND ", $extra);
    if (strlen($extra)) {
        $extra = " AND {$extra}";
    }
    $sql = "SELECT * FROM FlickrPhotos WHERE user_id='{$enc_user}' {$extra} ORDER BY dateupload DESC";
    if (isset($more['with'])) {
        # Here, we are asking for a the page which a particular photo occurs in a person's stream, which
        # means we'll be passing in the determining the page number ourselves. We do this by figuring out
        # how many photos are before this one in the stream and then dividing.
        $photo = flickr_photos_get_by_id($more['with']);
        $can_see_photo = $photo ? flickr_photos_permissions_can_view_photo($photo, $GLOBALS['cfg']['user']['id']) : false;
        if ($can_see_photo) {
            # The only reason we need this is for spill messing with per-page amounts
            $pagination_more = $more;
            $pagination_more['just_pagination'] = 1;
            $pagination = db_fetch_paginated_users($cluster_id, $sql, $pagination_more);
            $offset_where = " AND dateupload >= '{$photo['dateupload']}'";
            $offset_sql = "SELECT COUNT(*) FROM FlickrPhotos WHERE user_id='{$enc_user}' {$extra} {$offset_where} ORDER BY dateupload DESC";
            $ret = db_fetch_users($cluster_id, $offset_sql);
            if ($ret['ok']) {
                $offset_count = intval(array_pop($ret['rows'][0]));
                $per_page = isset($more['per_page']) ? max(1, $more['per_page']) : $GLOBALS['cfg']['pagination_per_page'];
                $page = ceil($offset_count / $per_page);
                if ($page > $pagination['page_count']) {
                    $page--;
                }
                $more['page'] = $page;
            }
        }
    }
    return db_fetch_paginated_users($cluster_id, $sql, $more);
}