From 5c4dc1474ae89437f52101039f1452c267c252a7 Mon Sep 17 00:00:00 2001 From: Sem Date: Thu, 8 Dec 2011 19:15:33 +0100 Subject: Added friend/remove and friendrequest/decline actions. --- actions/friendrequest/decline.php | 12 ++++++++++++ actions/friends/add.php | 3 ++- actions/friends/remove.php | 24 ++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100755 actions/friendrequest/decline.php create mode 100644 actions/friends/remove.php (limited to 'actions') diff --git a/actions/friendrequest/decline.php b/actions/friendrequest/decline.php new file mode 100755 index 000000000..5b48acfb4 --- /dev/null +++ b/actions/friendrequest/decline.php @@ -0,0 +1,12 @@ +guid, 'friendrequest', $user->guid)) { + system_message(elgg_echo("friendrequest:remove:success")); +} else { + system_message(elgg_echo("friendrequest:remove:fail")); +} + +forward(REFERER); diff --git a/actions/friends/add.php b/actions/friends/add.php index 702a384d3..5d4ecc078 100644 --- a/actions/friends/add.php +++ b/actions/friends/add.php @@ -9,7 +9,8 @@ if(!elgg_instanceof($friend, 'user')){ } if(check_entity_relationship($friend->guid, "friendrequest", $user->guid) - || check_entity_relationship($friend->guid, "friend", $user->guid)) { + || check_entity_relationship($friend->guid, "friend", $user->guid)) { + $user->addFriend($friend->guid); remove_entity_relationship($friend->guid, "friendrequest", $user->guid); 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 @@ +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); -- cgit v1.2.3