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` OR `pending`) AND NOT `hidden` AND NOT `archive`
52 AND `network` IN ('%s', '%s', '%s')",
53 intval($a->profile['uid']),
55 dbesc(NETWORK_DIASPORA),
56 dbesc(NETWORK_OSTATUS)
58 if (dbm::is_result($r))
59 $a->set_pager_total($r[0]['total']);
61 $r = q("SELECT * FROM `contact`
62 WHERE `uid` = %d AND (NOT `blocked` OR `pending`) AND NOT `hidden` AND NOT `archive`
63 AND `network` IN ('%s', '%s', '%s')
64 ORDER BY `name` ASC LIMIT %d, %d",
65 intval($a->profile['uid']),
67 dbesc(NETWORK_DIASPORA),
68 dbesc(NETWORK_OSTATUS),
69 intval($a->pager['start']),
70 intval($a->pager['itemspage'])
72 if (!dbm::is_result($r)) {
73 info(t('No contacts.').EOL);
80 /// @TODO This triggers an E_NOTICE if 'self' is not there
87 // route DFRN profiles through the redirect
89 $is_owner = ((local_user() && ($a->profile['profile_uid'] == local_user())) ? true : false);
91 if($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel']))
92 $url = 'redir/' . $rr['id'];
96 $contact_details = get_contact_details_by_url($rr['url'], $a->profile['uid'], $rr);
100 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'), $contact_details['name'], $rr['url']),
101 'photo_menu' => contact_photo_menu($rr),
102 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
103 'name' => htmlentities(substr($contact_details['name'],0,20)),
104 'username' => htmlentities($contact_details['name']),
105 'details' => $contact_details['location'],
106 'tags' => $contact_details['keywords'],
107 'about' => $contact_details['about'],
108 'account_type' => account_type($contact_details),
111 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
112 'network' => network_to_name($rr['network'], $rr['url']),
117 $tpl = get_markup_template("viewcontact_template.tpl");
118 $o .= replace_macros($tpl, array(
119 '$title' => t('Contacts'),
120 '$contacts' => $contacts,
121 '$paginate' => paginate($a),