aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--[-rwxr-xr-x]actions/friendrequest/decline.php4
-rw-r--r--actions/friends/remove.php6
-rw-r--r--languages/en.php6
-rw-r--r--start.php25
-rw-r--r--views/default/friendrequest/requests.php47
5 files changed, 80 insertions, 8 deletions
diff --git a/actions/friendrequest/decline.php b/actions/friendrequest/decline.php
index 5b48acfb4..247023c60 100755..100644
--- 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 @@
+<?php
+/**
+ * The friend requests' list
+ *
+ * @uses $vars['requests'] Array of ElggUsers
+ */
+
+if (!empty($vars['requests']) && is_array($vars['requests'])) {
+ $user = elgg_get_logged_in_user_entity();
+ echo '<ul class="elgg-list">';
+ 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 = "<h4>$user_title</h4>";
+ $alt = $accept_button . $delete_button;
+
+ echo '<li class="pvs">';
+ echo elgg_view_image_block($icon, $body, array('image_alt' => $alt));
+ echo '</li>';
+ }
+ echo '</ul>';
+} else {
+ echo '<p class="mtm">' . elgg_echo('friendrequest:none') . "</p>";
+}