Friendica Communications Platform (please note that this is a clone of the repository at github, issues are handled there) https://friendi.ca
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

92 lines
2.5 KiB

  1. <?php
  2. require_once('include/Contact.php');
  3. require_once('include/contact_selectors.php');
  4. function viewcontacts_init(&$a) {
  5. if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
  6. return;
  7. }
  8. profile_load($a,$a->argv[1]);
  9. }
  10. function viewcontacts_content(&$a) {
  11. require_once("mod/proxy.php");
  12. if((get_config('system','block_public')) && (! local_user()) && (! remote_user())) {
  13. notice( t('Public access denied.') . EOL);
  14. return;
  15. }
  16. if(((! count($a->profile)) || ($a->profile['hide-friends']))) {
  17. notice( t('Permission denied.') . EOL);
  18. return;
  19. }
  20. $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE `uid` = %d AND `blocked` = 0 AND `pending` = 0 AND `hidden` = 0 AND `archive` = 0 ",
  21. intval($a->profile['uid'])
  22. );
  23. if(count($r))
  24. $a->set_pager_total($r[0]['total']);
  25. $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 ",
  26. intval($a->profile['uid']),
  27. intval($a->pager['start']),
  28. intval($a->pager['itemspage'])
  29. );
  30. if(! count($r)) {
  31. info( t('No contacts.') . EOL );
  32. return $o;
  33. }
  34. $contacts = array();
  35. foreach($r as $rr) {
  36. if($rr['self'])
  37. continue;
  38. $url = $rr['url'];
  39. // route DFRN profiles through the redirect
  40. $is_owner = ((local_user() && ($a->profile['profile_uid'] == local_user())) ? true : false);
  41. if($is_owner && ($rr['network'] === NETWORK_DFRN) && ($rr['rel']))
  42. $url = 'redir/' . $rr['id'];
  43. else
  44. $url = zrl($url);
  45. $contact_details = get_contact_details_by_url($rr['url'], $a->profile['uid']);
  46. $contacts[] = array(
  47. 'id' => $rr['id'],
  48. 'img_hover' => sprintf( t('Visit %s\'s profile [%s]'), $rr['name'], $rr['url']),
  49. 'thumb' => proxy_url($rr['thumb'], false, PROXY_SIZE_THUMB),
  50. 'name' => htmlentities(substr($rr['name'],0,20)),
  51. 'username' => htmlentities($rr['name']),
  52. 'details' => $contact_details['location'],
  53. 'tags' => $contact_details['keywords'],
  54. 'about' => $contact_details['about'],
  55. 'account_type' => (($contact_details['community']) ? t('Forum') : ''),
  56. 'url' => $url,
  57. 'sparkle' => '',
  58. 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
  59. 'network' => network_to_name($rr['network'], $rr['url']),
  60. );
  61. }
  62. $tpl = get_markup_template("viewcontact_template.tpl");
  63. $o .= replace_macros($tpl, array(
  64. '$title' => t('View Contacts'),
  65. '$contacts' => $contacts,
  66. '$paginate' => paginate($a),
  67. ));
  68. return $o;
  69. }