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.

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