2010-07-29 01:24:07 +00:00
|
|
|
<?php
|
2018-01-15 02:22:39 +00:00
|
|
|
/**
|
|
|
|
* @file mod/viewcontacts.php
|
|
|
|
*/
|
2018-10-24 06:15:24 +00:00
|
|
|
|
2017-04-30 04:07:00 +00:00
|
|
|
use Friendica\App;
|
2018-01-10 03:42:04 +00:00
|
|
|
use Friendica\Content\ContactSelector;
|
2018-01-15 19:51:56 +00:00
|
|
|
use Friendica\Content\Nav;
|
2018-10-24 06:15:24 +00:00
|
|
|
use Friendica\Content\Pager;
|
2017-11-07 02:22:52 +00:00
|
|
|
use Friendica\Core\Config;
|
2018-01-21 18:33:59 +00:00
|
|
|
use Friendica\Core\L10n;
|
2018-08-11 20:40:44 +00:00
|
|
|
use Friendica\Core\Protocol;
|
2018-10-31 14:35:50 +00:00
|
|
|
use Friendica\Core\Renderer;
|
2018-10-24 06:15:24 +00:00
|
|
|
use Friendica\Core\System;
|
2018-07-21 12:40:21 +00:00
|
|
|
use Friendica\Database\DBA;
|
2017-12-07 14:04:24 +00:00
|
|
|
use Friendica\Model\Contact;
|
2018-01-15 02:22:39 +00:00
|
|
|
use Friendica\Model\Profile;
|
2018-07-31 02:06:22 +00:00
|
|
|
use Friendica\Util\Proxy as ProxyUtils;
|
2017-04-30 04:07:00 +00:00
|
|
|
|
2018-01-22 14:16:25 +00:00
|
|
|
function viewcontacts_init(App $a)
|
|
|
|
{
|
2018-08-01 05:29:58 +00:00
|
|
|
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
2019-05-02 03:16:10 +00:00
|
|
|
throw new \Friendica\Network\HTTPException\ForbiddenException(L10n::t('Access denied.'));
|
2011-04-22 02:12:22 +00:00
|
|
|
}
|
2010-07-29 01:24:07 +00:00
|
|
|
|
2018-08-01 05:29:58 +00:00
|
|
|
if ($a->argc < 2) {
|
2019-05-02 03:16:10 +00:00
|
|
|
throw new \Friendica\Network\HTTPException\ForbiddenException(L10n::t('Access denied.'));
|
2018-08-01 05:29:58 +00:00
|
|
|
}
|
|
|
|
|
2018-01-15 19:51:56 +00:00
|
|
|
Nav::setSelected('home');
|
2015-11-30 02:25:23 +00:00
|
|
|
|
2018-12-25 16:36:41 +00:00
|
|
|
$user = DBA::selectFirst('user', [], ['nickname' => $a->argv[1], 'blocked' => false]);
|
|
|
|
if (!DBA::isResult($user)) {
|
2019-05-02 03:16:10 +00:00
|
|
|
throw new \Friendica\Network\HTTPException\NotFoundException();
|
2018-08-01 05:29:58 +00:00
|
|
|
}
|
2015-11-30 02:25:23 +00:00
|
|
|
|
2018-12-25 16:36:41 +00:00
|
|
|
$a->data['user'] = $user;
|
|
|
|
$a->profile_uid = $user['uid'];
|
2015-11-30 02:25:23 +00:00
|
|
|
|
2018-08-01 05:29:58 +00:00
|
|
|
Profile::load($a, $a->argv[1]);
|
2010-07-29 01:24:07 +00:00
|
|
|
}
|
|
|
|
|
2018-01-22 14:16:25 +00:00
|
|
|
function viewcontacts_content(App $a)
|
|
|
|
{
|
2018-08-01 05:29:58 +00:00
|
|
|
if (Config::get('system', 'block_public') && !local_user() && !remote_user()) {
|
2018-01-21 18:33:59 +00:00
|
|
|
notice(L10n::t('Public access denied.') . EOL);
|
2011-04-22 02:12:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-02-12 03:10:11 +00:00
|
|
|
$is_owner = $a->profile['profile_uid'] == local_user();
|
2018-02-12 02:25:09 +00:00
|
|
|
|
2015-11-30 02:25:23 +00:00
|
|
|
// tabs
|
2018-12-25 16:36:41 +00:00
|
|
|
$o = Profile::getTabs($a, $is_owner, $a->data['user']['nickname']);
|
2010-07-29 01:24:07 +00:00
|
|
|
|
2018-08-01 05:29:58 +00:00
|
|
|
if (!count($a->profile) || $a->profile['hide-friends']) {
|
2018-01-21 18:33:59 +00:00
|
|
|
notice(L10n::t('Permission denied.') . EOL);
|
2016-06-28 10:32:09 +00:00
|
|
|
return $o;
|
2016-06-25 14:20:44 +00:00
|
|
|
}
|
|
|
|
|
2018-12-25 16:36:41 +00:00
|
|
|
$condition = [
|
|
|
|
'uid' => $a->profile['uid'],
|
|
|
|
'blocked' => false,
|
|
|
|
'pending' => false,
|
|
|
|
'hidden' => false,
|
|
|
|
'archive' => false,
|
|
|
|
'network' => [Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS]
|
|
|
|
];
|
|
|
|
|
2019-01-27 19:54:08 +00:00
|
|
|
$total = DBA::count('contact', $condition);
|
2018-12-25 16:36:41 +00:00
|
|
|
|
2018-10-24 15:42:59 +00:00
|
|
|
$pager = new Pager($a->query_string);
|
2010-07-29 01:24:07 +00:00
|
|
|
|
2018-12-25 16:36:41 +00:00
|
|
|
$params = ['order' => ['name' => false], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
|
|
|
|
|
|
|
|
$contacts_stmt = DBA::select('contact', [], $condition, $params);
|
|
|
|
|
|
|
|
if (!DBA::isResult($contacts_stmt)) {
|
|
|
|
info(L10n::t('No contacts.') . EOL);
|
2010-07-29 01:24:07 +00:00
|
|
|
return $o;
|
|
|
|
}
|
|
|
|
|
2018-01-15 13:05:12 +00:00
|
|
|
$contacts = [];
|
2010-07-29 01:24:07 +00:00
|
|
|
|
2018-12-25 16:36:41 +00:00
|
|
|
while ($contact = DBA::fetch($contacts_stmt)) {
|
2016-12-20 20:15:53 +00:00
|
|
|
/// @TODO This triggers an E_NOTICE if 'self' is not there
|
2018-12-25 16:36:41 +00:00
|
|
|
if ($contact['self']) {
|
2010-07-29 01:24:07 +00:00
|
|
|
continue;
|
2016-12-20 20:15:53 +00:00
|
|
|
}
|
2010-07-29 01:24:07 +00:00
|
|
|
|
2018-12-25 16:36:41 +00:00
|
|
|
$contact_details = Contact::getDetailsByURL($contact['url'], $a->profile['uid'], $contact);
|
2015-11-05 23:47:54 +00:00
|
|
|
|
2018-01-15 13:05:12 +00:00
|
|
|
$contacts[] = [
|
2018-12-25 16:36:41 +00:00
|
|
|
'id' => $contact['id'],
|
|
|
|
'img_hover' => L10n::t('Visit %s\'s profile [%s]', $contact_details['name'], $contact['url']),
|
|
|
|
'photo_menu' => Contact::photoMenu($contact),
|
|
|
|
'thumb' => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::SIZE_THUMB),
|
|
|
|
'name' => substr($contact_details['name'], 0, 20),
|
|
|
|
'username' => $contact_details['name'],
|
|
|
|
'details' => $contact_details['location'],
|
|
|
|
'tags' => $contact_details['keywords'],
|
|
|
|
'about' => $contact_details['about'],
|
|
|
|
'account_type' => Contact::getAccountType($contact_details),
|
|
|
|
'url' => Contact::magicLink($contact['url']),
|
|
|
|
'sparkle' => '',
|
|
|
|
'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $contact['url']),
|
|
|
|
'network' => ContactSelector::networkToName($contact['network'], $contact['url']),
|
2018-01-15 13:05:12 +00:00
|
|
|
];
|
2010-07-29 01:24:07 +00:00
|
|
|
}
|
|
|
|
|
2018-12-25 16:36:41 +00:00
|
|
|
DBA::close($contacts_stmt);
|
2010-07-29 01:24:07 +00:00
|
|
|
|
2018-10-31 14:44:06 +00:00
|
|
|
$tpl = Renderer::getMarkupTemplate("viewcontact_template.tpl");
|
2018-10-31 14:35:50 +00:00
|
|
|
$o .= Renderer::replaceMacros($tpl, [
|
2018-12-25 16:36:41 +00:00
|
|
|
'$title' => L10n::t('Contacts'),
|
2012-02-23 10:22:32 +00:00
|
|
|
'$contacts' => $contacts,
|
2018-10-24 15:42:59 +00:00
|
|
|
'$paginate' => $pager->renderFull($total),
|
2018-01-15 13:05:12 +00:00
|
|
|
]);
|
2012-02-23 10:22:32 +00:00
|
|
|
|
2010-07-29 01:24:07 +00:00
|
|
|
return $o;
|
2011-05-23 09:39:57 +00:00
|
|
|
}
|