Merge branch 'MDL-60828-master' of git://github.com/sarjona/moodle

This commit is contained in:
Andrew Nicols
2018-03-13 14:18:59 +08:00
3 changed files with 22 additions and 10 deletions
+13 -2
View File
@@ -23,6 +23,7 @@
*/
namespace core_user\output;
use moodle_url;
use renderable;
use renderer_base;
use stdClass;
@@ -44,15 +45,22 @@ class unified_filter implements renderable, templatable {
/** @var array $selectedoptions The list of selected filter option values. */
protected $selectedoptions;
/** @var moodle_url|string $baseurl The url with params needed to call up this page. */
protected $baseurl;
/**
* unified_filter constructor.
*
* @param array $filteroptions The filter options.
* @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->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) {
global $PAGE;
$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) {
if (!isset($this->filteroptions[$option])) {
+6 -6
View File
@@ -212,18 +212,18 @@ foreach ($enrolbuttons as $enrolbutton) {
}
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.
$baseurl = new moodle_url('/user/index.php', array(
'contextid' => $context->id,
'id' => $course->id,
'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,
$searchkeywords, $bulkoperations, $selectall);
$participanttable->define_baseurl($baseurl);
+3 -2
View File
@@ -115,9 +115,10 @@ class core_user_renderer extends plugin_renderer_base {
* @param stdClass $course The course object.
* @param context $context The context object.
* @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
*/
public function unified_filter($course, $context, $filtersapplied) {
public function unified_filter($course, $context, $filtersapplied, $baseurl = null) {
global $CFG, $DB, $USER;
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.
$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);
return $this->output->render_from_template('core_user/unified_filter', $context);