}
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));
}
}