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\DBM;
11 use Friendica\Model\Contact;
12 use Friendica\Model\Profile;
14 function viewcontacts_init(App $a)
16 if ((Config::get('system', 'block_public')) && (! local_user()) && (! remote_user())) {
20 Nav::setSelected('home');
24 $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
28 if (! DBM::is_result($r)) {
32 $a->data['user'] = $r[0];
33 $a->profile_uid = $r[0]['uid'];
34 $is_owner = (local_user() && (local_user() == $a->profile_uid));
36 Profile::load($a, $a->argv[1]);
40 function viewcontacts_content(App $a)
42 require_once("mod/proxy.php");
44 if ((Config::get('system', 'block_public')) && (! local_user()) && (! remote_user())) {
45 notice(L10n::t('Public access denied.') . EOL);
49 $is_owner = $a->profile['profile_uid'] == local_user();
54 $o .= Profile::getTabs($a, $is_owner, $a->data['user']['nickname']);
56 if (((! count($a->profile)) || ($a->profile['hide-friends']))) {
57 notice(L10n::t('Permission denied.') . EOL);
61 $r = q("SELECT COUNT(*) AS `total` FROM `contact`
62 WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
63 AND NOT `hidden` AND NOT `archive`
64 AND `network` IN ('%s', '%s', '%s')",
65 intval($a->profile['uid']),
67 dbesc(NETWORK_DIASPORA),
68 dbesc(NETWORK_OSTATUS)
70 if (DBM::is_result($r)) {
71 $a->set_pager_total($r[0]['total']);
74 $r = q("SELECT * FROM `contact`
75 WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
76 AND NOT `hidden` AND NOT `archive`
77 AND `network` IN ('%s', '%s', '%s')
78 ORDER BY `name` ASC LIMIT %d, %d",
79 intval($a->profile['uid']),
81 dbesc(NETWORK_DIASPORA),
82 dbesc(NETWORK_OSTATUS),
83 intval($a->pager['start']),
84 intval($a->pager['itemspage'])
86 if (!DBM::is_result($r)) {
87 info(L10n::t('No contacts.').EOL);
94 /// @TODO This triggers an E_NOTICE if 'self' is not there
101 // route DFRN profiles through the redirect
102 if ($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) {
103 $url = 'redir/' . $rr['id'];
105 $url = Profile::zrl($url);
108 $contact_details = Contact::getDetailsByURL($rr['url'], $a->profile['uid'], $rr);
112 'img_hover' => L10n::t('Visit %s\'s profile [%s]', $contact_details['name'], $rr['url']),
113 'photo_menu' => Contact::photoMenu($rr),
114 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
115 'name' => htmlentities(substr($contact_details['name'], 0, 20)),
116 'username' => htmlentities($contact_details['name']),
117 'details' => $contact_details['location'],
118 'tags' => $contact_details['keywords'],
119 'about' => $contact_details['about'],
120 'account_type' => Contact::getAccountType($contact_details),
123 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
124 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
129 $tpl = get_markup_template("viewcontact_template.tpl");
130 $o .= replace_macros($tpl, [
131 '$title' => L10n::t('Contacts'),
132 '$contacts' => $contacts,
133 '$paginate' => paginate($a),