Permalink
Browse files

finish passing viewer_id in dollar-more (where it makes sense)

  • Loading branch information...
1 parent 92828a5 commit a01620cab20da42fcd8487fea8649f96d2b6cc70 straup committed Nov 24, 2011
View
@@ -24,14 +24,16 @@
$owner = users_get_by_id($flickr_user['user_id']);
+ $is_own = ($owner['id'] == $GLOBALS['cfg']['user']['id']) ? 1 : 0;
+ $GLOBALS['smarty']->assign("is_own", $is_own);
+
#
$more = array(
+ 'viewer_id' => $GLOBALS['cfg']['user']['id'],
'page' => get_int32("page"),
);
- #
-
if ($by_alias = get_str("by_alias")){
$more['by_owner'] = flickr_users_get_by_path_alias($by_alias);
}
@@ -42,12 +44,7 @@
else {}
- #
-
- $is_own = ($owner['id'] == $GLOBALS['cfg']['user']['id']) ? 1 : 0;
- $GLOBALS['smarty']->assign("is_own", $is_own);
-
- $faves = flickr_faves_for_user($owner, $GLOBALS['cfg']['user']['id'], $more);
+ $faves = flickr_faves_for_user($owner, $more);
$photos = array();
foreach ($faves['rows'] as $f){
View
@@ -56,7 +56,12 @@
}
else {
- $bookends = flickr_photos_get_bookends($photo, $GLOBALS['cfg']['user']['id']);
+
+ $more = array(
+ 'viewer_id' => $GLOBALS['cfg']['user']['id'],
+ );
+
+ $bookends = flickr_photos_get_bookends($photo, $more);
}
$GLOBALS['smarty']->assign_by_ref("before", $bookends['before']);
@@ -25,16 +25,17 @@
$owner = users_get_by_id($flickr_user['user_id']);
+ $is_own = ($owner['id'] == $GLOBALS['cfg']['user']['id']) ? 1 : 0;
+ $GLOBALS['smarty']->assign("is_own", $is_own);
+
#
$more = array(
'page' => get_int32("page"),
+ 'viewer_id' => $GLOBALS['cfg']['user']['id'],
);
- $is_own = ($owner['id'] == $GLOBALS['cfg']['user']['id']) ? 1 : 0;
- $GLOBALS['smarty']->assign("is_own", $is_own);
-
- $photos = flickr_photos_for_user($owner, $GLOBALS['cfg']['user']['id'], $more);
+ $photos = flickr_photos_for_user($owner, $more);
$count = count($photos['rows']);
@@ -27,11 +27,6 @@
$GLOBALS['smarty']->assign_by_ref("owner", $owner);
$GLOBALS['smarty']->assign("is_own", $is_own);
- # Note: these needs to be strictly accurate until I tweak the
- # schema definition(s) for camera stuff in parallel-flickr-solr
- # https://github.com/straup/parallel-flickr-solr/blob/master/solr/conf/schema.xml
- # (20111122/straup)
-
$make = get_str("make");
$model = get_str("model");
@@ -27,8 +27,6 @@
$GLOBALS['smarty']->assign_by_ref("owner", $owner);
$GLOBALS['smarty']->assign("is_own", $is_own);
- # TO DO: check to see if facet is apssed in as a q uery param
-
$facet = get_str("facet");
$placetypes = flickr_places_valid_placetypes();
@@ -2,15 +2,21 @@
#################################################################
- function flickr_faves_for_user(&$user, $viewer_id=0, $more=array()){
+ function flickr_faves_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']);
- # FIX ME: PERMISSIONS
+ # TO DO: PERMISSIONS
$extra = "";
- # FIX ME: INDEXES
+ # TO DO: INDEXES
$sql = "SELECT * FROM FlickrFaves WHERE user_id='{$enc_user}'";
@@ -77,6 +83,9 @@ function flickr_faves_add_fave(&$viewer, &$photo, $date_faved=0){
return $rsp;
}
+ # TO DO: index/update the photo in solr and insert $viewer['id']
+ # into the faved_by column (20111123/straup)
+
return array(
'ok' => 1
);
@@ -97,12 +97,18 @@ function flickr_photos_update_photo(&$photo, $update){
#################################################################
- function flickr_photos_count_for_user(&$user, $viewer_id=0){
+ function flickr_photos_count_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']);
- if ($perms = flickr_photos_permissions_photos_where($user['id'], $viewer_id)){
+ if ($perms = flickr_photos_permissions_photos_where($user['id'], $more['viewer_id'])){
$str_perms = implode(",", $perms);
$extra = " AND perms IN ({$str_perms})";
}
@@ -115,24 +121,20 @@ function flickr_photos_count_for_user(&$user, $viewer_id=0){
#################################################################
- function flickr_photos_for_user(&$user, $viewer_id=0, $more=array()){
+ 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();
- # TO DO: first of all this bit is probably wrong (and should
- # be in a separate function) but if it stays the "_count"
- # function needs to be updated (20111117/straup)
-
- if (isset($more['ymd'])){
-
- $enc_ymd = AddSlashes($more['ymd']);
- $extra[] = "DATE_FORMAT(datetaken, '%Y-%m-%d') = '{$enc_ymd}'";
- }
-
- if ($perms = flickr_photos_permissions_photos_where($user['id'], $viewer_id)){
+ if ($perms = flickr_photos_permissions_photos_where($user['id'], $more['viewer_id'])){
$str_perms = implode(",", $perms);
$extra[] = "perms IN ({$str_perms})";
}
@@ -171,27 +173,33 @@ function flickr_photos_add_photo($photo){
#################################################################
- function flickr_photos_get_bookends(&$photo, $viewer_id=0){
+ function flickr_photos_get_bookends(&$photo, $more=array()){
+
+ $defaults = array(
+ 'viewer_id' => 0,
+ );
+
+ $more = array_merge($defaults, $more);
$user = users_get_by_id($photo['user_id']);
$cluster_id = $user['cluster_id'];
$enc_id = AddSlashes($photo['id']);
$enc_user = AddSlashes($photo['user_id']);
- if ($perms = flickr_photos_permissions_photos_where($user['id'], $viewer_id)){
+ if ($perms = flickr_photos_permissions_photos_where($user['id'], $more['viewer_id'])){
$str_perms = implode(",", $perms);
$extra = " AND perms IN ({$str_perms})";
}
- # FIX ME: INDEXES
+ # TO DO: INDEXES
$sql = "SELECT * FROM FlickrPhotos WHERE user_id = '{$enc_user}' AND id < '{$enc_id}' {$extra} ORDER BY id DESC LIMIT 1";
$rsp = db_fetch_users($cluster_id, $sql);
$before = $rsp['rows'];
- # FIX ME: INDEXES
+ # TO DO: INDEXES
$sql = "SELECT * FROM FlickrPhotos WHERE user_id='{$enc_user}' AND id > '{$enc_id}' {$extra} ORDER BY id ASC LIMIT 1";
$rsp = db_fetch_users($cluster_id, $sql);

0 comments on commit a01620c

Please sign in to comment.