index.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. elgg_gatekeeper();
  3. $user = elgg_get_page_owner_entity();
  4. if (!($user instanceof ElggUser)) {
  5. $user = elgg_get_logged_in_user_entity();
  6. elgg_set_page_owner_guid($user->getGUID());
  7. }
  8. if (!$user->canEdit()) {
  9. forward(REFERER);
  10. }
  11. // set the correct context and page owner
  12. elgg_push_context('friends');
  13. // breadcrumb
  14. elgg_push_breadcrumb(elgg_echo('friends'), "friends/{$user->username}");
  15. elgg_push_breadcrumb(elgg_echo('friend_request:menu'));
  16. $options = [
  17. 'type' => 'user',
  18. 'limit' => false,
  19. 'relationship' => 'friendrequest',
  20. 'relationship_guid' => $user->getGUID(),
  21. 'inverse_relationship' => true,
  22. ];
  23. // Get all received requests
  24. $received_requests = elgg_get_entities_from_relationship($options);
  25. // Get all received requests
  26. $options['inverse_relationship'] = false;
  27. $sent_requests = elgg_get_entities_from_relationship($options);
  28. // Get page elements
  29. $title_text = elgg_echo('friend_request:title', [$user->name]);
  30. $content = elgg_view('friend_request/received', [
  31. 'entities' => $received_requests,
  32. ]);
  33. $content .= elgg_view('friend_request/sent', [
  34. 'entities' => $sent_requests,
  35. ]);
  36. // Build page
  37. $body = elgg_view_layout('content', [
  38. 'title' => $title_text,
  39. 'content' => $content,
  40. 'filter' => false,
  41. ]);
  42. // Draw page
  43. echo elgg_view_page($title_text, $body);