From: Sem Date: Thu, 8 Dec 2011 20:19:02 +0000 (+0100) Subject: Arranged page to see friend requests. X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=ab09c2001bd9384c4e3c2964c5d1a39a0e91b013;p=lorea%2Felgg.git Arranged page to see friend requests. --- diff --git a/actions/friendrequest/decline.php b/actions/friendrequest/decline.php old mode 100755 new mode 100644 index 5b48acfb4..247023c60 --- a/actions/friendrequest/decline.php +++ b/actions/friendrequest/decline.php @@ -4,9 +4,9 @@ $user = elgg_get_logged_in_user_entity(); $friend = get_entity(sanitize_int(get_input("guid"))); if(remove_entity_relationship($friend->guid, 'friendrequest', $user->guid)) { - system_message(elgg_echo("friendrequest:remove:success")); + system_message(elgg_echo("friendrequest:decline:success", array($user->name))); } else { - system_message(elgg_echo("friendrequest:remove:fail")); + system_message(elgg_echo("friendrequest:decline:fail")); } forward(REFERER); diff --git a/actions/friends/remove.php b/actions/friends/remove.php index 4ba7bc572..1ad9471b3 100644 --- a/actions/friends/remove.php +++ b/actions/friends/remove.php @@ -4,7 +4,7 @@ $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))); + register_error(elgg_echo('friends:remove:failure', array($friend->name))); forward(REFERER); } @@ -15,10 +15,10 @@ if(check_entity_relationship($user->guid, "friend", $friend->guid)) { $friend->removeFriend($user->guid); } } catch (Exception $e) { - register_error(elgg_echo('friendrequest:remove:failure', array($friend->name))); + register_error(elgg_echo('friends:remove:failure', array($friend->name))); forward(REFERER); } } -system_message(elgg_echo('friendrequest:remove:successful', array($friend->name))); +system_message(elgg_echo('friends:remove:successful', array($friend->name))); forward(REFERER); diff --git a/languages/en.php b/languages/en.php index 1f9e88a46..821278c1a 100644 --- a/languages/en.php +++ b/languages/en.php @@ -11,6 +11,12 @@ $english = array( 'friendrequest:add:failure' => 'Oops! There was a problem while trying to send the request. Try it again.', 'friendrequest:add:exists' => 'You already sent a friend request to %s, don\'t be so intense.', + 'friendrequest:decline:success' => 'You just delined %s friend request', + 'friendrequest:decline:fail' => 'For any reason this friend request cannot be deleted', + + 'friendrequest:remove:check' => 'Are you sure you want to decline the friend request?', + 'friendrequest:none' => 'No pending friend requests.', + ); diff --git a/start.php b/start.php index e044cc9b5..f3ea460cc 100644 --- a/start.php +++ b/start.php @@ -46,16 +46,35 @@ function friendrequest_page_handler($page){ forward("friendrequests"); } + gatekeeper(); + elgg_push_context('friends'); + + $title = elgg_echo('friendrequest'); + $page_owner = elgg_get_logged_in_user_entity(); + elgg_set_page_owner_guid($page_owner->guid); + + $requests = elgg_get_entities_from_relationship(array( + 'type' => 'user', + 'relationship' => 'friendrequest', + 'relationship_guid' => $page_owner->guid, + 'inverse_relationship' => true, + 'limit' => 0, + )); + $content = elgg_view('friendrequest/requests', array( + 'requests' => $requests, + )); + $params = array( - 'title' => elgg_echo('friendrequest'), + 'content' => $content, + 'title' => $title, 'filter' => '', ); - $body = elgg_view_layout('content', $params); - echo elgg_view_page($params['title'], $body); + echo elgg_view_page($title, $body); + return true; } diff --git a/views/default/friendrequest/requests.php b/views/default/friendrequest/requests.php new file mode 100644 index 000000000..1680bdc4e --- /dev/null +++ b/views/default/friendrequest/requests.php @@ -0,0 +1,47 @@ +'; + foreach ($vars['requests'] as $user) { + $icon = elgg_view_entity_icon($user, 'tiny', array('use_hover' => 'true')); + + $user_title = elgg_view('output/url', array( + 'href' => $user->getURL(), + 'text' => $user->name, + 'is_trusted' => true, + )); + + $url = "action/friends/add?friend={$user->guid}"; + $accept_button = elgg_view('output/url', array( + 'href' => $url, + 'text' => elgg_echo('accept'), + 'class' => 'elgg-button elgg-button-submit', + 'is_action' => true, + 'is_trusted' => true, + )); + + $url = "action/friendrequest/decline?guid={$user->guid}"; + $delete_button = elgg_view('output/confirmlink', array( + 'href' => $url, + 'confirm' => elgg_echo('friendrequest:remove:check'), + 'text' => elgg_echo('delete'), + 'class' => 'elgg-button elgg-button-delete mlm', + )); + + $body = "

$user_title

"; + $alt = $accept_button . $delete_button; + + echo '
  • '; + echo elgg_view_image_block($icon, $body, array('image_alt' => $alt)); + echo '
  • '; + } + echo ''; +} else { + echo '

    ' . elgg_echo('friendrequest:none') . "

    "; +}