decline.php 785 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. $friend_guid = (int) get_input('guid');
  3. $friend = get_user($friend_guid);
  4. if (empty($friend)) {
  5. register_error(elgg_echo('error:missing_data'));
  6. forward(REFERER);
  7. }
  8. $user = elgg_get_logged_in_user_entity();
  9. if (!remove_entity_relationship($friend->getGUID(), 'friendrequest', $user->getGUID())) {
  10. register_error(elgg_echo('friend_request:decline:fail'));
  11. forward(REFERER);
  12. }
  13. $subject = elgg_echo('friend_request:decline:subject', [$user->name]);
  14. $message = elgg_echo('friend_request:decline:message', [$friend->name, $user->name]);
  15. $params = [
  16. 'action' => 'friend_request_decline',
  17. 'object' => $user,
  18. ];
  19. notify_user($friend->getGUID(), $user->getGUID(), $subject, $message, $params);
  20. system_message(elgg_echo('friend_request:decline:success'));
  21. forward(REFERER);