membershipreq.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php
  2. /**
  3. * Manage group invite requests.
  4. *
  5. * @package ElggGroups
  6. */
  7. elgg_gatekeeper();
  8. $guid = (int) get_input("group_guid");
  9. elgg_entity_gatekeeper($guid, "group");
  10. elgg_group_gatekeeper();
  11. elgg_set_page_owner_guid($guid);
  12. $group = get_entity($guid);
  13. if (!$group->canEdit()) {
  14. register_error(elgg_echo("groups:noaccess"));
  15. forward(REFERER);
  16. }
  17. $title = elgg_echo("groups:membershiprequests");
  18. // change page title
  19. if ($group->isPublicMembership()) {
  20. $title = elgg_echo("group_tools:menu:invitations");
  21. }
  22. elgg_push_breadcrumb(elgg_echo("groups"), "groups/all");
  23. elgg_push_breadcrumb($group->name, $group->getURL());
  24. elgg_push_breadcrumb($title);
  25. elgg_register_menu_item("title", array(
  26. "name" => "groups:invite",
  27. "href" => "groups/invite/" . $group->getGUID(),
  28. "text" => elgg_echo("groups:invite"),
  29. "link_class" => "elgg-button elgg-button-action",
  30. ));
  31. $subpage = get_input("subpage");
  32. $offset = (int) get_input("offset");
  33. $limit = (int) get_input("limit", 25);
  34. $dbprefix = elgg_get_config("dbprefix");
  35. elgg_push_context("group_membershipreq");
  36. $menu = elgg_view_menu("filter", array(
  37. "entity" => $group,
  38. "class" => "elgg-menu-hz",
  39. "sort_by" => "priority",
  40. "handler" => "groups"
  41. ));
  42. elgg_pop_context();
  43. switch ($subpage) {
  44. case "invites":
  45. // invited users
  46. $options = array(
  47. "joins" => array("JOIN " . $dbprefix . "users_entity ue ON e.guid = ue.guid"),
  48. "type" => "user",
  49. "relationship" => "invited",
  50. "relationship_guid" => $guid,
  51. "offset" => $offset,
  52. "limit" => $limit,
  53. "count" => true,
  54. "order_by" => "ue.name ASC"
  55. );
  56. $count = elgg_get_entities_from_relationship($options);
  57. unset($options["count"]);
  58. $invitations = elgg_get_entities_from_relationship($options);
  59. $content = elgg_view("group_tools/membershipreq/invites", array(
  60. "invitations" => $invitations,
  61. "entity" => $group,
  62. "offset" => $offset,
  63. "limit" => $limit,
  64. "count" => $count
  65. ));
  66. break;
  67. case "email_invites":
  68. // invited emails
  69. $options = array(
  70. "selects" => array("SUBSTRING_INDEX(v.string, '|', -1) AS invited_email"),
  71. "annotation_name" => "email_invitation",
  72. "annotation_owner_guid" => $group->getGUID(),
  73. "wheres" => array("(v.string LIKE '%|%')"),
  74. "offset" => $offset,
  75. "limit" => $limit,
  76. "count" => true,
  77. "order_by" => "invited_email ASC"
  78. );
  79. $count = elgg_get_annotations($options);
  80. unset($options["count"]);
  81. $emails = elgg_get_annotations($options);
  82. $content = elgg_view("group_tools/membershipreq/email_invites", array(
  83. "emails" => $emails,
  84. "entity" => $group,
  85. "offset" => $offset,
  86. "limit" => $limit,
  87. "count" => $count
  88. ));
  89. break;
  90. default:
  91. // membership requests
  92. $options = array(
  93. "joins" => array("JOIN " . $dbprefix . "users_entity ue ON e.guid = ue.guid"),
  94. "type" => "user",
  95. "relationship" => "membership_request",
  96. "relationship_guid" => $guid,
  97. "inverse_relationship" => true,
  98. "offset" => $offset,
  99. "limit" => $limit,
  100. "count" => true,
  101. "order_by" => "ue.name ASC"
  102. );
  103. $count = elgg_get_entities_from_relationship($options);
  104. unset($options["count"]);
  105. $requests = elgg_get_entities_from_relationship($options);
  106. $content = elgg_view("groups/membershiprequests", array(
  107. "requests" => $requests,
  108. "entity" => $group,
  109. "offset" => $offset,
  110. "limit" => $limit,
  111. "count" => $count
  112. ));
  113. break;
  114. }
  115. $params = array(
  116. "content" => $content,
  117. "title" => $title,
  118. "filter" => $menu,
  119. );
  120. $body = elgg_view_layout("content", $params);
  121. echo elgg_view_page($title, $body);