2 require_once('include/Contact.php');
3 require_once('include/contact_selectors.php');
5 function viewcontacts_init(App $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",
19 if (! dbm::is_result($r)) {
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 function viewcontacts_content(App $a) {
33 require_once("mod/proxy.php");
35 if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
36 notice( t('Public access denied.') . EOL);
43 $o .= profile_tabs($a,$is_owner, $a->data['user']['nickname']);
45 if(((! count($a->profile)) || ($a->profile['hide-friends']))) {
46 notice( t('Permission denied.') . EOL);
50 $r = q("SELECT COUNT(*) AS `total` FROM `contact`
51 WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
52 AND NOT `hidden` AND NOT `archive`
53 AND `network` IN ('%s', '%s', '%s')",
54 intval($a->profile['uid']),
56 dbesc(NETWORK_DIASPORA),
57 dbesc(NETWORK_OSTATUS)
59 if (dbm::is_result($r))
60 $a->set_pager_total($r[0]['total']);
62 $r = q("SELECT * FROM `contact`
63 WHERE `uid` = %d AND NOT `blocked` AND NOT `pending`
64 AND NOT `hidden` AND NOT `archive`
65 AND `network` IN ('%s', '%s', '%s')
66 ORDER BY `name` ASC LIMIT %d, %d",
67 intval($a->profile['uid']),
69 dbesc(NETWORK_DIASPORA),
70 dbesc(NETWORK_OSTATUS),
71 intval($a->pager['start']),
72 intval($a->pager['itemspage'])
74 if (!dbm::is_result($r)) {
75 info(t('No contacts.').EOL);
82 /// @TODO This triggers an E_NOTICE if 'self' is not there
89 // route DFRN profiles through the redirect
91 $is_owner = ((local_user() && ($a->profile['profile_uid'] == local_user())) ? true : false);
93 if($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel']))
94 $url = 'redir/' . $rr['id'];
98 $contact_details = get_contact_details_by_url($rr['url'], $a->profile['uid'], $rr);
102 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'), $contact_details['name'], $rr['url']),
103 'photo_menu' => contact_photo_menu($rr),
104 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
105 'name' => htmlentities(substr($contact_details['name'],0,20)),
106 'username' => htmlentities($contact_details['name']),
107 'details' => $contact_details['location'],
108 'tags' => $contact_details['keywords'],
109 'about' => $contact_details['about'],
110 'account_type' => account_type($contact_details),
113 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
114 'network' => network_to_name($rr['network'], $rr['url']),
119 $tpl = get_markup_template("viewcontact_template.tpl");
120 $o .= replace_macros($tpl, array(
121 '$title' => t('Contacts'),
122 '$contacts' => $contacts,
123 '$paginate' => paginate($a),