4 use Friendica\Core\Config;
5 use Friendica\Database\DBM;
6 use Friendica\Model\Contact;
8 require_once('include/contact_selectors.php');
10 function viewcontacts_init(App $a) {
12 if((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) {
16 nav_set_selected('home');
20 $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
24 if (! DBM::is_result($r)) {
28 $a->data['user'] = $r[0];
29 $a->profile_uid = $r[0]['uid'];
30 $is_owner = (local_user() && (local_user() == $a->profile_uid));
32 profile_load($a,$a->argv[1]);
37 function viewcontacts_content(App $a) {
38 require_once("mod/proxy.php");
40 if((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) {
41 notice( t('Public access denied.') . EOL);
48 $o .= profile_tabs($a,$is_owner, $a->data['user']['nickname']);
50 if(((! count($a->profile)) || ($a->profile['hide-friends']))) {
51 notice( t('Permission denied.') . EOL);
55 $r = q("SELECT COUNT(*) AS `total` FROM `contact`
56 WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
57 AND NOT `hidden` AND NOT `archive`
58 AND `network` IN ('%s', '%s', '%s')",
59 intval($a->profile['uid']),
61 dbesc(NETWORK_DIASPORA),
62 dbesc(NETWORK_OSTATUS)
64 if (DBM::is_result($r))
65 $a->set_pager_total($r[0]['total']);
67 $r = q("SELECT * FROM `contact`
68 WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
69 AND NOT `hidden` AND NOT `archive`
70 AND `network` IN ('%s', '%s', '%s')
71 ORDER BY `name` ASC LIMIT %d, %d",
72 intval($a->profile['uid']),
74 dbesc(NETWORK_DIASPORA),
75 dbesc(NETWORK_OSTATUS),
76 intval($a->pager['start']),
77 intval($a->pager['itemspage'])
79 if (!DBM::is_result($r)) {
80 info(t('No contacts.').EOL);
87 /// @TODO This triggers an E_NOTICE if 'self' is not there
94 // route DFRN profiles through the redirect
96 $is_owner = ((local_user() && ($a->profile['profile_uid'] == local_user())) ? true : false);
98 if($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel']))
99 $url = 'redir/' . $rr['id'];
103 $contact_details = Contact::getDetailsByURL($rr['url'], $a->profile['uid'], $rr);
107 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'), $contact_details['name'], $rr['url']),
108 'photo_menu' => Contact::photoMenu($rr),
109 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
110 'name' => htmlentities(substr($contact_details['name'],0,20)),
111 'username' => htmlentities($contact_details['name']),
112 'details' => $contact_details['location'],
113 'tags' => $contact_details['keywords'],
114 'about' => $contact_details['about'],
115 'account_type' => Contact::getAccountType($contact_details),
118 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
119 'network' => network_to_name($rr['network'], $rr['url']),
124 $tpl = get_markup_template("viewcontact_template.tpl");
125 $o .= replace_macros($tpl, array(
126 '$title' => t('Contacts'),
127 '$contacts' => $contacts,
128 '$paginate' => paginate($a),