Commit c4d63db6 authored by Robert Lyon's avatar Robert Lyon

Bug 1515484: Fix the online users pagination to use json

This is 2 of 6 patches to standardize pagination

behatnotneeded

Change-Id: I7741ae0d436d7e11fe248307936757d3d8027cc1
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent d9d1cd84
......@@ -121,10 +121,10 @@ var Paginator = function(id, list, heading, script, extradata) {
if ((queryData.offset % setlimitselect.value) !== 0) {
queryData.offset = Math.floor(queryData.offset / setlimitselect.value) * setlimitselect.value;
}
queryData.setlimit = "1";
queryData.limit = setlimitselect.value;
queryData.extradata = serializeJSON(self.extraData);
}
queryData.setlimit = "1";
queryData.limit = setlimitselect.value;
queryData.extradata = serializeJSON(self.extraData);
self.sendQuery(queryData);
});
......
......@@ -2023,6 +2023,9 @@ function build_onlinelist_html(&$data, $page) {
'count' => $data['count'],
'limit' => $data['limit'],
'offset' => $data['offset'],
'datatable' => 'onlinelist',
'jsonscript' => 'user/online.json.php',
'setlimit' => true,
'resultcounttextsingular' => $resultcounttextsingular,
'resultcounttextplural' => $resultcounttextplural,
'extradata' => array('page' => $page),
......
......@@ -6,4 +6,9 @@
</div>
</div>
{$data.pagination|safe}
{if $data.pagination_js}
<script type="application/javascript">
{$data.pagination_js|safe}
</script>
{/if}
{include file="footer.tpl"}
<?php
/**
*
* @package mahara
* @subpackage core
* @author Stacey Walker
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL version 3 or later
* @copyright For copyright information on Mahara, please see the README file distributed with this software.
*
*/
define('INTERNAL', 1);
define('JSON', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
$offset = param_integer('offset', 0);
$limit = param_integer('limit', 10);
$setlimit = param_boolean('setlimit', false);
$data = get_onlineusers($limit, $offset);
build_onlinelist_html($data, 'online');
json_reply(false, array(
'message' => null,
'data' => array(
'tablerows' => $data['tablerows'],
'pagination' => $data['pagination'],
'pagination_js' => $data['pagination_js'],
'count' => $data['count'],
'results' => $data['count'] . ' ' . ($data['count'] == 1 ? get_string('result') : get_string('results')),
'offset' => $offset,
'setlimit' => $setlimit,
)
));
\ No newline at end of file
......@@ -17,8 +17,14 @@ define('SECTION_PLUGINNAME', 'user');
define('SECTION_PAGE', 'onlineusers');
$offset = param_integer('offset', 0);
$limit = 10;
$limit = param_integer('limit', 10);
$userlimit = get_account_preference($USER->get('id'), 'viewsperpage');
if ($limit > 0 && $limit != $userlimit) {
$USER->set_account_preference('viewsperpage', $limit);
}
else {
$limit = $userlimit;
}
$data = get_onlineusers($limit, $offset);
build_onlinelist_html($data, 'online');
......
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