4 use Friendica\Core\Config;
6 require_once('include/Contact.php');
7 require_once('include/contact_selectors.php');
9 function viewcontacts_init(App $a) {
11 if((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) {
15 nav_set_selected('home');
19 $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
23 if (! dbm::is_result($r)) {
27 $a->data['user'] = $r[0];
28 $a->profile_uid = $r[0]['uid'];
29 $is_owner = (local_user() && (local_user() == $a->profile_uid));
31 profile_load($a,$a->argv[1]);
36 function viewcontacts_content(App $a) {
37 require_once("mod/proxy.php");
39 if((Config::get('system','block_public')) && (! local_user()) && (! remote_user())) {
40 notice( t('Public access denied.') . EOL);
47 $o .= profile_tabs($a,$is_owner, $a->data['user']['nickname']);
49 if(((! count($a->profile)) || ($a->profile['hide-friends']))) {
50 notice( t('Permission denied.') . EOL);
54 $r = q("SELECT COUNT(*) AS `total` FROM `contact`
55 WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
56 AND NOT `hidden` AND NOT `archive`
57 AND `network` IN ('%s', '%s', '%s')",
58 intval($a->profile['uid']),
60 dbesc(NETWORK_DIASPORA),
61 dbesc(NETWORK_OSTATUS)
63 if (dbm::is_result($r))
64 $a->set_pager_total($r[0]['total']);
66 $r = q("SELECT * FROM `contact`
67 WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
68 AND NOT `hidden` AND NOT `archive`
69 AND `network` IN ('%s', '%s', '%s')
70 ORDER BY `name` ASC LIMIT %d, %d",
71 intval($a->profile['uid']),
73 dbesc(NETWORK_DIASPORA),
74 dbesc(NETWORK_OSTATUS),
75 intval($a->pager['start']),
76 intval($a->pager['itemspage'])
78 if (!dbm::is_result($r)) {
79 info(t('No contacts.').EOL);
86 /// @TODO This triggers an E_NOTICE if 'self' is not there
93 // route DFRN profiles through the redirect
95 $is_owner = ((local_user() && ($a->profile['profile_uid'] == local_user())) ? true : false);
97 if($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel']))
98 $url = 'redir/' . $rr['id'];
102 $contact_details = get_contact_details_by_url($rr['url'], $a->profile['uid'], $rr);
106 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'), $contact_details['name'], $rr['url']),
107 'photo_menu' => contact_photo_menu($rr),
108 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
109 'name' => htmlentities(substr($contact_details['name'],0,20)),
110 'username' => htmlentities($contact_details['name']),
111 'details' => $contact_details['location'],
112 'tags' => $contact_details['keywords'],
113 'about' => $contact_details['about'],
114 'account_type' => account_type($contact_details),
117 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
118 'network' => network_to_name($rr['network'], $rr['url']),
123 $tpl = get_markup_template("viewcontact_template.tpl");
124 $o .= replace_macros($tpl, array(
125 '$title' => t('Contacts'),
126 '$contacts' => $contacts,
127 '$paginate' => paginate($a),