add.php 558 B

12345678910111213141516171819202122232425
  1. <?php
  2. /**
  3. * Elgg add friend action
  4. *
  5. * @package Elgg.Core
  6. * @subpackage Friends.Management
  7. */
  8. // Get the GUID of the user to friend
  9. $friend_guid = get_input('friend');
  10. $friend = get_user($friend_guid);
  11. if (!$friend) {
  12. register_error(elgg_echo('error:missing_data'));
  13. forward(REFERER);
  14. }
  15. if (!elgg_get_logged_in_user_entity()->addFriend($friend->guid, true)) {
  16. register_error(elgg_echo("friends:add:failure", array($friend->name)));
  17. forward(REFERER);
  18. }
  19. system_message(elgg_echo("friends:add:successful", array($friend->name)));
  20. forward(REFERER);