Merge pull request #7069 from nupplaphil/task/mod_allfriends
Move mod/allfriends to src/Module/AllFriends
This commit is contained in:
commit
d48b100f78
|
@ -1,106 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @file mod/allfriends.php
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Friendica\App;
|
|
||||||
use Friendica\Content\ContactSelector;
|
|
||||||
use Friendica\Content\Pager;
|
|
||||||
use Friendica\Core\L10n;
|
|
||||||
use Friendica\Core\Renderer;
|
|
||||||
use Friendica\Core\System;
|
|
||||||
use Friendica\Database\DBA;
|
|
||||||
use Friendica\Model;
|
|
||||||
use Friendica\Module;
|
|
||||||
use Friendica\Util\Proxy as ProxyUtils;
|
|
||||||
|
|
||||||
|
|
||||||
function allfriends_content(App $a)
|
|
||||||
{
|
|
||||||
$o = '';
|
|
||||||
if (!local_user()) {
|
|
||||||
notice(L10n::t('Permission denied.') . EOL);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$cid = 0;
|
|
||||||
if ($a->argc > 1) {
|
|
||||||
$cid = intval($a->argv[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$cid) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$uid = $a->user['uid'];
|
|
||||||
|
|
||||||
$contact = DBA::selectFirst('contact', ['name', 'url', 'photo', 'uid', 'id'], ['id' => $cid, 'uid' => local_user()]);
|
|
||||||
|
|
||||||
if (!DBA::isResult($contact)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$a->page['aside'] = "";
|
|
||||||
Model\Profile::load($a, "", 0, Model\Contact::getDetailsByURL($contact["url"]));
|
|
||||||
|
|
||||||
$total = Model\GContact::countAllFriends(local_user(), $cid);
|
|
||||||
|
|
||||||
$pager = new Pager($a->query_string);
|
|
||||||
|
|
||||||
$r = Model\GContact::allFriends(local_user(), $cid, $pager->getStart(), $pager->getItemsPerPage());
|
|
||||||
if (!DBA::isResult($r)) {
|
|
||||||
$o .= L10n::t('No friends to display.');
|
|
||||||
return $o;
|
|
||||||
}
|
|
||||||
|
|
||||||
$id = 0;
|
|
||||||
|
|
||||||
$entries = [];
|
|
||||||
foreach ($r as $rr) {
|
|
||||||
//get further details of the contact
|
|
||||||
$contact_details = Model\Contact::getDetailsByURL($rr['url'], $uid, $rr);
|
|
||||||
|
|
||||||
$connlnk = '';
|
|
||||||
// $rr[cid] is only available for common contacts. So if the contact is a common one, use contact_photo_menu to generate the photo_menu
|
|
||||||
// If the contact is not common to the user, Connect/Follow' will be added to the photo menu
|
|
||||||
if ($rr['cid']) {
|
|
||||||
$rr['id'] = $rr['cid'];
|
|
||||||
$photo_menu = Model\Contact::photoMenu($rr);
|
|
||||||
} else {
|
|
||||||
$connlnk = System::baseUrl() . '/follow/?url=' . $rr['url'];
|
|
||||||
$photo_menu = [
|
|
||||||
'profile' => [L10n::t("View Profile"), Model\Contact::magicLink($rr['url'])],
|
|
||||||
'follow' => [L10n::t("Connect/Follow"), $connlnk]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
$entry = [
|
|
||||||
'url' => Model\Contact::magicLink($rr['url']),
|
|
||||||
'itemurl' => defaults($contact_details, 'addr', $rr['url']),
|
|
||||||
'name' => $contact_details['name'],
|
|
||||||
'thumb' => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::SIZE_THUMB),
|
|
||||||
'img_hover' => $contact_details['name'],
|
|
||||||
'details' => $contact_details['location'],
|
|
||||||
'tags' => $contact_details['keywords'],
|
|
||||||
'about' => $contact_details['about'],
|
|
||||||
'account_type' => Model\Contact::getAccountType($contact_details),
|
|
||||||
'network' => ContactSelector::networkToName($contact_details['network'], $contact_details['url']),
|
|
||||||
'photo_menu' => $photo_menu,
|
|
||||||
'conntxt' => L10n::t('Connect'),
|
|
||||||
'connlnk' => $connlnk,
|
|
||||||
'id' => ++$id,
|
|
||||||
];
|
|
||||||
$entries[] = $entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
$tab_str = Module\Contact::getTabsHTML($a, $contact, 4);
|
|
||||||
|
|
||||||
$tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl');
|
|
||||||
$o .= Renderer::replaceMacros($tpl, [
|
|
||||||
'$tab_str' => $tab_str,
|
|
||||||
'$contacts' => $entries,
|
|
||||||
'$paginate' => $pager->renderFull($total),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $o;
|
|
||||||
}
|
|
|
@ -40,84 +40,12 @@ class Router
|
||||||
*/
|
*/
|
||||||
public function collectRoutes()
|
public function collectRoutes()
|
||||||
{
|
{
|
||||||
$this->routeCollector->addRoute(['GET', 'POST'], '/itemsource[/{guid}]', Module\Itemsource::class);
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/amcd', Module\AccountManagementControlDocument::class);
|
|
||||||
$this->routeCollector->addGroup('/.well-known', function (RouteCollector $collector) {
|
$this->routeCollector->addGroup('/.well-known', function (RouteCollector $collector) {
|
||||||
$collector->addRoute(['GET'], '/host-meta' , Module\WellKnown\HostMeta::class);
|
$collector->addRoute(['GET'], '/host-meta' , Module\WellKnown\HostMeta::class);
|
||||||
$collector->addRoute(['GET'], '/nodeinfo[/1.0]' , Module\NodeInfo::class);
|
$collector->addRoute(['GET'], '/nodeinfo[/1.0]' , Module\NodeInfo::class);
|
||||||
$collector->addRoute(['GET'], '/webfinger' , Module\Xrd::class);
|
$collector->addRoute(['GET'], '/webfinger' , Module\Xrd::class);
|
||||||
$collector->addRoute(['GET'], '/x-social-relay' , Module\WellKnown\XSocialRelay::class);
|
$collector->addRoute(['GET'], '/x-social-relay' , Module\WellKnown\XSocialRelay::class);
|
||||||
});
|
});
|
||||||
$this->routeCollector->addRoute(['GET'], '/acctlink', Module\Acctlink::class);
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/apps', Module\Apps::class);
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/attach/{item:\d+}', Module\Attach::class);
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/babel', Module\Babel::class);
|
|
||||||
$this->routeCollector->addGroup('/contact', function (RouteCollector $collector) {
|
|
||||||
$collector->addRoute(['GET'], '[/]', Module\Contact::class);
|
|
||||||
$collector->addRoute(['GET'], '/{id:\d+}[/posts|conversations]', Module\Contact::class);
|
|
||||||
});
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/credits', Module\Credits::class);
|
|
||||||
$this->routeCollector->addGroup('/feed', function (RouteCollector $collector) {
|
|
||||||
$collector->addRoute(['GET'], '/{nickname}', Module\Feed::class);
|
|
||||||
$collector->addRoute(['GET'], '/{nickname}/posts', Module\Feed::class);
|
|
||||||
$collector->addRoute(['GET'], '/{nickname}/comments', Module\Feed::class);
|
|
||||||
$collector->addRoute(['GET'], '/{nickname}/replies', Module\Feed::class);
|
|
||||||
$collector->addRoute(['GET'], '/{nickname}/activity', Module\Feed::class);
|
|
||||||
});
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/feedtest', Module\Feedtest::class);
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/filer[/{id:\d+}]', Module\Filer::class);
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/followers/{owner}', Module\Followers::class);
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/following/{owner}', Module\Following::class);
|
|
||||||
$this->routeCollector->addGroup('/group', function (RouteCollector $collector) {
|
|
||||||
$collector->addRoute(['GET', 'POST'], '[/]', Module\Group::class);
|
|
||||||
$collector->addRoute(['GET', 'POST'], '/{group:\d+}', Module\Group::class);
|
|
||||||
$collector->addRoute(['GET', 'POST'], '/none', Module\Group::class);
|
|
||||||
$collector->addRoute(['GET', 'POST'], '/new', Module\Group::class);
|
|
||||||
$collector->addRoute(['GET', 'POST'], '/drop/{group:\d+}', Module\Group::class);
|
|
||||||
$collector->addRoute(['GET', 'POST'], '/{group:\d+}/{contact:\d+}', Module\Group::class);
|
|
||||||
|
|
||||||
$collector->addRoute(['POST'], '/{group:\d+}/add/{contact:\d+}', Module\Group::class);
|
|
||||||
$collector->addRoute(['POST'], '/{group:\d+}/remove/{contact:\d+}', Module\Group::class);
|
|
||||||
});
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/hashtag', Module\Hashtag::class);
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/inbox[/{nickname}]', Module\Inbox::class);
|
|
||||||
$this->routeCollector->addGroup('/install', function (RouteCollector $collector) {
|
|
||||||
$collector->addRoute(['GET', 'POST'], '[/]', Module\Install::class);
|
|
||||||
$collector->addRoute(['GET'], '/testrewrite', Module\Install::class);
|
|
||||||
});
|
|
||||||
$this->routeCollector->addRoute(['GET', 'POST'], '/localtime', Module\Localtime::class);
|
|
||||||
$this->routeCollector->addRoute(['GET', 'POST'], '/login', Module\Login::class);
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/magic', Module\Magic::class);
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/manifest', Module\Manifest::class);
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/nodeinfo/1.0', Module\NodeInfo::class);
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/objects/{guid}', Module\Objects::class);
|
|
||||||
$this->routeCollector->addGroup('/oembed', function (RouteCollector $collector) {
|
|
||||||
$collector->addRoute(['GET'], '/[b2h|h2b]', Module\Oembed::class);
|
|
||||||
$collector->addRoute(['GET'], '/{hash}', Module\Oembed::class);
|
|
||||||
});
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/outbox/{owner}', Module\Outbox::class);
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/owa', Module\Owa::class);
|
|
||||||
$this->routeCollector->addGroup('/photo', function (RouteCollector $collector) {
|
|
||||||
$collector->addRoute(['GET'], '/{name}', Module\Photo::class);
|
|
||||||
$collector->addRoute(['GET'], '/{type}/{name}', Module\Photo::class);
|
|
||||||
$collector->addRoute(['GET'], '/{type}/{customize}/{name}', Module\Photo::class);
|
|
||||||
});
|
|
||||||
$this->routeCollector->addGroup('/profile', function (RouteCollector $collector) {
|
|
||||||
$collector->addRoute(['GET'], '/{nickname}', Module\Profile::class);
|
|
||||||
$collector->addRoute(['GET'], '/{profile:\d+}/view', Module\Profile::class);
|
|
||||||
});
|
|
||||||
$this->routeCollector->addGroup('/proxy', function (RouteCollector $collector) {
|
|
||||||
$collector->addRoute(['GET'], '[/]', Module\Proxy::class);
|
|
||||||
$collector->addRoute(['GET'], '/{url}', Module\Proxy::class);
|
|
||||||
$collector->addRoute(['GET'], '/sub1/{url}', Module\Proxy::class);
|
|
||||||
$collector->addRoute(['GET'], '/sub1/sub2/{url}', Module\Proxy::class);
|
|
||||||
});
|
|
||||||
$this->routeCollector->addRoute(['GET', 'POST'], '/register', Module\Register::class);
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/statistics.json', Module\Statistics::class);
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/tos', Module\Tos::class);
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/webfinger', Module\WebFinger::class);
|
|
||||||
$this->routeCollector->addRoute(['GET'], '/xrd', Module\Xrd::class);
|
|
||||||
|
|
||||||
$this->routeCollector->addGroup('/admin', function (RouteCollector $collector) {
|
$this->routeCollector->addGroup('/admin', function (RouteCollector $collector) {
|
||||||
$collector->addRoute(['GET'] , '[/]' , Module\Admin\Summary::class);
|
$collector->addRoute(['GET'] , '[/]' , Module\Admin\Summary::class);
|
||||||
|
|
||||||
|
@ -154,6 +82,78 @@ class Router
|
||||||
|
|
||||||
$collector->addRoute(['GET', 'POST'], '/users[/{action}/{uid}]' , Module\Admin\Users::class);
|
$collector->addRoute(['GET', 'POST'], '/users[/{action}/{uid}]' , Module\Admin\Users::class);
|
||||||
});
|
});
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/amcd', Module\AccountManagementControlDocument::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/acctlink', Module\Acctlink::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/allfriends/{id:\d+}', Module\AllFriends::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/apps', Module\Apps::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/attach/{item:\d+}', Module\Attach::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/babel', Module\Babel::class);
|
||||||
|
$this->routeCollector->addGroup('/contact', function (RouteCollector $collector) {
|
||||||
|
$collector->addRoute(['GET'], '[/]', Module\Contact::class);
|
||||||
|
$collector->addRoute(['GET'], '/{id:\d+}[/posts|conversations]', Module\Contact::class);
|
||||||
|
});
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/credits', Module\Credits::class);
|
||||||
|
$this->routeCollector->addGroup('/feed', function (RouteCollector $collector) {
|
||||||
|
$collector->addRoute(['GET'], '/{nickname}', Module\Feed::class);
|
||||||
|
$collector->addRoute(['GET'], '/{nickname}/posts', Module\Feed::class);
|
||||||
|
$collector->addRoute(['GET'], '/{nickname}/comments', Module\Feed::class);
|
||||||
|
$collector->addRoute(['GET'], '/{nickname}/replies', Module\Feed::class);
|
||||||
|
$collector->addRoute(['GET'], '/{nickname}/activity', Module\Feed::class);
|
||||||
|
});
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/feedtest', Module\Feedtest::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/filer[/{id:\d+}]', Module\Filer::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/followers/{owner}', Module\Followers::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/following/{owner}', Module\Following::class);
|
||||||
|
$this->routeCollector->addGroup('/group', function (RouteCollector $collector) {
|
||||||
|
$collector->addRoute(['GET', 'POST'], '[/]', Module\Group::class);
|
||||||
|
$collector->addRoute(['GET', 'POST'], '/{group:\d+}', Module\Group::class);
|
||||||
|
$collector->addRoute(['GET', 'POST'], '/none', Module\Group::class);
|
||||||
|
$collector->addRoute(['GET', 'POST'], '/new', Module\Group::class);
|
||||||
|
$collector->addRoute(['GET', 'POST'], '/drop/{group:\d+}', Module\Group::class);
|
||||||
|
$collector->addRoute(['GET', 'POST'], '/{group:\d+}/{contact:\d+}', Module\Group::class);
|
||||||
|
|
||||||
|
$collector->addRoute(['POST'], '/{group:\d+}/add/{contact:\d+}', Module\Group::class);
|
||||||
|
$collector->addRoute(['POST'], '/{group:\d+}/remove/{contact:\d+}', Module\Group::class);
|
||||||
|
});
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/hashtag', Module\Hashtag::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/inbox[/{nickname}]', Module\Inbox::class);
|
||||||
|
$this->routeCollector->addGroup('/install', function (RouteCollector $collector) {
|
||||||
|
$collector->addRoute(['GET', 'POST'], '[/]', Module\Install::class);
|
||||||
|
$collector->addRoute(['GET'], '/testrewrite', Module\Install::class);
|
||||||
|
});
|
||||||
|
$this->routeCollector->addRoute(['GET', 'POST'], '/itemsource[/{guid}]', Module\Itemsource::class);
|
||||||
|
$this->routeCollector->addRoute(['GET', 'POST'], '/localtime', Module\Localtime::class);
|
||||||
|
$this->routeCollector->addRoute(['GET', 'POST'], '/login', Module\Login::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/magic', Module\Magic::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/manifest', Module\Manifest::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/nodeinfo/1.0', Module\NodeInfo::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/objects/{guid}', Module\Objects::class);
|
||||||
|
$this->routeCollector->addGroup('/oembed', function (RouteCollector $collector) {
|
||||||
|
$collector->addRoute(['GET'], '/[b2h|h2b]', Module\Oembed::class);
|
||||||
|
$collector->addRoute(['GET'], '/{hash}', Module\Oembed::class);
|
||||||
|
});
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/outbox/{owner}', Module\Outbox::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/owa', Module\Owa::class);
|
||||||
|
$this->routeCollector->addGroup('/photo', function (RouteCollector $collector) {
|
||||||
|
$collector->addRoute(['GET'], '/{name}', Module\Photo::class);
|
||||||
|
$collector->addRoute(['GET'], '/{type}/{name}', Module\Photo::class);
|
||||||
|
$collector->addRoute(['GET'], '/{type}/{customize}/{name}', Module\Photo::class);
|
||||||
|
});
|
||||||
|
$this->routeCollector->addGroup('/profile', function (RouteCollector $collector) {
|
||||||
|
$collector->addRoute(['GET'], '/{nickname}', Module\Profile::class);
|
||||||
|
$collector->addRoute(['GET'], '/{profile:\d+}/view', Module\Profile::class);
|
||||||
|
});
|
||||||
|
$this->routeCollector->addGroup('/proxy', function (RouteCollector $collector) {
|
||||||
|
$collector->addRoute(['GET'], '[/]', Module\Proxy::class);
|
||||||
|
$collector->addRoute(['GET'], '/{url}', Module\Proxy::class);
|
||||||
|
$collector->addRoute(['GET'], '/sub1/{url}', Module\Proxy::class);
|
||||||
|
$collector->addRoute(['GET'], '/sub1/sub2/{url}', Module\Proxy::class);
|
||||||
|
});
|
||||||
|
$this->routeCollector->addRoute(['GET', 'POST'], '/register', Module\Register::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/statistics.json', Module\Statistics::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/tos', Module\Tos::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/webfinger', Module\WebFinger::class);
|
||||||
|
$this->routeCollector->addRoute(['GET'], '/xrd', Module\Xrd::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct(RouteCollector $routeCollector = null)
|
public function __construct(RouteCollector $routeCollector = null)
|
||||||
|
|
|
@ -237,6 +237,28 @@ class Contact extends BaseObject
|
||||||
return ['public' => $pcid, 'user' => $ucid];
|
return ['public' => $pcid, 'user' => $ucid];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns contact details for a given contact id in combination with a user id
|
||||||
|
*
|
||||||
|
* @param int $cid A contact ID
|
||||||
|
* @param int $uid The User ID
|
||||||
|
* @param array $fields The selected fields for the contact
|
||||||
|
*
|
||||||
|
* @return array The contact details
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
*/
|
||||||
|
public static function getContactForUser($cid, $uid, array $fields = [])
|
||||||
|
{
|
||||||
|
$contact = DBA::selectFirst('contact', $fields, ['id' => $cid, 'uid' => $uid]);
|
||||||
|
|
||||||
|
if (!DBA::isResult($contact)) {
|
||||||
|
return [];
|
||||||
|
} else {
|
||||||
|
return $contact;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Block contact id for user id
|
* @brief Block contact id for user id
|
||||||
*
|
*
|
||||||
|
|
107
src/Module/AllFriends.php
Normal file
107
src/Module/AllFriends.php
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Friendica\Module;
|
||||||
|
|
||||||
|
use Friendica\BaseModule;
|
||||||
|
use Friendica\Content\ContactSelector;
|
||||||
|
use Friendica\Content\Pager;
|
||||||
|
use Friendica\Core\L10n;
|
||||||
|
use Friendica\Core\Renderer;
|
||||||
|
use Friendica\Model;
|
||||||
|
use Friendica\Network\HTTPException;
|
||||||
|
use Friendica\Util\Proxy as ProxyUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This module shows all public friends of the selected contact
|
||||||
|
*/
|
||||||
|
class AllFriends extends BaseModule
|
||||||
|
{
|
||||||
|
public static function content()
|
||||||
|
{
|
||||||
|
$app = self::getApp();
|
||||||
|
|
||||||
|
if (!local_user()) {
|
||||||
|
throw new HTTPException\ForbiddenException();
|
||||||
|
}
|
||||||
|
|
||||||
|
$cid = 0;
|
||||||
|
|
||||||
|
// @TODO: Replace with parameter from router
|
||||||
|
if ($app->argc > 1) {
|
||||||
|
$cid = intval($app->argv[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$cid) {
|
||||||
|
throw new HTTPException\BadRequestException(L10n::t('Invalid contact.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$uid = $app->user['uid'];
|
||||||
|
|
||||||
|
$contact = Model\Contact::getContactForUser($cid, local_user(), ['name', 'url', 'photo', 'uid', 'id']);
|
||||||
|
|
||||||
|
if (empty($contact)) {
|
||||||
|
throw new HTTPException\BadRequestException(L10n::t('Invalid contact.'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$app->page['aside'] = "";
|
||||||
|
Model\Profile::load($app, "", 0, Model\Contact::getDetailsByURL($contact["url"]));
|
||||||
|
|
||||||
|
$total = Model\GContact::countAllFriends(local_user(), $cid);
|
||||||
|
|
||||||
|
$pager = new Pager($app->query_string);
|
||||||
|
|
||||||
|
$friends = Model\GContact::allFriends(local_user(), $cid, $pager->getStart(), $pager->getItemsPerPage());
|
||||||
|
if (empty($friends)) {
|
||||||
|
return L10n::t('No friends to display.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$id = 0;
|
||||||
|
|
||||||
|
$entries = [];
|
||||||
|
foreach ($friends as $friend) {
|
||||||
|
//get further details of the contact
|
||||||
|
$contactDetails = Model\Contact::getDetailsByURL($friend['url'], $uid, $friend);
|
||||||
|
|
||||||
|
$connlnk = '';
|
||||||
|
// $friend[cid] is only available for common contacts. So if the contact is a common one, use contact_photo_menu to generate the photoMenu
|
||||||
|
// If the contact is not common to the user, Connect/Follow' will be added to the photo menu
|
||||||
|
if ($friend['cid']) {
|
||||||
|
$friend['id'] = $friend['cid'];
|
||||||
|
$photoMenu = Model\Contact::photoMenu($friend);
|
||||||
|
} else {
|
||||||
|
$connlnk = $app->getBaseURL() . '/follow/?url=' . $friend['url'];
|
||||||
|
$photoMenu = [
|
||||||
|
'profile' => [L10n::t('View Profile'), Model\Contact::magicLinkbyId($friend['id'], $friend['url'])],
|
||||||
|
'follow' => [L10n::t('Connect/Follow'), $connlnk]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
$entry = [
|
||||||
|
'url' => Model\Contact::magicLinkbyId($friend['id'], $friend['url']),
|
||||||
|
'itemurl' => defaults($contactDetails, 'addr', $friend['url']),
|
||||||
|
'name' => $contactDetails['name'],
|
||||||
|
'thumb' => ProxyUtils::proxifyUrl($contactDetails['thumb'], false, ProxyUtils::SIZE_THUMB),
|
||||||
|
'img_hover' => $contactDetails['name'],
|
||||||
|
'details' => $contactDetails['location'],
|
||||||
|
'tags' => $contactDetails['keywords'],
|
||||||
|
'about' => $contactDetails['about'],
|
||||||
|
'account_type' => Model\Contact::getAccountType($contactDetails),
|
||||||
|
'network' => ContactSelector::networkToName($contactDetails['network'], $contactDetails['url']),
|
||||||
|
'photoMenu' => $photoMenu,
|
||||||
|
'conntxt' => L10n::t('Connect'),
|
||||||
|
'connlnk' => $connlnk,
|
||||||
|
'id' => ++$id,
|
||||||
|
];
|
||||||
|
$entries[] = $entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tab_str = Contact::getTabsHTML($app, $contact, 4);
|
||||||
|
|
||||||
|
$tpl = Renderer::getMarkupTemplate('viewcontact_template.tpl');
|
||||||
|
return Renderer::replaceMacros($tpl, [
|
||||||
|
'$tab_str' => $tab_str,
|
||||||
|
'$contacts' => $entries,
|
||||||
|
'$paginate' => $pager->renderFull($total),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,7 +3,6 @@
|
||||||
namespace Friendica\Module;
|
namespace Friendica\Module;
|
||||||
|
|
||||||
use Friendica\BaseModule;
|
use Friendica\BaseModule;
|
||||||
use Friendica\Core\System;
|
|
||||||
use Friendica\Protocol\OStatus;
|
use Friendica\Protocol\OStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue