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.

101 lines
2.6 KiB

  1. <?php
  2. require_once('include/socgraph.php');
  3. require_once('include/Contact.php');
  4. require_once('include/contact_selectors.php');
  5. require_once('mod/contacts.php');
  6. function allfriends_content(&$a) {
  7. $o = '';
  8. if(! local_user()) {
  9. notice( t('Permission denied.') . EOL);
  10. return;
  11. }
  12. if($a->argc > 1)
  13. $cid = intval($a->argv[1]);
  14. if(! $cid)
  15. return;
  16. $uid = $a->user[uid];
  17. $c = q("SELECT `name`, `url`, `photo` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
  18. intval($cid),
  19. intval(local_user())
  20. );
  21. if(! count($c))
  22. return;
  23. $a->page['aside'] = "";
  24. profile_load($a, "", 0, get_contact_details_by_url($c[0]["url"]));
  25. $total = count_all_friends(local_user(), $cid);
  26. if(count($total))
  27. $a->set_pager_total($total);
  28. $r = all_friends(local_user(), $cid, $a->pager['start'], $a->pager['itemspage']);
  29. if(! count($r)) {
  30. $o .= t('No friends to display.');
  31. return $o;
  32. }
  33. $id = 0;
  34. foreach($r as $rr) {
  35. //get further details of the contact
  36. $contact_details = get_contact_details_by_url($rr['url'], $uid, $rr);
  37. $photo_menu = '';
  38. // $rr[cid] is only available for common contacts. So if the contact is a common one, use contact_photo_menu to generate the photo_menu
  39. // If the contact is not common to the user, Connect/Follow' will be added to the photo menu
  40. if ($rr[cid]) {
  41. $rr[id] = $rr[cid];
  42. $photo_menu = contact_photo_menu ($rr);
  43. }
  44. else {
  45. $connlnk = $a->get_baseurl() . '/follow/?url=' . $rr['url'];
  46. $photo_menu = array(
  47. 'profile' => array(t("View Profile"), zrl($rr['url'])),
  48. 'follow' => array(t("Connect/Follow"), $connlnk)
  49. );
  50. }
  51. $entry = array(
  52. 'url' => $rr['url'],
  53. 'itemurl' => (($contact_details['addr'] != "") ? $contact_details['addr'] : $rr['url']),
  54. 'name' => htmlentities($contact_details['name']),
  55. 'thumb' => proxy_url($contact_details['thumb'], false, PROXY_SIZE_THUMB),
  56. 'img_hover' => htmlentities($contact_details['name']),
  57. 'details' => $contact_details['location'],
  58. 'tags' => $contact_details['keywords'],
  59. 'about' => $contact_details['about'],
  60. 'account_type' => (($contact_details['community']) ? t('Forum') : ''),
  61. 'network' => network_to_name($contact_details['network'], $contact_details['url']),
  62. 'photo_menu' => $photo_menu,
  63. 'conntxt' => t('Connect'),
  64. 'connlnk' => $connlnk,
  65. 'id' => ++$id,
  66. );
  67. $entries[] = $entry;
  68. }
  69. $tab_str = contacts_tab($a, $cid, 3);
  70. $tpl = get_markup_template('viewcontact_template.tpl');
  71. $o .= replace_macros($tpl,array(
  72. //'$title' => sprintf( t('Friends of %s'), htmlentities($c[0]['name'])),
  73. '$tab_str' => $tab_str,
  74. '$contacts' => $entries,
  75. '$paginate' => paginate($a),
  76. ));
  77. return $o;
  78. }