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]);
41 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);
52 $o .= Profile::getTabs($a, $is_owner, $a->data['user']['nickname']);
54 if(((! count($a->profile)) || ($a->profile['hide-friends']))) {
55 notice(L10n::t('Permission denied.') . EOL);
59 $r = q("SELECT COUNT(*) AS `total` FROM `contact`
60 WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
61 AND NOT `hidden` AND NOT `archive`
62 AND `network` IN ('%s', '%s', '%s')",
63 intval($a->profile['uid']),
65 dbesc(NETWORK_DIASPORA),
66 dbesc(NETWORK_OSTATUS)
68 if (DBM::is_result($r))
69 $a->set_pager_total($r[0]['total']);
71 $r = q("SELECT * FROM `contact`
72 WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
73 AND NOT `hidden` AND NOT `archive`
74 AND `network` IN ('%s', '%s', '%s')
75 ORDER BY `name` ASC LIMIT %d, %d",
76 intval($a->profile['uid']),
78 dbesc(NETWORK_DIASPORA),
79 dbesc(NETWORK_OSTATUS),
80 intval($a->pager['start']),
81 intval($a->pager['itemspage'])
83 if (!DBM::is_result($r)) {
84 info(t('No contacts.').EOL);
91 /// @TODO This triggers an E_NOTICE if 'self' is not there
98 // route DFRN profiles through the redirect
100 $is_owner = ((local_user() && ($a->profile['profile_uid'] == local_user())) ? true : false);
102 if($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel']))
103 $url = 'redir/' . $rr['id'];
105 $url = Profile::zrl($url);
107 $contact_details = Contact::getDetailsByURL($rr['url'], $a->profile['uid'], $rr);
111 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'), $contact_details['name'], $rr['url']),
112 'photo_menu' => Contact::photoMenu($rr),
113 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
114 'name' => htmlentities(substr($contact_details['name'],0,20)),
115 'username' => htmlentities($contact_details['name']),
116 'details' => $contact_details['location'],
117 'tags' => $contact_details['keywords'],
118 'about' => $contact_details['about'],
119 'account_type' => Contact::getAccountType($contact_details),
122 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
123 'network' => ContactSelector::networkToName($rr['network'], $rr['url']),
128 $tpl = get_markup_template("viewcontact_template.tpl");
129 $o .= replace_macros($tpl, [
130 '$title' => t('Contacts'),
131 '$contacts' => $contacts,
132 '$paginate' => paginate($a),