mail.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Mail all the members of a group
  4. */
  5. $group_guid = (int) get_input("group_guid", 0);
  6. $user_guids = get_input("user_guids");
  7. $subject = get_input("title");
  8. $body = get_input("description");
  9. $forward_url = REFERER;
  10. $user_guids = group_tools_verify_group_members($group_guid, $user_guids);
  11. if (!empty($group_guid) && !empty($body) && !empty($user_guids)) {
  12. $group = get_entity($group_guid);
  13. if (!empty($group) && ($group instanceof ElggGroup)) {
  14. if ($group->canEdit()) {
  15. set_time_limit(0);
  16. $body .= PHP_EOL . PHP_EOL;
  17. $body .= elgg_echo("group_tools:mail:message:from") . ": " . $group->name . " [" . $group->getURL() . "]";
  18. foreach ($user_guids as $guid) {
  19. notify_user($guid, $group->getGUID(), $subject, $body, NULL, "email");
  20. }
  21. system_message(elgg_echo("group_tools:action:mail:success"));
  22. $forward_url = $group->getURL();
  23. } else {
  24. register_error(elgg_echo("group_tools:action:error:edit"));
  25. }
  26. } else {
  27. register_error(elgg_echo("group_tools:action:error:entity"));
  28. }
  29. } else {
  30. register_error(elgg_echo("group_tools:action:error:input"));
  31. }
  32. forward($forward_url);