mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-60828 user: Reset current page when filtering/searching users
Added baseurl parameter to core_user\output\unified_filter to let specify different URL, instead of using always $PAGE->url.
This commit is contained in:
parent
1287039e62
commit
bb4a79234b
@ -23,6 +23,7 @@
|
|||||||
*/
|
*/
|
||||||
namespace core_user\output;
|
namespace core_user\output;
|
||||||
|
|
||||||
|
use moodle_url;
|
||||||
use renderable;
|
use renderable;
|
||||||
use renderer_base;
|
use renderer_base;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
@ -44,15 +45,22 @@ class unified_filter implements renderable, templatable {
|
|||||||
/** @var array $selectedoptions The list of selected filter option values. */
|
/** @var array $selectedoptions The list of selected filter option values. */
|
||||||
protected $selectedoptions;
|
protected $selectedoptions;
|
||||||
|
|
||||||
|
/** @var moodle_url|string $baseurl The url with params needed to call up this page. */
|
||||||
|
protected $baseurl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* unified_filter constructor.
|
* unified_filter constructor.
|
||||||
*
|
*
|
||||||
* @param array $filteroptions The filter options.
|
* @param array $filteroptions The filter options.
|
||||||
* @param array $selectedoptions The list of selected filter option values.
|
* @param array $selectedoptions The list of selected filter option values.
|
||||||
|
* @param string|moodle_url $baseurl The url with params needed to call up this page.
|
||||||
*/
|
*/
|
||||||
public function __construct($filteroptions, $selectedoptions) {
|
public function __construct($filteroptions, $selectedoptions, $baseurl = null) {
|
||||||
$this->filteroptions = $filteroptions;
|
$this->filteroptions = $filteroptions;
|
||||||
$this->selectedoptions = $selectedoptions;
|
$this->selectedoptions = $selectedoptions;
|
||||||
|
if (!empty($baseurl)) {
|
||||||
|
$this->baseurl = new moodle_url($baseurl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +72,10 @@ class unified_filter implements renderable, templatable {
|
|||||||
public function export_for_template(renderer_base $output) {
|
public function export_for_template(renderer_base $output) {
|
||||||
global $PAGE;
|
global $PAGE;
|
||||||
$data = new stdClass();
|
$data = new stdClass();
|
||||||
$data->action = $PAGE->url->out(false);
|
if (empty($this->baseurl)) {
|
||||||
|
$this->baseurl = $PAGE->url;
|
||||||
|
}
|
||||||
|
$data->action = $this->baseurl->out(false);
|
||||||
|
|
||||||
foreach ($this->selectedoptions as $option) {
|
foreach ($this->selectedoptions as $option) {
|
||||||
if (!isset($this->filteroptions[$option])) {
|
if (!isset($this->filteroptions[$option])) {
|
||||||
|
@ -213,18 +213,18 @@ foreach ($enrolbuttons as $enrolbutton) {
|
|||||||
}
|
}
|
||||||
echo html_writer::div($enrolbuttonsout, 'pull-right');
|
echo html_writer::div($enrolbuttonsout, 'pull-right');
|
||||||
|
|
||||||
// Render the unified filter.
|
|
||||||
$renderer = $PAGE->get_renderer('core_user');
|
|
||||||
echo $renderer->unified_filter($course, $context, $filtersapplied);
|
|
||||||
|
|
||||||
echo '<div class="userlist">';
|
|
||||||
|
|
||||||
// Should use this variable so that we don't break stuff every time a variable is added or changed.
|
// Should use this variable so that we don't break stuff every time a variable is added or changed.
|
||||||
$baseurl = new moodle_url('/user/index.php', array(
|
$baseurl = new moodle_url('/user/index.php', array(
|
||||||
'contextid' => $context->id,
|
'contextid' => $context->id,
|
||||||
'id' => $course->id,
|
'id' => $course->id,
|
||||||
'perpage' => $perpage));
|
'perpage' => $perpage));
|
||||||
|
|
||||||
|
// Render the unified filter.
|
||||||
|
$renderer = $PAGE->get_renderer('core_user');
|
||||||
|
echo $renderer->unified_filter($course, $context, $filtersapplied, $baseurl);
|
||||||
|
|
||||||
|
echo '<div class="userlist">';
|
||||||
|
|
||||||
$participanttable = new \core_user\participants_table($course->id, $groupid, $lastaccess, $roleid, $enrolid, $status,
|
$participanttable = new \core_user\participants_table($course->id, $groupid, $lastaccess, $roleid, $enrolid, $status,
|
||||||
$searchkeywords, $bulkoperations, $selectall);
|
$searchkeywords, $bulkoperations, $selectall);
|
||||||
$participanttable->define_baseurl($baseurl);
|
$participanttable->define_baseurl($baseurl);
|
||||||
|
@ -115,9 +115,10 @@ class core_user_renderer extends plugin_renderer_base {
|
|||||||
* @param stdClass $course The course object.
|
* @param stdClass $course The course object.
|
||||||
* @param context $context The context object.
|
* @param context $context The context object.
|
||||||
* @param array $filtersapplied Array of currently applied filters.
|
* @param array $filtersapplied Array of currently applied filters.
|
||||||
|
* @param string|moodle_url $baseurl The url with params needed to call up this page.
|
||||||
* @return bool|string
|
* @return bool|string
|
||||||
*/
|
*/
|
||||||
public function unified_filter($course, $context, $filtersapplied) {
|
public function unified_filter($course, $context, $filtersapplied, $baseurl = null) {
|
||||||
global $CFG, $DB, $USER;
|
global $CFG, $DB, $USER;
|
||||||
|
|
||||||
require_once($CFG->dirroot . '/enrol/locallib.php');
|
require_once($CFG->dirroot . '/enrol/locallib.php');
|
||||||
@ -248,7 +249,7 @@ class core_user_renderer extends plugin_renderer_base {
|
|||||||
// Add missing applied filters to the filter options.
|
// Add missing applied filters to the filter options.
|
||||||
$filteroptions = $this->handle_missing_applied_filters($filtersapplied, $filteroptions);
|
$filteroptions = $this->handle_missing_applied_filters($filtersapplied, $filteroptions);
|
||||||
|
|
||||||
$indexpage = new \core_user\output\unified_filter($filteroptions, $filtersapplied);
|
$indexpage = new \core_user\output\unified_filter($filteroptions, $filtersapplied, $baseurl);
|
||||||
$context = $indexpage->export_for_template($this->output);
|
$context = $indexpage->export_for_template($this->output);
|
||||||
|
|
||||||
return $this->output->render_from_template('core_user/unified_filter', $context);
|
return $this->output->render_from_template('core_user/unified_filter', $context);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user