Merge pull request #10730 from annando/public-contact-list
Display the public contacts for profile visitors
This commit is contained in:
commit
be3fb5f205
|
@ -44,10 +44,16 @@ class ContactBlock
|
||||||
* @hook contact_block_end (contacts=>array, output=>string)
|
* @hook contact_block_end (contacts=>array, output=>string)
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function getHTML(array $profile)
|
public static function getHTML(array $profile, int $visitor_uid = null)
|
||||||
{
|
{
|
||||||
$o = '';
|
$o = '';
|
||||||
|
|
||||||
|
if (is_null($visitor_uid) || ($visitor_uid == $profile['uid'])) {
|
||||||
|
$contact_uid = $profile['uid'];
|
||||||
|
} else {
|
||||||
|
$contact_uid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
$shown = DI::pConfig()->get($profile['uid'], 'system', 'display_friend_count', 24);
|
$shown = DI::pConfig()->get($profile['uid'], 'system', 'display_friend_count', 24);
|
||||||
if ($shown == 0) {
|
if ($shown == 0) {
|
||||||
return $o;
|
return $o;
|
||||||
|
@ -82,7 +88,7 @@ class ContactBlock
|
||||||
$rel = [Contact::FOLLOWER, Contact::FRIEND];
|
$rel = [Contact::FOLLOWER, Contact::FRIEND];
|
||||||
}
|
}
|
||||||
|
|
||||||
$contact_ids_stmt = DBA::select('contact', ['id'], [
|
$personal_contacts = DBA::selectToArray('contact', ['uri-id'], [
|
||||||
'uid' => $profile['uid'],
|
'uid' => $profile['uid'],
|
||||||
'self' => false,
|
'self' => false,
|
||||||
'blocked' => false,
|
'blocked' => false,
|
||||||
|
@ -93,13 +99,10 @@ class ContactBlock
|
||||||
'network' => Protocol::FEDERATED,
|
'network' => Protocol::FEDERATED,
|
||||||
], ['limit' => $shown]);
|
], ['limit' => $shown]);
|
||||||
|
|
||||||
if (DBA::isResult($contact_ids_stmt)) {
|
$contact_uriids = array_column($personal_contacts, 'uri-id');
|
||||||
$contact_ids = [];
|
|
||||||
while($contact = DBA::fetch($contact_ids_stmt)) {
|
|
||||||
$contact_ids[] = $contact["id"];
|
|
||||||
}
|
|
||||||
|
|
||||||
$contacts_stmt = DBA::select('contact', ['id', 'uid', 'addr', 'url', 'name', 'thumb', 'avatar', 'network'], ['id' => $contact_ids]);
|
if (!empty($contact_uriids)) {
|
||||||
|
$contacts_stmt = DBA::select('contact', ['id', 'uid', 'addr', 'url', 'name', 'thumb', 'avatar', 'network'], ['uri-id' => $contact_uriids, 'uid' => $contact_uid]);
|
||||||
|
|
||||||
if (DBA::isResult($contacts_stmt)) {
|
if (DBA::isResult($contacts_stmt)) {
|
||||||
$contacts_title = DI::l10n()->tt('%d Contact', '%d Contacts', $total);
|
$contacts_title = DI::l10n()->tt('%d Contact', '%d Contacts', $total);
|
||||||
|
@ -113,8 +116,6 @@ class ContactBlock
|
||||||
|
|
||||||
DBA::close($contacts_stmt);
|
DBA::close($contacts_stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
DBA::close($contact_ids_stmt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('widget/contacts.tpl');
|
$tpl = Renderer::getMarkupTemplate('widget/contacts.tpl');
|
||||||
|
|
|
@ -406,7 +406,7 @@ class Profile
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$block && $show_contacts) {
|
if (!$block && $show_contacts) {
|
||||||
$contact_block = ContactBlock::getHTML($profile);
|
$contact_block = ContactBlock::getHTML($profile, local_user());
|
||||||
|
|
||||||
if (is_array($profile) && !$profile['hide-friends']) {
|
if (is_array($profile) && !$profile['hide-friends']) {
|
||||||
$contact_count = DBA::count('contact', [
|
$contact_count = DBA::count('contact', [
|
||||||
|
|
Loading…
Reference in a new issue