events.php 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. /**
  3. * All event handlers are bundled in this file
  4. */
  5. /**
  6. * Notify a user when a friend relationship is created
  7. *
  8. * @param string $event the name of the event
  9. * @param string $object_type the type of the event
  10. * @param ElggRelationship $object supplied realationship
  11. *
  12. * @return void
  13. */
  14. function friend_request_event_create_friendrequest($event, $object_type, $object) {
  15. if (($object instanceof ElggRelationship)) {
  16. $user_one = get_user($object->guid_one);
  17. $user_two = get_user($object->guid_two);
  18. $view_friends_url = elgg_get_site_url() . "friend_request/" . $user_two->username;
  19. // Notify target user
  20. $subject = elgg_echo("friend_request:newfriend:subject", array($user_one->name));
  21. $message = elgg_echo("friend_request:newfriend:body", array($user_one->name, $view_friends_url));
  22. $params = array(
  23. "action" => "friend_request",
  24. "object" => $user_one
  25. );
  26. notify_user($object->guid_two, $object->guid_one, $subject, $message, $params);
  27. }
  28. }