invite.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Invite users to groups
  4. *
  5. * @package ElggGroups
  6. */
  7. gatekeeper();
  8. $guid = (int) get_input("group_guid");
  9. $group = get_entity($guid);
  10. if (!empty($group) && ($group instanceof ElggGroup)) {
  11. if ($group->canEdit() || group_tools_allow_members_invite($group)) {
  12. elgg_set_page_owner_guid($guid);
  13. // get plugin settings
  14. $invite = elgg_get_plugin_setting("invite", "group_tools");
  15. $invite_email = elgg_get_plugin_setting("invite_email", "group_tools");
  16. $invite_csv = elgg_get_plugin_setting("invite_csv", "group_tools");
  17. if (in_array("yes", array($invite, $invite_csv, $invite_email))) {
  18. $title = elgg_echo("group_tools:groups:invite:title");
  19. $breadcrumb = elgg_echo("group_tools:groups:invite");
  20. } else {
  21. $title = elgg_echo("groups:invite:title");
  22. $breadcrumb = elgg_echo("groups:invite");
  23. }
  24. elgg_push_breadcrumb(elgg_echo("groups"), "groups/all");
  25. elgg_push_breadcrumb($group->name, $group->getURL());
  26. elgg_push_breadcrumb($breadcrumb);
  27. $content = elgg_view_form("groups/invite", array(
  28. "id" => "invite_to_group",
  29. "class" => "elgg-form-alt mtm",
  30. "enctype" => "multipart/form-data"
  31. ), array(
  32. "entity" => $group,
  33. "invite" => $invite,
  34. "invite_email" => $invite_email,
  35. "invite_csv" => $invite_csv
  36. ));
  37. $params = array(
  38. "content" => $content,
  39. "title" => $title,
  40. "filter" => "",
  41. );
  42. $body = elgg_view_layout("content", $params);
  43. echo elgg_view_page($title, $body);
  44. } else {
  45. register_error(elgg_echo("groups:noaccess"));
  46. forward(REFERER);
  47. }
  48. } else {
  49. register_error(elgg_echo("groups:noaccess"));
  50. forward(REFERER);
  51. }