示例#1
0
        $sortorder = 'DESC';
    }
    // Split usort into it relevant parts and add in sortorder.
    $usersort = str_replace(',', ' ' . $sortorder . ',', $usort);
    $usersort .= ' ' . $sortorder;
    $sql = "{$sql} ORDER BY {$usersort}";
}
// Need to do the sql.
global $DB;
$users = $DB->get_records_sql($sql, $params, $offset, $perpage);
if (!$ptable->is_downloading()) {
    // We may have more users as limited to $perpage, so work out how many.
    list($esql, $params) = get_enrolled_sql($context, '', $groupid > 0 ? $groupid : 0);
    $sql = "SELECT count(1) as count\n              FROM {user} u\n              JOIN ({$esql}) je ON je.id = u.id\n             WHERE u.deleted = 0";
    $total = $DB->count_records_sql($sql, $params);
    $ptable->pagesize($perpage, $total);
}
if (empty($download)) {
    print $out->header();
    // Display group selector if required.
    groups_print_activity_menu($cm, $CFG->wwwroot . '/mod/forumng/feature/userposts/list.php?' . $forum->get_link_params(mod_forumng::PARAM_PLAIN));
    print '<div class="clearer"></div>';
    // Get all users.
    if (!$users) {
        // No users, print info and stop.
        print_string('nothingtodisplay', 'forumng');
        // Display link to the discussion.
        print link_arrow_left($forum->get_name(), '../../view.php?id=' . $cmid);
        // Display footer.
        print $out->footer();
        return;