streams/Zotlabs/Widget/Common_friends.php

52 lines
1.1 KiB
PHP
Raw Normal View History

2017-09-20 00:35:57 +00:00
<?php
namespace Zotlabs\Widget;
2019-01-18 21:04:05 +00:00
2017-09-20 00:35:57 +00:00
class Common_friends {
function widget($arr) {
if((! \App::$profile['profile_uid'])
|| (! perm_is_allowed(\App::$profile['profile_uid'],get_observer_hash(),'view_contacts'))) {
return '';
}
2019-01-18 21:04:05 +00:00
return self::common_friends_visitor_widget(\App::$profile['profile_uid']);
}
static function common_friends_visitor_widget($profile_uid,$cnt = 25) {
if(local_channel() == $profile_uid)
return;
$observer_hash = get_observer_hash();
if((! $observer_hash) || (! perm_is_allowed($profile_uid,$observer_hash,'view_contacts')))
return;
require_once('include/socgraph.php');
$t = count_common_friends($profile_uid,$observer_hash);
if(! $t)
return;
$r = common_friends($profile_uid,$observer_hash,0,$cnt,true);
return replace_macros(get_markup_template('remote_friends_common.tpl'), array(
'$desc' => t('Common Connections'),
'$base' => z_root(),
'$uid' => $profile_uid,
'$cid' => $observer,
'$linkmore' => (($t > $cnt) ? 'true' : ''),
'$more' => sprintf( t('View all %d common connections'), $t),
'$items' => $r
));
2017-09-20 00:35:57 +00:00
}
2019-01-18 21:04:05 +00:00
2017-09-20 00:35:57 +00:00
}