2 require_once('include/Contact.php');
3 require_once('include/contact_selectors.php');
5 function viewcontacts_init(&$a) {
7 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
11 nav_set_selected('home');
15 $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
22 $a->data['user'] = $r[0];
23 $a->profile_uid = $r[0]['uid'];
24 $is_owner = (local_user() && (local_user() == $a->profile_uid));
26 profile_load($a,$a->argv[1]);
31 function viewcontacts_content(&$a) {
32 require_once("mod/proxy.php");
34 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
35 notice( t('Public access denied.') . EOL);
42 $o .= profile_tabs($a,$is_owner, $a->data['user']['nickname']);
44 if(((! count($a->profile)) || ($a->profile['hide-friends']))) {
45 notice( t('Permission denied.') . EOL);
49 $r = q("SELECT COUNT(*) AS `total` FROM `contact`
50 WHERE `uid` = %d AND NOT `blocked` AND NOT `hidden` AND NOT `archive`
51 AND `network` IN ('%s', '%s', '%s')",
52 intval($a->profile['uid']),
54 dbesc(NETWORK_DIASPORA),
55 dbesc(NETWORK_OSTATUS)
58 $a->set_pager_total($r[0]['total']);
60 $r = q("SELECT * FROM `contact`
61 WHERE `uid` = %d AND NOT `blocked` AND NOT `hidden` AND NOT `archive`
62 AND `network` IN ('%s', '%s', '%s')
63 ORDER BY `name` ASC LIMIT %d, %d",
64 intval($a->profile['uid']),
66 dbesc(NETWORK_DIASPORA),
67 dbesc(NETWORK_OSTATUS),
68 intval($a->pager['start']),
69 intval($a->pager['itemspage'])
72 info(t('No contacts.').EOL);
84 // route DFRN profiles through the redirect
86 $is_owner = ((local_user() && ($a->profile['profile_uid'] == local_user())) ? true : false);
88 if($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel']))
89 $url = 'redir/' . $rr['id'];
93 $contact_details = get_contact_details_by_url($rr['url'], $a->profile['uid'], $rr);
97 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'), $contact_details['name'], $rr['url']),
98 'photo_menu' => contact_photo_menu($rr),
99 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
100 'name' => htmlentities(substr($contact_details['name'],0,20)),
101 'username' => htmlentities($contact_details['name']),
102 'details' => $contact_details['location'],
103 'tags' => $contact_details['keywords'],
104 'about' => $contact_details['about'],
105 'account_type' => account_type($contact_details),
108 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
109 'network' => network_to_name($rr['network'], $rr['url']),
114 $tpl = get_markup_template("viewcontact_template.tpl");
115 $o .= replace_macros($tpl, array(
116 '$title' => t('Contacts'),
117 '$contacts' => $contacts,
118 '$paginate' => paginate($a),