5 require_once('include/Contact.php');
6 require_once('include/contact_selectors.php');
8 function viewcontacts_init(App $a) {
10 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
14 nav_set_selected('home');
18 $r = q("SELECT * FROM `user` WHERE `nickname` = '%s' AND `blocked` = 0 LIMIT 1",
22 if (! dbm::is_result($r)) {
26 $a->data['user'] = $r[0];
27 $a->profile_uid = $r[0]['uid'];
28 $is_owner = (local_user() && (local_user() == $a->profile_uid));
30 profile_load($a,$a->argv[1]);
35 function viewcontacts_content(App $a) {
36 require_once("mod/proxy.php");
38 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
39 notice( t('Public access denied.') . EOL);
46 $o .= profile_tabs($a,$is_owner, $a->data['user']['nickname']);
48 if(((! count($a->profile)) || ($a->profile['hide-friends']))) {
49 notice( t('Permission denied.') . EOL);
53 $r = q("SELECT COUNT(*) AS `total` FROM `contact`
54 WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
55 AND NOT `hidden` AND NOT `archive`
56 AND `network` IN ('%s', '%s', '%s')",
57 intval($a->profile['uid']),
59 dbesc(NETWORK_DIASPORA),
60 dbesc(NETWORK_OSTATUS)
62 if (dbm::is_result($r))
63 $a->set_pager_total($r[0]['total']);
65 $r = q("SELECT * FROM `contact`
66 WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
67 AND NOT `hidden` AND NOT `archive`
68 AND `network` IN ('%s', '%s', '%s')
69 ORDER BY `name` ASC LIMIT %d, %d",
70 intval($a->profile['uid']),
72 dbesc(NETWORK_DIASPORA),
73 dbesc(NETWORK_OSTATUS),
74 intval($a->pager['start']),
75 intval($a->pager['itemspage'])
77 if (!dbm::is_result($r)) {
78 info(t('No contacts.').EOL);
85 /// @TODO This triggers an E_NOTICE if 'self' is not there
92 // route DFRN profiles through the redirect
94 $is_owner = ((local_user() && ($a->profile['profile_uid'] == local_user())) ? true : false);
96 if($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel']))
97 $url = 'redir/' . $rr['id'];
101 $contact_details = get_contact_details_by_url($rr['url'], $a->profile['uid'], $rr);
105 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'), $contact_details['name'], $rr['url']),
106 'photo_menu' => contact_photo_menu($rr),
107 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
108 'name' => htmlentities(substr($contact_details['name'],0,20)),
109 'username' => htmlentities($contact_details['name']),
110 'details' => $contact_details['location'],
111 'tags' => $contact_details['keywords'],
112 'about' => $contact_details['about'],
113 'account_type' => account_type($contact_details),
116 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
117 'network' => network_to_name($rr['network'], $rr['url']),
122 $tpl = get_markup_template("viewcontact_template.tpl");
123 $o .= replace_macros($tpl, array(
124 '$title' => t('Contacts'),
125 '$contacts' => $contacts,
126 '$paginate' => paginate($a),