Commit eee4f445 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Friend request options return you to correct pagination (bug #852304)"

parents 8dab3d36 77dd66aa
......@@ -1753,6 +1753,7 @@ function build_userlist_html(&$data, $page, $admingroups) {
$smarty = smarty_core();
$smarty->assign('data', isset($userdata) ? $userdata : null);
$smarty->assign('page', $page);
$smarty->assign('offset', $data['offset']);
$params = array();
if (isset($data['query'])) {
......
......@@ -18,14 +18,14 @@
{if $user->pending}
<li class="approvefriend">{$user->accept|safe}</li>
<li class="denyrequest">
<a href="{$WWWROOT}user/denyrequest.php?id={$user->id}&amp;returnto={$page}" class="btn-deny">
<a href="{$WWWROOT}user/denyrequest.php?id={$user->id}&amp;returnto={$page}&amp;offset={$offset}" class="btn-deny">
{str tag='denyrequest' section='group'}
</a>
</li>
{/if}
{if $user->friend}
<li class="removefriend">
<a href="{$WWWROOT}user/removefriend.php?id={$user->id}&amp;returnto={$page}" class="btn-del">
<a href="{$WWWROOT}user/removefriend.php?id={$user->id}&amp;returnto={$page}&amp;offset={$offset}" class="btn-del">
{str tag='removefromfriendslist' section='group'}
</a>
</li>
......@@ -36,7 +36,7 @@
{elseif !$user->pending} {* Not an existing, pending, or requested friend *}
{if $user->friendscontrol == 'auth'}
<li class="friend">
<a href="{$WWWROOT}user/requestfriendship.php?id={$user->id}&amp;returnto={$page}" class="btn-request">
<a href="{$WWWROOT}user/requestfriendship.php?id={$user->id}&amp;returnto={$page}&amp;offset={$offset}" class="btn-request">
{str tag='sendfriendrequest' section='group'}
</a>
</li>
......@@ -52,7 +52,7 @@
{/if}
{if $user->messages}
<li class="messages">
<a href="{$WWWROOT}user/sendmessage.php?id={$user->id}&amp;returnto={$page}" class="btn-message">
<a href="{$WWWROOT}user/sendmessage.php?id={$user->id}&amp;returnto={$page}&amp;offset={$offset}" class="btn-message">
{str tag='sendmessage' section='group'}
</a>
</li>
......
......@@ -18,7 +18,6 @@ require_once('searchlib.php');
safe_require('search', 'internal');
$id = param_integer('id');
$returnto = param_alpha('returnto', 'myfriends');
if (!record_exists('usr_friend_request', 'owner', $USER->get('id'), 'requester', $id)
|| !($user = get_record('usr', 'id', $id, 'deleted', 0))) {
......@@ -27,6 +26,21 @@ if (!record_exists('usr_friend_request', 'owner', $USER->get('id'), 'requester',
$user->introduction = get_field('artefact', 'title', 'artefacttype', 'introduction', 'owner', $id);
$returnto = param_alpha('returnto', 'myfriends');
$offset = param_integer('offset', 0);
switch ($returnto) {
case 'find':
$goto = 'user/find.php';
break;
case 'view':
$goto = profile_url($user, false);
break;
default:
$goto = 'user/myfriends.php';
}
$goto .= (strpos($goto,'?') ? '&' : '?') . 'offset=' . $offset;
$goto = get_config('wwwroot') . $goto;
$form = pieform(array(
'name' => 'denyrequest',
'autofocus' => false,
......@@ -40,7 +54,7 @@ $form = pieform(array(
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('denyfriendrequestlower', 'group'), get_string('cancel')),
'goto' => get_config('wwwroot') . ($returnto == 'find' ? 'user/find.php' : ($returnto == 'view' ? profile_url($user, false) : 'user/myfriends.php')),
'goto' => $goto,
)
)
));
......@@ -83,15 +97,19 @@ function denyrequest_submit(Pieform $form, $values) {
handle_event('removefriendrequest', array('owner' => $loggedinid, 'requester' => $id));
$SESSION->add_ok_msg(get_string('friendformrejectsuccess', 'group'));
$offset = param_integer('offset', 0);
switch (param_alpha('returnto', 'myfriends')) {
case 'find':
redirect('/user/find.php');
$goto = 'user/find.php';
break;
case 'view':
redirect(profile_url($user));
$goto = profile_url($user, false);
break;
default:
redirect('/user/myfriends.php');
$goto = 'user/myfriends.php';
break;
}
$goto .= (strpos($goto,'?')) ? '&offset=' . $offset : '?offset=' . $offset;
$goto = get_config('wwwroot') . $goto;
redirect($goto);
}
......@@ -15,7 +15,6 @@ require(dirname(dirname(__FILE__)) . '/init.php');
require_once('pieforms/pieform.php');
$id = param_integer('id');
$returnto = param_alpha('returnto', 'myfriends');
if (!is_friend($id, $USER->get('id')) || !$user = get_record('usr', 'id', $id, 'deleted', 0)) {
throw new AccessDeniedException(get_string('cantremovefriend', 'group'));
......@@ -25,6 +24,21 @@ $user->introduction = get_field('artefact', 'title', 'artefacttype', 'introducti
define('TITLE', get_string('removefromfriends', 'group', display_name($id)));
$returnto = param_alpha('returnto', 'myfriends');
$offset = param_integer('offset', 0);
switch ($returnto) {
case 'find':
$goto = 'user/find.php';
break;
case 'view':
$goto = profile_url($user, false);
break;
default:
$goto = 'user/myfriends.php';
}
$goto .= (strpos($goto,'?') ? '&' : '?') . 'offset=' . $offset;
$goto = get_config('wwwroot') . $goto;
$form = pieform(array(
'name' => 'removefriend',
'autofocus' => false,
......@@ -38,7 +52,7 @@ $form = pieform(array(
'submit' => array(
'type' => 'submitcancel',
'value' => array(get_string('removefriend', 'group'), get_string('cancel')),
'goto' => get_config('wwwroot') . ($returnto == 'find' ? 'user/find.php' : ($returnto == 'view' ? profile_url($user, false) : 'user/myfriends.php')),
'goto' => $goto,
)
)
));
......@@ -83,16 +97,19 @@ function removefriend_submit(Pieform $form, $values) {
handle_event('removefriend', array('user' => $loggedinid, 'friend' => $id));
$SESSION->add_ok_msg(get_string('friendformremovesuccess', 'group', display_name($id)));
$offset = param_integer('offset', 0);
switch (param_alpha('returnto', 'myfriends')) {
case 'find':
redirect('/user/find.php');
$goto = 'user/find.php';
break;
case 'view':
redirect(profile_url($user));
$goto = profile_url($user, false);
break;
default:
redirect('/user/myfriends.php');
$goto = 'user/myfriends.php';
break;
}
$goto .= (strpos($goto,'?')) ? '&offset=' . $offset : '?offset=' . $offset;
$goto = get_config('wwwroot') . $goto;
redirect($goto);
}
......@@ -27,13 +27,14 @@ $user->introduction = get_field('artefact', 'title', 'artefacttype', 'introducti
define('TITLE', get_string('sendfriendshiprequest', 'group', display_name($id)));
$returnto = param_alpha('returnto', 'myfriends');
$offset = param_integer('offset', 0);
switch ($returnto) {
case 'find': $goto = 'user/find.php'; break;
case 'view': $goto = profile_url($user, false); break;
default:
$goto = 'user/myfriends.php';
}
$goto .= (strpos($goto,'?')) ? '&offset=' . $offset : '?offset=' . $offset;
$goto = get_config('wwwroot') . $goto;
if (is_friend($id, $USER->get('id'))) {
......
......@@ -46,6 +46,7 @@ else if (!can_send_message($USER->to_stdclass(), $id)) {
define('TITLE', get_string('sendmessageto', 'group', display_name($user)));
$returnto = param_alpha('returnto', 'myfriends');
$offset = param_integer('offset', 0);
switch ($returnto) {
case 'find':
$goto = 'user/find.php';
......@@ -64,6 +65,7 @@ switch ($returnto) {
default:
$goto = 'user/myfriends.php';
}
$goto .= (strpos($goto,'?')) ? '&offset=' . $offset : '?offset=' . $offset;
$form = pieform(array(
'name' => 'sendmessage',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment