diff options
author | Sem <sembrestels@riseup.net> | 2011-12-08 19:15:33 +0100 |
---|---|---|
committer | Sem <sembrestels@riseup.net> | 2011-12-08 19:15:33 +0100 |
commit | 5c4dc1474ae89437f52101039f1452c267c252a7 (patch) | |
tree | d79e54a330b9682f635b21bafbce58157fe45650 /actions/friends/remove.php | |
parent | f14c7d977d57e7a2cca8bff8931a56fe405cf50c (diff) | |
download | elgg-5c4dc1474ae89437f52101039f1452c267c252a7.tar.gz elgg-5c4dc1474ae89437f52101039f1452c267c252a7.tar.bz2 |
Added friend/remove and friendrequest/decline actions.
Diffstat (limited to 'actions/friends/remove.php')
-rw-r--r-- | actions/friends/remove.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/actions/friends/remove.php b/actions/friends/remove.php new file mode 100644 index 000000000..4ba7bc572 --- /dev/null +++ b/actions/friends/remove.php @@ -0,0 +1,24 @@ +<?php + +$friend = get_entity(sanitize_int(get_input('friend'))); +$user = elgg_get_logged_in_user_entity(); + +if(!elgg_instanceof($friend, 'user')){ + register_error(elgg_echo('friendrequest:remove:failure', array($friend->name))); + forward(REFERER); +} + +if(check_entity_relationship($user->guid, "friend", $friend->guid)) { + try { + $user->removeFriend($friend->guid); + if(check_entity_relationship($friend->guid, "friend", $user->guid)){ + $friend->removeFriend($user->guid); + } + } catch (Exception $e) { + register_error(elgg_echo('friendrequest:remove:failure', array($friend->name))); + forward(REFERER); + } +} + +system_message(elgg_echo('friendrequest:remove:successful', array($friend->name))); +forward(REFERER); |