Elgg  Version 2.3
remove.php
Go to the documentation of this file.
1 <?php
9 // Get the GUID of the user to friend
10 $friend_guid = (int) get_input('friend');
11 
13 if (!$friend) {
14  return elgg_error_response(elgg_echo('error:missing_data'));
15 }
16 
18 if (!$user->isFriendsWith($friend->guid)) {
19  return elgg_ok_response('', elgg_echo('friends:remove:no_friend', [$friend->getDisplayName()]));
20 }
21 
22 if (!elgg_get_logged_in_user_entity()->removeFriend($friend->guid)) {
23  return elgg_error_response(elgg_echo('friends:remove:failure', [$friend->getDisplayName()]));
24 }
25 
26 return elgg_ok_response('', elgg_echo('friends:remove:successful', [$friend->getDisplayName()]));
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
$friend_guid
Definition: remove.php:10
$friend
Definition: remove.php:12
$user
Definition: remove.php:7
get_user($guid)
Get a user object from a GUID.
Definition: users.php:87
get_input($variable, $default=null, $filter_result=true)
Get some input from variables passed submitted through GET or POST.
Definition: input.php:27
elgg_error_response($error= '', $forward_url=REFERRER, $status_code=ELGG_HTTP_OK)
Prepare an error response to be returned by a page or an action handler.
elgg_ok_response($content= '', $message= '', $forward_url=null, $status_code=ELGG_HTTP_OK)
Prepares a successful response to be returned by a page or an action handler.
elgg_get_logged_in_user_entity()
Return the current logged in user, or null if no user is logged in.
Definition: sessions.php:32