diff options
Diffstat (limited to 'mod')
-rw-r--r-- | mod/viewcontacts.php | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/mod/viewcontacts.php b/mod/viewcontacts.php index 3f69e4a09..e3c0c490a 100644 --- a/mod/viewcontacts.php +++ b/mod/viewcontacts.php @@ -1,13 +1,14 @@ <?php require_once('include/contact_selectors.php'); +require_once('include/Contact.php'); function viewcontacts_init(&$a) { if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) { return; } - - profile_load($a,$a->argv[1]); + if(argc() > 1) + profile_load($a,argv(1)); } @@ -33,57 +34,53 @@ function viewcontacts_content(&$a) { return; } + if(! perm_is_allowed($a->profile['uid'], get_observer_hash(),'view_contacts')) { + notice( t('Permission denied.') . EOL); + return; + } + - $r = q("SELECT COUNT(*) as `total` FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 ", + + $r = q("SELECT COUNT(abook_id) as total FROM abook WHERE abook_channel = %d AND abook_flags = 0 ", intval($a->profile['uid']) ); - if(count($r)) + if($r) $a->set_pager_total($r[0]['total']); - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 ORDER BY `name` ASC LIMIT %d , %d ", + $r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and abook_flags = 0 order by xchan_name LIMIT %d , %d ", intval($a->profile['uid']), intval($a->pager['start']), intval($a->pager['itemspage']) ); - if(! count($r)) { - info( t('No contacts.') . EOL ); + + if(! $r) { + info( t('No connections.') . EOL ); return $o; } $contacts = array(); foreach($r as $rr) { - if($rr['self']) - continue; - - $url = $rr['url']; - - // route DFRN profiles through the redirect - - $is_owner = ((local_user() && ($a->profile['profile_uid'] == local_user())) ? true : false); - if($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel'])) - $url = 'redir/' . $rr['id']; - else - $url = zid($url); + $url = zid($rr['xchan_url']); $contacts[] = array( - 'id' => $rr['id'], - 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'), $rr['name'], $rr['url']), - 'thumb' => $rr['thumb'], - 'name' => substr($rr['name'],0,20), - 'username' => $rr['name'], + 'id' => $rr['abook_id'], + 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'), $rr['xchan_name'], $rr['xchan_url']), + 'thumb' => $rr['xchan_photo_m'], + 'name' => substr($rr['xchan_name'],0,20), + 'username' => $rr['xchan_addr'], 'url' => $url, 'sparkle' => '', 'itemurl' => $rr['url'], - 'network' => network_to_name($rr['network']), + 'network' => '', ); } $tpl = get_markup_template("viewcontact_template.tpl"); $o .= replace_macros($tpl, array( - '$title' => t('View Contacts'), + '$title' => t('View Connnections'), '$contacts' => $contacts, '$paginate' => paginate($a), )); |