plugin changes to contact_block, also configurable limit

This commit is contained in:
Friendika 2010-12-26 15:48:44 -08:00
parent e8a63b2abb
commit 2abdfb462a
2 changed files with 16 additions and 6 deletions

View file

@ -94,9 +94,11 @@ Current hooks:
$b is the (string) generated HTML of the entry $b is the (string) generated HTML of the entry
(The profile array details are in $a->profile) (The profile array details are in $a->profile)
'contact_block_end' - called when displaying the block of contacts/friends on a 'contact_block_end' - called when formatting the block of contacts/friends on a
profile sidebar profile sidebar has completed
*** $b is the (string) generated HTML of the contact block $b is an array
'contacts' => contact array of entries
'output' => the (string) generated HTML of the contact block
*** = subject to change *** = subject to change

View file

@ -1742,6 +1742,11 @@ if(! function_exists('contact_block')) {
function contact_block() { function contact_block() {
$o = ''; $o = '';
$a = get_app(); $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'])) if((! is_array($a->profile)) || ($a->profile['hide-friends']))
return $o; return $o;
$r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0", $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 .= '<h4 class="contact-h4">' . t('No contacts') . '</h4>'; $o .= '<h4 class="contact-h4">' . t('No contacts') . '</h4>';
return $o; return $o;
} }
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 ORDER BY RAND() LIMIT 24", $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($a->profile['uid']),
intval($shown)
); );
if(count($r)) { if(count($r)) {
$o .= '<h4 class="contact-h4">' . $total . ' ' . t('Contacts') . '</h4><div id="contact-block">'; $o .= '<h4 class="contact-h4">' . $total . ' ' . t('Contacts') . '</h4><div id="contact-block">';
@ -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; return $o;
}} }}