3 * @file mod/viewcontacts.php
6 use Friendica\Content\ContactSelector;
7 use Friendica\Content\Nav;
8 use Friendica\Core\Config;
9 use Friendica\Core\L10n;
10 use Friendica\Database\DBA;
11 use Friendica\Model\Contact;
12 use Friendica\Model\Profile;
13 use Friendica\Util\Proxy as ProxyUtils;
15 function viewcontacts_init(App $a)
17 if ((Config::get('system', 'block_public')) && (! local_user()) && (! remote_user())) {
21 Nav::setSelected('home');
25 $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
29 if (! DBA::isResult($r)) {
33 $a->data['user'] = $r[0];
34 $a->profile_uid = $r[0]['uid'];
35 $is_owner = (local_user() && (local_user() == $a->profile_uid));
37 Profile::load($a, $a->argv[1]);
41 function viewcontacts_content(App $a)
43 if ((Config::get('system', 'block_public')) && (! local_user()) && (! remote_user())) {
44 notice(L10n::t('Public access denied.') . EOL);
48 $is_owner = $a->profile['profile_uid'] == local_user();
53 $o .= Profile::getTabs($a, $is_owner, $a->data['user']['nickname']);
55 if (((! count($a->profile)) || ($a->profile['hide-friends']))) {
56 notice(L10n::t('Permission denied.') . EOL);
60 $r = q("SELECT COUNT(*) AS `total` FROM `contact`
61 WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
62 AND NOT `hidden` AND NOT `archive`
63 AND `network` IN ('%s', '%s', '%s')",
64 intval($a->profile['uid']),
65 DBA::escape(NETWORK_DFRN),
66 DBA::escape(NETWORK_DIASPORA),
67 DBA::escape(NETWORK_OSTATUS)
69 if (DBA::isResult($r)) {
70 $a->set_pager_total($r[0]['total']);
73 $r = q("SELECT * FROM `contact`
74 WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
75 AND NOT `hidden` AND NOT `archive`
76 AND `network` IN ('%s', '%s', '%s')
77 ORDER BY `name` ASC LIMIT %d, %d",
78 intval($a->profile['uid']),
79 DBA::escape(NETWORK_DFRN),
80 DBA::escape(NETWORK_DIASPORA),
81 DBA::escape(NETWORK_OSTATUS),
82 intval($a->pager['start']),
83 intval($a->pager['itemspage'])
85 if (!DBA::isResult($r)) {
86 info(L10n::t('No contacts.').EOL);
93 /// @TODO This triggers an E_NOTICE if 'self' is not there
98 $contact_details = Contact::getDetailsByURL($rr['url'], $a->profile['uid'], $rr);
102 'img_hover' => L10n::t('Visit %s\'s profile [%s]', $contact_details['name'], $rr['url']),
103 'photo_menu' => Contact::photoMenu($rr),
104 'thumb' => ProxyUtils::proxifyUrl($contact_details['thumb'], false, ProxyUtils::SIZE_THUMB),
105 'name' => htmlentities(substr($contact_details['name'], 0, 20)),
106 'username' => htmlentities($contact_details['name']),
107 'details' => $contact_details['location'],
108 'tags' => $contact_details['keywords'],
109 'about' => $contact_details['about'],
110 'account_type' => Contact::getAccountType($contact_details),
111 'url' => Contact::magicLink($rr['url']),
113 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
114 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
119 $tpl = get_markup_template("viewcontact_template.tpl");
120 $o .= replace_macros($tpl, [
121 '$title' => L10n::t('Contacts'),
122 '$contacts' => $contacts,
123 '$paginate' => paginate($a),