From 7baeb451836752a612ca976db04aeffcafeb621d Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 2 Mar 2014 19:40:59 -0800 Subject: some anomolies found when viewing connections in various cases. --- include/text.php | 12 +++++++++--- include/zot.php | 21 +++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/text.php b/include/text.php index dfd35c769..839e63f5e 100755 --- a/include/text.php +++ b/include/text.php @@ -665,8 +665,11 @@ function contact_block() { if((! is_array($a->profile)) || ($a->profile['hide_friends'])) return $o; - $r = q("SELECT COUNT(abook_id) AS total FROM abook WHERE abook_channel = %d and abook_flags = 0", - intval($a->profile['uid']) + $r = q("SELECT COUNT(abook_id) AS total FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and abook_flags = 0 and not (xchan_flags & %d) and not (xchan_flags & %d) and not (xchan_flags & %d)", + intval($a->profile['uid']), + intval(XCHAN_FLAGS_HIDDEN), + intval(XCHAN_FLAGS_ORPHAN), + intval(XCHAN_FLAGS_DELETED) ); if(count($r)) { $total = intval($r[0]['total']); @@ -677,8 +680,11 @@ function contact_block() { } else { - $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash WHERE abook_channel = %d AND abook_flags = 0 ORDER BY RAND() LIMIT %d", + $r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash WHERE abook_channel = %d AND abook_flags = 0 and not (xchan_flags & %d ) and not (xchan_flags & %d ) and not (xchan_flags & %d ) ORDER BY RAND() LIMIT %d", intval($a->profile['uid']), + intval(XCHAN_FLAGS_HIDDEN), + intval(XCHAN_FLAGS_ORPHAN), + intval(XCHAN_FLAGS_DELETED), intval($shown) ); diff --git a/include/zot.php b/include/zot.php index d7d7eb419..a52abfecd 100644 --- a/include/zot.php +++ b/include/zot.php @@ -330,8 +330,15 @@ function zot_refresh($them,$channel = null, $force = false) { else $permissions = $j['permissions']; + $connected_set = false; + if($permissions && is_array($permissions)) { foreach($permissions as $k => $v) { + // The connected permission means you are in their address book + if($k === 'connected') { + $connected_set = intval($v); + continue; + } if($v) { $their_perms = $their_perms | intval($global_perms[$k][1]); } @@ -353,6 +360,20 @@ function zot_refresh($them,$channel = null, $force = false) { intval($channel['channel_id']), intval(ABOOK_FLAG_SELF) ); + if($connected_set === 0) { + + // if they are in your address book but you aren't in theirs, mark their address book entry hidden. + + $y1 = q("update abook set abook_flags = (abook_flags | %d) + where abook_xchan = '%s' and abook_channel = %d + and not (abook_flags & %d) limit 1", + intval(ABOOK_FLAG_HIDDEN), + dbesc($x['hash']), + intval($channel['channel_id']), + intval(ABOOK_FLAG_SELF) + ); + } + if(! $y) logger('abook update failed'); else { -- cgit v1.2.3