From 842ac46857b7cc10f2fc2e653b350be2a3508cfe Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 8 Feb 2015 23:35:29 +0100 Subject: [PATCH] Scrape now contains the number of contacts as well. --- boot.php | 15 ++++++++++++++- mod/noscrape.php | 13 +++++++++++++ view/templates/profile_vcard.tpl | 2 ++ view/theme/vier/templates/profile_vcard.tpl | 2 ++ 4 files changed, 31 insertions(+), 1 deletion(-) diff --git a/boot.php b/boot.php index dd6bc6ac5d..96b19add13 100644 --- a/boot.php +++ b/boot.php @@ -1673,8 +1673,20 @@ if(! function_exists('profile_sidebar')) { if (!$block){ $contact_block = contact_block(); - } + if(is_array($a->profile) AND !$a->profile['hide-friends']) { + $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 AND `archive` = 0 + AND `network` IN ('%s', '%s', '%s', '%s', '')", + intval($a->profile['uid']), + dbesc(NETWORK_DFRN), + dbesc(NETWORK_DIASPORA), + dbesc(NETWORK_OSTATUS), + dbesc(NETWORK_STATUSNET) + ); + if(count($r)) + $contacts = intval($r[0]['total']); + } + } $p = array(); foreach($profile as $k => $v) { @@ -1699,6 +1711,7 @@ if(! function_exists('profile_sidebar')) { '$homepage' => $homepage, '$about' => $about, '$network' => t('Network:'), + '$contacts' => $contacts, '$diaspora' => $diaspora, '$contact_block' => $contact_block, )); diff --git a/mod/noscrape.php b/mod/noscrape.php index 10df72eeb8..a93abd29a8 100644 --- a/mod/noscrape.php +++ b/mod/noscrape.php @@ -31,6 +31,19 @@ function noscrape_init(&$a) { 'tags' => $keywords ); + if(is_array($a->profile) AND !$a->profile['hide-friends']) { + $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `self` = 0 AND `blocked` = 0 and `pending` = 0 AND `hidden` = 0 AND `archive` = 0 + AND `network` IN ('%s', '%s', '%s', '%s', '')", + intval($a->profile['uid']), + dbesc(NETWORK_DFRN), + dbesc(NETWORK_DIASPORA), + dbesc(NETWORK_OSTATUS), + dbesc(NETWORK_STATUSNET) + ); + if(count($r)) + $json_info["contacts"] = intval($r[0]['total']); + } + //These are optional fields. $profile_fields = array('pdesc', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital', 'about'); foreach($profile_fields as $field) diff --git a/view/templates/profile_vcard.tpl b/view/templates/profile_vcard.tpl index 9bbb7f8a42..097d44cc3b 100644 --- a/view/templates/profile_vcard.tpl +++ b/view/templates/profile_vcard.tpl @@ -31,6 +31,8 @@ {{if $profile.pubkey}}{{/if}} + {{if $contacts}}{{/if}} + {{if $marital}}
{{$marital}}
{{$profile.marital}}
{{/if}} {{if $homepage}}
{{$homepage}}
{{$profile.homepage}}
{{/if}} diff --git a/view/theme/vier/templates/profile_vcard.tpl b/view/theme/vier/templates/profile_vcard.tpl index 9d0c65601a..ca5f44cf1c 100644 --- a/view/theme/vier/templates/profile_vcard.tpl +++ b/view/theme/vier/templates/profile_vcard.tpl @@ -40,6 +40,8 @@ {{if $profile.pubkey}}{{/if}} + {{if $contacts}}{{/if}} + {{if $marital}}
{{$marital}}
{{$profile.marital}}
{{/if}} {{if $homepage}}
{{$homepage}}
{{$profile.homepage}}
{{/if}} -- 2.39.5