streams/Zotlabs/Widget/Common_friends.php

57 lines
1.3 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
2021-12-02 22:33:36 +00:00
use App;
2021-12-02 23:02:31 +00:00
class Common_friends
{
2017-09-20 00:35:57 +00:00
2021-12-02 23:02:31 +00:00
public function widget($arr)
{
2017-09-20 00:35:57 +00:00
2021-12-02 23:02:31 +00:00
if ((!App::$profile['profile_uid'])
|| (!perm_is_allowed(App::$profile['profile_uid'], get_observer_hash(), 'view_contacts'))) {
return '';
}
2017-09-20 00:35:57 +00:00
2021-12-02 23:02:31 +00:00
return self::common_friends_visitor_widget(App::$profile['profile_uid']);
2019-01-18 21:04:05 +00:00
2021-12-02 23:02:31 +00:00
}
2019-01-18 21:04:05 +00:00
2021-12-02 23:02:31 +00:00
public static function common_friends_visitor_widget($profile_uid, $cnt = 25)
{
2019-01-18 21:04:05 +00:00
2021-12-02 23:02:31 +00:00
if (local_channel() == $profile_uid)
return;
2019-01-18 21:04:05 +00:00
2021-12-02 23:02:31 +00:00
$observer_hash = get_observer_hash();
2019-01-18 21:04:05 +00:00
2021-12-02 23:02:31 +00:00
if ((!$observer_hash) || (!perm_is_allowed($profile_uid, $observer_hash, 'view_contacts')))
return;
2019-01-18 21:04:05 +00:00
2021-12-02 23:02:31 +00:00
require_once('include/socgraph.php');
2019-01-18 21:04:05 +00:00
2021-12-02 23:02:31 +00:00
$t = count_common_friends($profile_uid, $observer_hash);
2019-01-18 21:04:05 +00:00
2021-12-02 23:02:31 +00:00
if (!$t)
return;
2019-01-18 21:04:05 +00:00
2021-12-02 23:02:31 +00:00
$r = common_friends($profile_uid, $observer_hash, 0, $cnt, true);
2017-09-20 00:35:57 +00:00
2021-12-02 23:02:31 +00:00
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
));
}
2019-01-18 21:04:05 +00:00
2017-09-20 00:35:57 +00:00
}