2 require_once('include/Contact.php');
3 require_once('include/contact_selectors.php');
5 if(! function_exists('viewcontacts_init')) {
6 function viewcontacts_init(&$a) {
8 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
12 nav_set_selected('home');
16 $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
23 $a->data['user'] = $r[0];
24 $a->profile_uid = $r[0]['uid'];
25 $is_owner = (local_user() && (local_user() == $a->profile_uid));
27 profile_load($a,$a->argv[1]);
32 if(! function_exists('viewcontacts_content')) {
33 function viewcontacts_content(&$a) {
34 require_once("mod/proxy.php");
36 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
37 notice( t('Public access denied.') . EOL);
41 if(((! count($a->profile)) || ($a->profile['hide-friends']))) {
42 notice( t('Permission denied.') . EOL);
49 $o .= profile_tabs($a,$is_owner, $a->data['user']['nickname']);
51 $r = q("SELECT COUNT(*) AS `total` FROM `contact`
52 WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0
53 AND `network` IN ('%s', '%s', '%s')",
54 intval($a->profile['uid']),
56 dbesc(NETWORK_DIASPORA),
57 dbesc(NETWORK_OSTATUS)
60 $a->set_pager_total($r[0]['total']);
62 $r = q("SELECT * FROM `contact`
63 WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0
64 AND `network` IN ('%s', '%s', '%s')
65 ORDER BY `name` ASC LIMIT %d, %d",
66 intval($a->profile['uid']),
68 dbesc(NETWORK_DIASPORA),
69 dbesc(NETWORK_OSTATUS),
70 intval($a->pager['start']),
71 intval($a->pager['itemspage'])
74 info(t('No contacts.').EOL);
86 // route DFRN profiles through the redirect
88 $is_owner = ((local_user() && ($a->profile['profile_uid'] == local_user())) ? true : false);
90 if($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel']))
91 $url = 'redir/' . $rr['id'];
95 $contact_details = get_contact_details_by_url($rr['url'], $a->profile['uid']);
99 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'), $rr['name'], $rr['url']),
100 'photo_menu' => contact_photo_menu($rr),
101 'thumb' => proxy_url($rr['thumb'], false, PROXY_SIZE_THUMB),
102 'name' => htmlentities(substr($rr['name'],0,20)),
103 'username' => htmlentities($rr['name']),
104 'details' => $contact_details['location'],
105 'tags' => $contact_details['keywords'],
106 'about' => $contact_details['about'],
107 'account_type' => (($contact_details['community']) ? t('Forum') : ''),
110 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
111 'network' => network_to_name($rr['network'], $rr['url']),
116 $tpl = get_markup_template("viewcontact_template.tpl");
117 $o .= replace_macros($tpl, array(
118 '$title' => t('Contacts'),
119 '$contacts' => $contacts,
120 '$paginate' => paginate($a),