summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fb_views/fb_views_handler_filter_friends.inc26
1 files changed, 11 insertions, 15 deletions
diff --git a/fb_views/fb_views_handler_filter_friends.inc b/fb_views/fb_views_handler_filter_friends.inc
index 2bde355..602af2a 100644
--- a/fb_views/fb_views_handler_filter_friends.inc
+++ b/fb_views/fb_views_handler_filter_friends.inc
@@ -11,21 +11,17 @@ class fb_views_handler_filter_friends extends views_handler_filter_boolean_opera
}
function query() {
- $fb_app = $GLOBALS['_fb_app']; // Set on Canvas and Connect pages.
-
- $uid = $GLOBALS['user']->uid;
-
- if ($fb_app && $uid) {
- $fbu = fb_get_fbu($uid, $fb_app);
-
- if ($fbu) {
- $friends = fb_get_friends($fbu, $fb_app);
-
- if (is_array($friends) && count($friends)) {
- $this->ensure_my_table();
- $this->query->add_where(0, $this->table_alias . '.fbu IN (%s)', implode(',', $friends));
- }
- }
+ // We can't learn friends if user is not logged in.
+ $fbu = fb_facebook_user();
+ if ($fbu) {
+ $friends = fb_get_friends($fbu);
+ }
+ if (!$fbu || !count($friends)) {
+ // Hide all content
+ $friends = array(0);
}
+
+ $this->ensure_my_table();
+ $this->query->add_where(0, $this->table_alias . '.fbu IN (%s)', implode(',', $friends));
}
}