all.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * Extra tabs for the all groups page
  4. */
  5. // all groups doesn"t get link to self
  6. elgg_pop_breadcrumb();
  7. elgg_push_breadcrumb(elgg_echo("groups"));
  8. // only register title button if allowed
  9. if ((elgg_get_plugin_setting("limited_groups", "groups") != "yes") || elgg_is_admin_logged_in()) {
  10. elgg_register_title_button();
  11. }
  12. $selected_tab = get_input("filter");
  13. // default group options
  14. $group_options = array(
  15. "type" => "group",
  16. "full_view" => false,
  17. );
  18. $dbprefix = elgg_get_config("dbprefix");
  19. switch ($selected_tab) {
  20. case "ordered":
  21. $order_id = elgg_get_metastring_id("order");
  22. $group_options["limit"] = false;
  23. $group_options["pagination"] = false;
  24. $group_options["selects"] = array(
  25. "IFNULL((SELECT order_ms.string as order_val FROM " . $dbprefix . "metadata mo JOIN " . $dbprefix . "metastrings order_ms ON mo.value_id = order_ms.id WHERE e.guid = mo.entity_guid AND mo.name_id = " . $order_id . "), 99999) AS order_val"
  26. );
  27. $group_options["order_by"] = "CAST(order_val AS SIGNED) ASC, e.time_created DESC";
  28. if (elgg_is_admin_logged_in()) {
  29. $group_options["list_class"] = "group-tools-list-ordered";
  30. }
  31. break;
  32. case "yours":
  33. elgg_gatekeeper();
  34. $group_options["relationship"] = "member";
  35. $group_options["relationship_guid"] = elgg_get_logged_in_user_guid();
  36. $group_options["inverse_relationship"] = false;
  37. break;
  38. case "featured":
  39. $group_options["metadata_name_value_pairs"] = array(
  40. 'metadata_name' => 'featured_group',
  41. 'metadata_value' => 'yes'
  42. );
  43. break;
  44. case "open":
  45. $group_options["metadata_name_value_pairs"] = array(
  46. "name" => "membership",
  47. "value" => ACCESS_PUBLIC
  48. );
  49. break;
  50. case "closed":
  51. $group_options["metadata_name_value_pairs"] = array(
  52. "name" => "membership",
  53. "value" => ACCESS_PUBLIC,
  54. "operand" => "<>"
  55. );
  56. break;
  57. case "alpha":
  58. $group_options["joins"] = array("JOIN " . $dbprefix . "groups_entity ge ON e.guid = ge.guid");
  59. $group_options["order_by"] = "ge.name ASC";
  60. break;
  61. }
  62. if (isset($group_options["relationship"])) {
  63. $content = elgg_list_entities_from_relationship($group_options);
  64. } else {
  65. $content = elgg_list_entities_from_metadata($group_options);
  66. }
  67. if (empty($content)) {
  68. $content = elgg_echo("groups:none");
  69. }
  70. $filter = elgg_view("groups/group_sort_menu", array("selected" => $selected_tab));
  71. $sidebar = elgg_view("groups/sidebar/find");
  72. $sidebar .= elgg_view("groups/sidebar/featured");
  73. $params = array(
  74. "content" => $content,
  75. "sidebar" => $sidebar,
  76. "filter" => $filter,
  77. );
  78. $body = elgg_view_layout("content", $params);
  79. echo elgg_view_page(elgg_echo("groups:all"), $body);