related.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * A page to show (and add) related groups
  4. */
  5. $group_guid = (int) get_input("group_guid");
  6. $group = get_entity($group_guid);
  7. if (empty($group) || !elgg_instanceof($group, "group")) {
  8. register_error(elgg_echo("groups:notfound:details"));
  9. forward(REFERER);
  10. }
  11. // set page owner
  12. elgg_set_page_owner_guid($group->getGUID());
  13. // build breadcrumb
  14. elgg_push_breadcrumb(elgg_echo("groups"), "groups/all");
  15. elgg_push_breadcrumb($group->name, $group->getURL());
  16. $title_text = elgg_echo("group_tools:related_groups:title");
  17. elgg_push_breadcrumb($title_text);
  18. // page elements
  19. $content = "";
  20. if ($group->canEdit()) {
  21. $content .= elgg_view_form("group_tools/related_groups", array("class" => "mbm"), array("entity" => $group));
  22. }
  23. $dbprefix = elgg_get_config("dbprefix");
  24. $options = array(
  25. "type" => "group",
  26. "relationship" => "related_group",
  27. "relationship_guid" => $group->getGUID(),
  28. "full_view" => false,
  29. "joins" => array("JOIN " . $dbprefix . "groups_entity ge ON e.guid = ge.guid"),
  30. "order_by" => "ge.name ASC"
  31. );
  32. // helper context for entity menu
  33. elgg_push_context("group_tools_related_groups");
  34. $listing = elgg_list_entities_from_relationship($options);
  35. elgg_pop_context();
  36. if (!empty($listing)) {
  37. $content .= $listing;
  38. } else {
  39. $content .= "<div>" . elgg_echo("groups_tools:related_groups:none") . "</div>";
  40. }
  41. // build page
  42. $page_data = elgg_view_layout("content", array(
  43. "title" => $title_text,
  44. "content" => $content,
  45. "filter" => ""
  46. ));
  47. // draw page
  48. echo elgg_view_page($title_text, $page_data);