From 842ac46857b7cc10f2fc2e653b350be2a3508cfe Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Sun, 8 Feb 2015 23:35:29 +0100 Subject: [PATCH 1/3] 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}} From 05319083c69f62902f32738966cb8150bf2939f0 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 9 Feb 2015 21:45:17 +0100 Subject: [PATCH 2/3] Take the UID from another place. --- boot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot.php b/boot.php index 696928145f..503d0945d4 100644 --- a/boot.php +++ b/boot.php @@ -1682,7 +1682,7 @@ if(! function_exists('profile_sidebar')) { 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']), + intval($profile['uid']), dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), dbesc(NETWORK_OSTATUS), From 219932f692e09924685e34f5866135c6956dd347 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 17 Feb 2015 19:27:13 +0100 Subject: [PATCH 3/3] Removed Statusnet from the counting of contacts for scrape/noscrape --- boot.php | 5 ++--- mod/noscrape.php | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/boot.php b/boot.php index d2de87fc60..7ca4865d14 100644 --- a/boot.php +++ b/boot.php @@ -1681,12 +1681,11 @@ if(! function_exists('profile_sidebar')) { 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', '')", + AND `network` IN ('%s', '%s', '%s', '')", intval($profile['uid']), dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), - dbesc(NETWORK_OSTATUS), - dbesc(NETWORK_STATUSNET) + dbesc(NETWORK_OSTATUS) ); if(count($r)) $contacts = intval($r[0]['total']); diff --git a/mod/noscrape.php b/mod/noscrape.php index a93abd29a8..170c737767 100644 --- a/mod/noscrape.php +++ b/mod/noscrape.php @@ -33,12 +33,11 @@ function noscrape_init(&$a) { 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', '')", + AND `network` IN ('%s', '%s', '%s', '')", intval($a->profile['uid']), dbesc(NETWORK_DFRN), dbesc(NETWORK_DIASPORA), - dbesc(NETWORK_OSTATUS), - dbesc(NETWORK_STATUSNET) + dbesc(NETWORK_OSTATUS) ); if(count($r)) $json_info["contacts"] = intval($r[0]['total']);