Commit 83504279 authored by Robert Lyon's avatar Robert Lyon
Browse files

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: default avatarRobert Lyon <robertl@catalyst.net.nz>
(cherry picked from commit c4d63db6)
parent a5bb35a4
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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),
+5 −0
Original line number Diff line number Diff line
@@ -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"}
+34 −0
Original line number Diff line number Diff line
<?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
+8 −2
Original line number Diff line number Diff line
@@ -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');