show hidden connections in contact block if and only if the observer is the profile owner
This commit is contained in:
		| @@ -705,12 +705,22 @@ function contact_block() { | |||||||
| 	if($shown == 0) | 	if($shown == 0) | ||||||
| 		return; | 		return; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 	$is_owner = ((local_user() && local_user() == $a->profile['uid']) ? true : false); | ||||||
|  |  | ||||||
|  | 	$abook_flags = ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF; | ||||||
|  | 	$xchan_flags = XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED; | ||||||
|  | 	if(! $is_owner) { | ||||||
|  | 		$abook_flags = $abook_flags | ABOOK_FLAGS_HIDDEN; | ||||||
|  | 		$xchan_flags = $xchan_flags | XCHAN_FLAGS_HIDDEN; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	if((! is_array($a->profile)) || ($a->profile['hide_friends'])) | 	if((! is_array($a->profile)) || ($a->profile['hide_friends'])) | ||||||
| 		return $o; | 		return $o; | ||||||
| 	$r = q("SELECT COUNT(abook_id) AS total FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and not ( abook_flags & %d ) and not (xchan_flags & %d)", | 	$r = q("SELECT COUNT(abook_id) AS total FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d and not ( abook_flags & %d ) and not (xchan_flags & %d)", | ||||||
| 			intval($a->profile['uid']), | 			intval($a->profile['uid']), | ||||||
| 			intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF), | 			intval($abook_flags), | ||||||
| 			intval(XCHAN_FLAGS_HIDDEN|XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED) | 			intval($xchan_flags) | ||||||
| 	); | 	); | ||||||
| 	if(count($r)) { | 	if(count($r)) { | ||||||
| 		$total = intval($r[0]['total']); | 		$total = intval($r[0]['total']); | ||||||
| @@ -723,8 +733,8 @@ function contact_block() { | |||||||
|  |  | ||||||
| 		$r = q("SELECT abook.*, xchan.* FROM abook left join xchan on abook.abook_xchan = xchan.xchan_hash WHERE abook_channel = %d AND not ( abook_flags & %d) and not (xchan_flags & %d ) 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 not ( abook_flags & %d) and not (xchan_flags & %d ) ORDER BY RAND() LIMIT %d", | ||||||
| 				intval($a->profile['uid']), | 				intval($a->profile['uid']), | ||||||
| 				intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF), | 				intval($abook_flags), | ||||||
| 				intval(XCHAN_FLAGS_HIDDEN|XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED), | 				intval($xchan_flags), | ||||||
| 				intval($shown) | 				intval($shown) | ||||||
| 		); | 		); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -28,11 +28,19 @@ function viewconnections_content(&$a) { | |||||||
| 		return; | 		return; | ||||||
| 	}  | 	}  | ||||||
|  |  | ||||||
|  | 	$is_owner = ((local_user() && local_user() == $a->profile['uid']) ? true : false); | ||||||
|  |  | ||||||
|  | 	$abook_flags = ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF; | ||||||
|  | 	$xchan_flags = XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED; | ||||||
|  | 	if(! $is_owner) { | ||||||
|  | 		$abook_flags = $abook_flags | ABOOK_FLAGS_HIDDEN; | ||||||
|  | 		$xchan_flags = $xchan_flags | XCHAN_FLAGS_HIDDEN; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	$r = q("SELECT count(*) as total FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and not (abook_flags & %d ) and not ( xchan_flags & %d ) ", | 	$r = q("SELECT count(*) as total FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and not (abook_flags & %d ) and not ( xchan_flags & %d ) ", | ||||||
| 		intval($a->profile['uid']), | 		intval($a->profile['uid']), | ||||||
| 		intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF), | 		intval($abook_flags), | ||||||
| 		intval(XCHAN_FLAGS_HIDDEN|XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED) | 		intval($xchan_flags) | ||||||
| 	); | 	); | ||||||
| 	if($r) { | 	if($r) { | ||||||
| 		$a->set_pager_total($r[0]['total']); | 		$a->set_pager_total($r[0]['total']); | ||||||
| @@ -40,8 +48,8 @@ function viewconnections_content(&$a) { | |||||||
|  |  | ||||||
| 	$r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and not ( abook_flags & %d ) and not ( xchan_flags & %d ) order by xchan_name LIMIT %d , %d ", | 	$r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and not ( abook_flags & %d ) and not ( xchan_flags & %d ) order by xchan_name LIMIT %d , %d ", | ||||||
| 		intval($a->profile['uid']), | 		intval($a->profile['uid']), | ||||||
| 		intval(ABOOK_FLAG_HIDDEN|ABOOK_FLAG_PENDING|ABOOK_FLAG_SELF), | 		intval($abook_flags), | ||||||
| 		intval(XCHAN_FLAGS_HIDDEN|XCHAN_FLAGS_ORPHAN|XCHAN_FLAGS_DELETED), | 		intval($xchan_flags), | ||||||
| 		intval($a->pager['start']), | 		intval($a->pager['start']), | ||||||
| 		intval($a->pager['itemspage']) | 		intval($a->pager['itemspage']) | ||||||
| 	); | 	); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user