Commit 6d013775 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Fix myfriends pagination urls after first ajax call


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent 95e3e5e4
......@@ -51,13 +51,13 @@ class PluginBlocktypeMyfriends extends SystemBlocktype {
return array('profile', 'dashboard');
}
public static function build_myfriends_html(&$friends, $userid) {
public static function build_myfriends_html(&$friends, $userid, BlockInstance $instance) {
$friendarray = array_chunk($friends['data'], 4); // get the friends into a 4x4 array
$smarty = smarty_core();
$smarty->assign_by_ref('friends', $friendarray);
$friends['tablerows'] = $smarty->fetch('blocktype:myfriends:myfriendrows.tpl');
$baseurl = $_SERVER['REQUEST_URI']; // hmm
$baseurl .= (strpos($baseurl, '?') === false ? '?' : '&') . 'user=' . (int) $userid;
$baseurl = $instance->get_view()->get_url() . '&block=' . $instance->get('id');
$baseurl .= '&user=' . (int) $userid;
$pagination = build_pagination(array(
'id' => 'userfriendstable_pagination',
'class' => 'center nojs-hidden-block',
......@@ -85,7 +85,7 @@ class PluginBlocktypeMyfriends extends SystemBlocktype {
$friends = get_friends($userid, MAXFRIENDDISPLAY, 0);
if ($friends['count']) {
self::build_myfriends_html($friends, $userid);
self::build_myfriends_html($friends, $userid, $instance);
}
else {
$friends = false;
......
......@@ -35,9 +35,10 @@ require_once('user.php');
$userid = param_integer('user');
$offset = param_integer('offset');
$limit = param_integer('limit', MAXFRIENDDISPLAY);
$bi = new BlockInstance(param_integer('block'));
$friends = get_friends($userid, $limit, $offset);
PluginBlocktypeMyfriends::build_myfriends_html($friends, $userid);
PluginBlocktypeMyfriends::build_myfriends_html($friends, $userid, $bi);
json_reply(false, array('data' => $friends));
?>
Markdown is supported
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