From 2abdfb462a34a5c469efe12243e2a91d3fa39a03 Mon Sep 17 00:00:00 2001 From: Friendika Date: Sun, 26 Dec 2010 15:48:44 -0800 Subject: [PATCH] plugin changes to contact_block, also configurable limit --- addon/README | 8 +++++--- boot.php | 14 +++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/addon/README b/addon/README index 84f8569248..8d5088f783 100644 --- a/addon/README +++ b/addon/README @@ -94,9 +94,11 @@ Current hooks: $b is the (string) generated HTML of the entry (The profile array details are in $a->profile) -'contact_block_end' - called when displaying the block of contacts/friends on a - profile sidebar -*** $b is the (string) generated HTML of the contact block +'contact_block_end' - called when formatting the block of contacts/friends on a + profile sidebar has completed + $b is an array + 'contacts' => contact array of entries + 'output' => the (string) generated HTML of the contact block *** = subject to change diff --git a/boot.php b/boot.php index 7b7adba828..6565d40bd8 100644 --- a/boot.php +++ b/boot.php @@ -1742,6 +1742,11 @@ if(! function_exists('contact_block')) { function contact_block() { $o = ''; $a = get_app(); + + $shown = get_pconfig($a->profile['uid'],'system','display_friend_count'); + if(! $shown) + $shown = 24; + if((! is_array($a->profile)) || ($a->profile['hide-friends'])) return $o; $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0", @@ -1754,8 +1759,9 @@ function contact_block() { $o .= '

' . t('No contacts') . '

'; return $o; } - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 ORDER BY RAND() LIMIT 24", - intval($a->profile['uid']) + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 ORDER BY RAND() LIMIT %d", + intval($a->profile['uid']), + intval($shown) ); if(count($r)) { $o .= '

' . $total . ' ' . t('Contacts') . '

'; @@ -1778,7 +1784,9 @@ function contact_block() { } - call_hooks('contact_block_end', $o); + $arr = array('contacts' => $r, 'output' => $o); + + call_hooks('contact_block_end', $arr); return $o; }}