function flickr_photos_permissions_photos_where($owner_id, $viewer_id = 0)
{
    # dumper("owner: {$owner_id} viewer: {$viewer_id}");
    if ($owner_id == $viewer_id) {
        return '';
    }
    $perms_map = flickr_photos_permissions_map('string keys');
    if ($viewer_id == 0) {
        $perms = array($perms_map['public']);
    } else {
        if ($contact = flickr_contacts_get_contact($owner_id, $viewer_id)) {
            $rel_map = flickr_contacts_relationship_map();
            $str_rel = $rel_map[$contact['rel']];
            $perms = array($perms_map['public']);
            if ($str_rel == 'friends') {
                $perms[] = $perms_map['friends'];
                $perms[] = $perms_map['friends and family'];
            } else {
                if ($str_rel == 'family') {
                    $perms[] = $perms_map['family'];
                    $perms[] = $perms_map['friends and family'];
                } else {
                }
            }
        } else {
            $perms = array($perms_map['public']);
        }
    }
    return $perms;
}
function _flickr_photos_import_prepare_photo(&$user, $photo)
{
    $photo['user_id'] = $user['id'];
    unset($photo['owner']);
    unset($photo['ownername']);
    $fmt = "Y-m-d H:i:s";
    $photo['dateupload'] = gmdate($fmt, $photo['dateupload']);
    $ispublic = $photo['ispublic'] ? 1 : 0;
    $isfamily = $photo['isfamily'] ? 1 : 0;
    $isfriend = $photo['isfriend'] ? 1 : 0;
    $perms_map = flickr_photos_permissions_map("string keys");
    if ($ispublic) {
        $perms = $perms_map['public'];
    } else {
        if ($isfamily && $isfriend) {
            $perms = $perms_map['friends and family'];
        } else {
            if ($isfamily) {
                $perms = $perms_map['family'];
            } else {
                if ($isfriend) {
                    $perms = $perms_map['friends'];
                } else {
                    $perms = $perms_map['private'];
                }
            }
        }
    }
    $photo['perms'] = $perms;
    # echo "{$photo['id']} perms:{$perms} public:{$ispublic} friend:{$isfriend} family:{$isfamily}\n";
    unset($photo['ispublic']);
    unset($photo['isfamily']);
    unset($photo['isfriend']);
    # media (status)
    $photo['media'] = $photo['media'] == 'photo' ? 0 : 1;
    unset($photo['media_status']);
    # Strictly speaking, I am probably most responsible for
    # the need to do this. I'm sorry... (20111121/straup)
    $photo['hasgeo'] = $photo['accuracy'] ? 1 : 0;
    if (!$photo['hasgeo']) {
        unset($photo['latitude']);
        unset($photo['longitude']);
        unset($photo['accuracy']);
    }
    if ($photo['hasgeo']) {
        $geo_perms_map = flickr_geo_permissions_map("string keys");
        if ($photo['geo_is_public']) {
            $geoperms = $geo_perms_map['public'];
        } else {
            if ($photo['geo_is_contact']) {
                $geoperms = $geo_perms_map['contacts'];
            } else {
                if ($photo['geo_is_family'] && $photo['geo_is_friend']) {
                    $geoperms = $geo_perms_map['friends and family'];
                } else {
                    if ($photo['geo_is_friend']) {
                        $geoperms = $geo_perms_map['friends'];
                    } else {
                        if ($photo['geo_is_family']) {
                            $geoperms = $geo_perms_map['family'];
                        } else {
                            $geoperms = $geo_perms_map['private'];
                        }
                    }
                }
            }
        }
        $photo['geoperms'] = $geoperms;
        $photo['geocontext'] = $photo['context'];
        unset($photo['place_id']);
        unset($photo['geo_is_family']);
        unset($photo['geo_is_friend']);
        unset($photo['geo_is_contact']);
        unset($photo['geo_is_public']);
    }
    if (isset($photo['context'])) {
        unset($photo['context']);
    }
    if (isset($photo['date_faved'])) {
        unset($photo['date_faved']);
    }
    return $photo;
}
Example #3
0
# 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') {
        # please write me
    } else {
        $more = array('viewer_id' => $GLOBALS['cfg']['user']['id']);