MDL-68868 core_user: Final deprecation of participants unified filter

This commit is contained in:
David Woloszyn 2022-10-04 16:09:35 +11:00
parent 24f97edd91
commit 7a9de2cb24
10 changed files with 7 additions and 591 deletions

View File

@ -1,11 +0,0 @@
/**
* Unified filter page JS module for the course participants page.
*
* @deprecated since Moodle 3.9 MDL-68612 - user unified filter replaced by participants filter.
* @module core_user/unified_filter
* @copyright 2017 Jun Pataleta
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_user/unified_filter",["jquery","core/form-autocomplete","core/str","core/notification"],(function($,Autocomplete,Str,Notification){var SELECTORS_UNIFIED_FILTERS="#unified-filters";return{init:function(){!function(){M.util.js_pending("unified_filter_datasource"),Str.get_strings([{key:"userfilterplaceholder",component:"moodle"},{key:"nofiltersapplied",component:"moodle"}]).done((function(langstrings){var placeholder=langstrings[0],noSelectionString=langstrings[1];Autocomplete.enhance(SELECTORS_UNIFIED_FILTERS,!0,"core_user/unified_filter_datasource",placeholder,!1,!0,noSelectionString,!0).then((function(){M.util.js_complete("unified_filter_datasource")})).fail(Notification.exception)})).fail(Notification.exception);var last=$(SELECTORS_UNIFIED_FILTERS).val();$(SELECTORS_UNIFIED_FILTERS).on("change",(function(){var current=$(this).val(),listoffilters=[],textfilters=[],updatedselectedfilters=!1;if($.each(current,(function(index,catoption){var catandoption=catoption.split(":",2);if(2!==catandoption.length)return textfilters.push(catoption),!0;var category=catandoption[0],option=catandoption[1];return void 0!==listoffilters[category]&&(updatedselectedfilters=!0),listoffilters[category]=option,!0})),updatedselectedfilters){var updatefilters=[];for(var category in listoffilters)updatefilters.push(category+":"+listoffilters[category]);updatefilters=updatefilters.concat(textfilters),$(this).val(updatefilters)}last.join(",")!=current.join(",")&&this.form.submit()}))}()},getForm:function(){return $(SELECTORS_UNIFIED_FILTERS).closest("form")}}}));
//# sourceMappingURL=unified_filter.min.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,12 +0,0 @@
/**
* Datasource for the core_user/unified_filter.
* @deprecated since Moodle 3.9 MDL-68612 - user unified filter replaced by participants filter.
*
* This module is compatible with core/form-autocomplete.
*
* @copyright 2017 Jun Pataleta
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define("core_user/unified_filter_datasource",["jquery","core/ajax","core/notification"],(function($,Ajax,Notification){return{list:function(selector,query){var filteredOptions=[],el=$(selector),originalOptions=$(selector).data("originaloptionsjson"),selectedFilters=el.val();$.each(originalOptions,(function(index,option){return""!==query.trim()&&-1===option.label.toLocaleLowerCase().indexOf(query.toLocaleLowerCase())||$.inArray(option.value,selectedFilters)>-1||filteredOptions.push(option),!0}));var deferred=new $.Deferred;return deferred.resolve(filteredOptions),deferred.promise()},processResults:function(selector,results){var options=[];return $.each(results,(function(index,data){options.push({value:data.value,label:data.label})})),options},transport:function(selector,query,callback){this.list(selector,query).then(callback).catch(Notification.exception)}}}));
//# sourceMappingURL=unified_filter_datasource.min.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"unified_filter_datasource.min.js","sources":["../src/unified_filter_datasource.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see <http://www.gnu.org/licenses/>.\n\n/**\n * Datasource for the core_user/unified_filter.\n * @deprecated since Moodle 3.9 MDL-68612 - user unified filter replaced by participants filter.\n *\n * This module is compatible with core/form-autocomplete.\n *\n * @copyright 2017 Jun Pataleta\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\ndefine(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notification) {\n\n return /** @alias module:core_user/unified_filter_datasource */ {\n /**\n * List filter options.\n *\n * @param {String} selector The select element selector.\n * @param {String} query The query string.\n * @return {Promise}\n */\n list: function(selector, query) {\n var filteredOptions = [];\n\n var el = $(selector);\n var originalOptions = $(selector).data('originaloptionsjson');\n var selectedFilters = el.val();\n $.each(originalOptions, function(index, option) {\n // Skip option if it does not contain the query string.\n if (query.trim() !== '' && option.label.toLocaleLowerCase().indexOf(query.toLocaleLowerCase()) === -1) {\n return true;\n }\n // Skip filters that have already been selected.\n if ($.inArray(option.value, selectedFilters) > -1) {\n return true;\n }\n\n filteredOptions.push(option);\n return true;\n });\n\n var deferred = new $.Deferred();\n deferred.resolve(filteredOptions);\n\n return deferred.promise();\n },\n\n /**\n * Process the results for auto complete elements.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {Array} results An array or results.\n * @return {Array} New array of results.\n */\n processResults: function(selector, results) {\n var options = [];\n $.each(results, function(index, data) {\n options.push({\n value: data.value,\n label: data.label\n });\n });\n return options;\n },\n\n /**\n * Source of data for Ajax element.\n *\n * @param {String} selector The selector of the auto complete element.\n * @param {String} query The query string.\n * @param {Function} callback A callback function receiving an array of results.\n */\n /* eslint-disable promise/no-callback-in-promise */\n transport: function(selector, query, callback) {\n this.list(selector, query).then(callback).catch(Notification.exception);\n }\n };\n\n});\n"],"names":["define","$","Ajax","Notification","list","selector","query","filteredOptions","el","originalOptions","data","selectedFilters","val","each","index","option","trim","label","toLocaleLowerCase","indexOf","inArray","value","push","deferred","Deferred","resolve","promise","processResults","results","options","transport","callback","then","catch","exception"],"mappings":";;;;;;;;;AAyBAA,6CAAO,CAAC,SAAU,YAAa,sBAAsB,SAASC,EAAGC,KAAMC,oBAEH,CAQ5DC,KAAM,SAASC,SAAUC,WACjBC,gBAAkB,GAElBC,GAAKP,EAAEI,UACPI,gBAAkBR,EAAEI,UAAUK,KAAK,uBACnCC,gBAAkBH,GAAGI,MACzBX,EAAEY,KAAKJ,iBAAiB,SAASK,MAAOC,cAEf,KAAjBT,MAAMU,SAA0F,IAAzED,OAAOE,MAAMC,oBAAoBC,QAAQb,MAAMY,sBAItEjB,EAAEmB,QAAQL,OAAOM,MAAOV,kBAAoB,GAIhDJ,gBAAgBe,KAAKP,SAPV,SAWXQ,SAAW,IAAItB,EAAEuB,gBACrBD,SAASE,QAAQlB,iBAEVgB,SAASG,WAUpBC,eAAgB,SAAStB,SAAUuB,aAC3BC,QAAU,UACd5B,EAAEY,KAAKe,SAAS,SAASd,MAAOJ,MAC5BmB,QAAQP,KAAK,CACTD,MAAOX,KAAKW,MACZJ,MAAOP,KAAKO,WAGbY,SAWXC,UAAW,SAASzB,SAAUC,MAAOyB,eAC5B3B,KAAKC,SAAUC,OAAO0B,KAAKD,UAAUE,MAAM9B,aAAa+B"}

View File

@ -1,149 +0,0 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Unified filter page JS module for the course participants page.
*
* @deprecated since Moodle 3.9 MDL-68612 - user unified filter replaced by participants filter.
* @module core_user/unified_filter
* @copyright 2017 Jun Pataleta
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define(['jquery', 'core/form-autocomplete', 'core/str', 'core/notification'],
function($, Autocomplete, Str, Notification) {
/**
* Selectors.
*
* @access private
* @type {{UNIFIED_FILTERS: string}}
*/
var SELECTORS = {
UNIFIED_FILTERS: '#unified-filters'
};
/**
* Init function.
*
* @deprecated since Moodle 3.9 MDL-68612 - user unified filter replaced by participants filter.
* @method init
* @private
*/
var init = function() {
var stringkeys = [
{
key: 'userfilterplaceholder',
component: 'moodle'
},
{
key: 'nofiltersapplied',
component: 'moodle'
}
];
M.util.js_pending('unified_filter_datasource');
Str.get_strings(stringkeys).done(function(langstrings) {
var placeholder = langstrings[0];
var noSelectionString = langstrings[1];
Autocomplete.enhance(SELECTORS.UNIFIED_FILTERS, true, 'core_user/unified_filter_datasource', placeholder,
false, true, noSelectionString, true)
.then(function() {
M.util.js_complete('unified_filter_datasource');
return;
})
.fail(Notification.exception);
}).fail(Notification.exception);
var last = $(SELECTORS.UNIFIED_FILTERS).val();
$(SELECTORS.UNIFIED_FILTERS).on('change', function() {
var current = $(this).val();
var listoffilters = [];
var textfilters = [];
var updatedselectedfilters = false;
$.each(current, function(index, catoption) {
var catandoption = catoption.split(':', 2);
if (catandoption.length !== 2) {
textfilters.push(catoption);
return true; // Text search filter.
}
var category = catandoption[0];
var option = catandoption[1];
// The last option (eg. 'Teacher') out of a category (eg. 'Role') in this loop is the one that was last
// selected, so we want to use that if there are multiple options from the same category. Eg. The user
// may have chosen to filter by the 'Student' role, then wanted to filter by the 'Teacher' role - the
// last option in the category to be selected (in this case 'Teacher') will come last, so will overwrite
// 'Student' (after this if). We want to let the JS know that the filters have been updated.
if (typeof listoffilters[category] !== 'undefined') {
updatedselectedfilters = true;
}
listoffilters[category] = option;
return true;
});
// Check if we have something to remove from the list of filters.
if (updatedselectedfilters) {
// Go through and put the list into something we can use to update the list of filters.
var updatefilters = [];
for (var category in listoffilters) {
updatefilters.push(category + ":" + listoffilters[category]);
}
updatefilters = updatefilters.concat(textfilters);
$(this).val(updatefilters);
}
// Prevent form from submitting unnecessarily, eg. on blur when no filter is selected.
if (last.join(',') != current.join(',')) {
this.form.submit();
}
});
};
/**
* Return the unified user filter form.
*
* @deprecated since Moodle 3.9 MDL-68612 - user unified filter replaced by participants filter.
* @method getForm
* @return {DOMElement}
*/
var getForm = function() {
return $(SELECTORS.UNIFIED_FILTERS).closest('form');
};
return /** @alias module:core/form-autocomplete */ {
/**
* Initialise the unified user filter.
*
* @method init
*/
init: function() {
init();
},
/**
* Return the unified user filter form.
*
* @method getForm
* @return {DOMElement}
*/
getForm: function() {
return getForm();
}
};
});

View File

@ -1,93 +0,0 @@
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Datasource for the core_user/unified_filter.
* @deprecated since Moodle 3.9 MDL-68612 - user unified filter replaced by participants filter.
*
* This module is compatible with core/form-autocomplete.
*
* @copyright 2017 Jun Pataleta
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define(['jquery', 'core/ajax', 'core/notification'], function($, Ajax, Notification) {
return /** @alias module:core_user/unified_filter_datasource */ {
/**
* List filter options.
*
* @param {String} selector The select element selector.
* @param {String} query The query string.
* @return {Promise}
*/
list: function(selector, query) {
var filteredOptions = [];
var el = $(selector);
var originalOptions = $(selector).data('originaloptionsjson');
var selectedFilters = el.val();
$.each(originalOptions, function(index, option) {
// Skip option if it does not contain the query string.
if (query.trim() !== '' && option.label.toLocaleLowerCase().indexOf(query.toLocaleLowerCase()) === -1) {
return true;
}
// Skip filters that have already been selected.
if ($.inArray(option.value, selectedFilters) > -1) {
return true;
}
filteredOptions.push(option);
return true;
});
var deferred = new $.Deferred();
deferred.resolve(filteredOptions);
return deferred.promise();
},
/**
* Process the results for auto complete elements.
*
* @param {String} selector The selector of the auto complete element.
* @param {Array} results An array or results.
* @return {Array} New array of results.
*/
processResults: function(selector, results) {
var options = [];
$.each(results, function(index, data) {
options.push({
value: data.value,
label: data.label
});
});
return options;
},
/**
* Source of data for Ajax element.
*
* @param {String} selector The selector of the auto complete element.
* @param {String} query The query string.
* @param {Function} callback A callback function receiving an array of results.
*/
/* eslint-disable promise/no-callback-in-promise */
transport: function(selector, query, callback) {
this.list(selector, query).then(callback).catch(Notification.exception);
}
};
});

View File

@ -1,108 +0,0 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Class containing the filter options data for rendering the unified filter autocomplete element for the course participants page.
*
* @deprecated since Moodle 3.9 MDL-68612 - Please use \core_user\table\participants_search::class and table filtersets instead.
* @package core_user
* @copyright 2017 Jun Pataleta
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_user\output;
use moodle_url;
use renderable;
use renderer_base;
use stdClass;
use templatable;
defined('MOODLE_INTERNAL') || die();
/**
* Class containing the filter options data for rendering the unified filter autocomplete element for the course participants page.
*
* @deprecated since Moodle 3.9 MDL-68612 - Please use \core_user\table\participants_search::class and table filtersets instead.
* @copyright 2017 Jun Pataleta
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*
*/
class unified_filter implements renderable, templatable {
/** @var array $filteroptions The filter options. */
protected $filteroptions;
/** @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, $baseurl = null) {
$deprecatedtext = __CLASS__ . ' class is deprecated. Please use \core\table\participants_search::class' .
' with table filtersets instead.';
debugging($deprecatedtext, DEBUG_DEVELOPER);
$this->filteroptions = $filteroptions;
$this->selectedoptions = $selectedoptions;
if (!empty($baseurl)) {
$this->baseurl = new moodle_url($baseurl);
}
}
/**
* Function to export the renderer data in a format that is suitable for a mustache template.
*
* @param renderer_base $output Used to do a final render of any components that need to be rendered for export.
* @return stdClass|array
*/
public function export_for_template(renderer_base $output) {
global $PAGE;
$data = new stdClass();
if (empty($this->baseurl)) {
$this->baseurl = $PAGE->url;
}
$data->action = $this->baseurl->out(false);
foreach ($this->selectedoptions as $option) {
if (!isset($this->filteroptions[$option])) {
$this->filteroptions[$option] = $option;
}
}
$data->filteroptions = [];
$originalfilteroptions = [];
foreach ($this->filteroptions as $value => $label) {
$selected = in_array($value, $this->selectedoptions);
$filteroption = (object)[
'value' => $value,
'label' => $label
];
$originalfilteroptions[] = $filteroption;
$filteroption->selected = $selected;
$data->filteroptions[] = $filteroption;
}
$data->originaloptionsjson = json_encode($originalfilteroptions);
return $data;
}
}

View File

@ -110,156 +110,12 @@ class core_user_renderer extends plugin_renderer_base {
/**
* Renders the unified filter element for the course participants page.
* @deprecated since Moodle 3.9 MDL-68612 - Please use participants_filter() instead.
*
* @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
* @deprecated since 3.9
* @throws coding_exception
*/
public function unified_filter($course, $context, $filtersapplied, $baseurl = null) {
global $CFG, $DB, $USER;
public function unified_filter() {
throw new coding_exception('unified_filter cannot be used any more, please use participants_filter instead');
debugging('core_user_renderer->unified_filter() is deprecated. Please use participants_filter() instead.', DEBUG_DEVELOPER);
require_once($CFG->dirroot . '/enrol/locallib.php');
require_once($CFG->dirroot . '/lib/grouplib.php');
$manager = new course_enrolment_manager($this->page, $course);
$filteroptions = [];
// Filter options for role.
$roleseditable = has_capability('moodle/role:assign', $context);
$roles = get_viewable_roles($context);
if ($roleseditable) {
$roles += get_assignable_roles($context, ROLENAME_ALIAS);
}
$criteria = get_string('role');
$roleoptions = $this->format_filter_option(USER_FILTER_ROLE, $criteria, -1, get_string('noroles', 'role'));
foreach ($roles as $id => $role) {
$roleoptions += $this->format_filter_option(USER_FILTER_ROLE, $criteria, $id, $role);
}
$filteroptions += $roleoptions;
// Filter options for groups, if available.
if (has_capability('moodle/site:accessallgroups', $context) || $course->groupmode != SEPARATEGROUPS) {
// List all groups if the user can access all groups, or we are in visible group mode or no groups mode.
$groups = $manager->get_all_groups();
if (!empty($groups)) {
// Add 'No group' option, to enable filtering users without any group.
$nogroup[USERSWITHOUTGROUP] = (object)['name' => get_string('nogroup', 'group')];
$groups = $nogroup + $groups;
}
} else {
// Otherwise, just list the groups the user belongs to.
$groups = groups_get_all_groups($course->id, $USER->id);
}
$criteria = get_string('group');
$groupoptions = [];
foreach ($groups as $id => $group) {
$groupoptions += $this->format_filter_option(USER_FILTER_GROUP, $criteria, $id, $group->name);
}
$filteroptions += $groupoptions;
$canreviewenrol = has_capability('moodle/course:enrolreview', $context);
// Filter options for status.
if ($canreviewenrol) {
$criteria = get_string('status');
// Add statuses.
$filteroptions += $this->format_filter_option(USER_FILTER_STATUS, $criteria, ENROL_USER_ACTIVE, get_string('active'));
$filteroptions += $this->format_filter_option(USER_FILTER_STATUS, $criteria, ENROL_USER_SUSPENDED,
get_string('inactive'));
}
// Filter options for enrolment methods.
if ($canreviewenrol && $enrolmentmethods = $manager->get_enrolment_instance_names(true)) {
$criteria = get_string('enrolmentinstances', 'enrol');
$enroloptions = [];
foreach ($enrolmentmethods as $id => $enrolname) {
$enroloptions += $this->format_filter_option(USER_FILTER_ENROLMENT, $criteria, $id, $enrolname);
}
$filteroptions += $enroloptions;
}
$isfrontpage = ($course->id == SITEID);
// Get the list of fields we have to hide.
$hiddenfields = array();
if (!has_capability('moodle/course:viewhiddenuserfields', $context)) {
$hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
}
$haslastaccess = !isset($hiddenfields['lastaccess']);
// Filter options for last access.
if ($haslastaccess) {
// Get minimum lastaccess for this course and display a dropbox to filter by lastaccess going back this far.
// We need to make it diferently for normal courses and site course.
if (!$isfrontpage) {
$params = ['courseid' => $course->id, 'timeaccess' => 0];
$select = 'courseid = :courseid AND timeaccess != :timeaccess';
$minlastaccess = $DB->get_field_select('user_lastaccess', 'MIN(timeaccess)', $select, $params);
$lastaccess0exists = $DB->record_exists('user_lastaccess', $params);
} else {
$params = ['lastaccess' => 0];
$select = 'lastaccess != :lastaccess';
$minlastaccess = $DB->get_field_select('user', 'MIN(lastaccess)', $select, $params);
$lastaccess0exists = $DB->record_exists('user', $params);
}
$now = usergetmidnight(time());
$timeoptions = [];
$criteria = get_string('usersnoaccesssince');
// Days.
for ($i = 1; $i < 7; $i++) {
$timestamp = strtotime('-' . $i . ' days', $now);
if ($timestamp < $minlastaccess) {
break;
}
$value = get_string('numdays', 'moodle', $i);
$timeoptions += $this->format_filter_option(USER_FILTER_LAST_ACCESS, $criteria, $timestamp, $value);
}
// Weeks.
for ($i = 1; $i < 10; $i++) {
$timestamp = strtotime('-'.$i.' weeks', $now);
if ($timestamp < $minlastaccess) {
break;
}
$value = get_string('numweeks', 'moodle', $i);
$timeoptions += $this->format_filter_option(USER_FILTER_LAST_ACCESS, $criteria, $timestamp, $value);
}
// Months.
for ($i = 2; $i < 12; $i++) {
$timestamp = strtotime('-'.$i.' months', $now);
if ($timestamp < $minlastaccess) {
break;
}
$value = get_string('nummonths', 'moodle', $i);
$timeoptions += $this->format_filter_option(USER_FILTER_LAST_ACCESS, $criteria, $timestamp, $value);
}
// Try a year.
$timestamp = strtotime('-1 year', $now);
if ($timestamp >= $minlastaccess) {
$value = get_string('numyear', 'moodle', 1);
$timeoptions += $this->format_filter_option(USER_FILTER_LAST_ACCESS, $criteria, $timestamp, $value);
}
if (!empty($lastaccess0exists)) {
$value = get_string('never', 'moodle');
$timeoptions += $this->format_filter_option(USER_FILTER_LAST_ACCESS, $criteria, $timestamp, $value);
}
if (count($timeoptions) > 1) {
$filteroptions += $timeoptions;
}
}
// 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, $baseurl);
$context = $indexpage->export_for_template($this->output);
return $this->output->render_from_template('core_user/unified_filter', $context);
}
/**

View File

@ -1,68 +0,0 @@
{{!
This file is part of Moodle - http://moodle.org/
Moodle is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Moodle is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Moodle. If not, see <http://www.gnu.org/licenses/>.
}}
{{!
@template core_user/unified_filter
@deprecated since Moodle 3.9 MDL-68612 - please use core_user/participantsfilter instead.
Template for the unified filter element.
Context variables required for this template:
* action string - The action URL for the form.
* filteroptions - Array of filter options.
* value string - The option value.
* label string - The option label.
* selected boolean - Whether the option is selected
Example context (json):
{
"action": "/user/index.php",
"filteroptions": [
{
"value": "1",
"label": "Option 1"
},
{
"value": "2",
"label": "Option 2",
"selected": true
},
{
"value": "3",
"label": "Option 3",
"selected": true
},
{
"value": "4",
"label": "Option 4"
}
]
}
}}
<form method="post" action="{{action}}" class="mb-1" role="search">
<label for="unified-filters" class="sr-only">{{#str}}filters{{/str}}</label>
<select name="unified-filters[]" id="unified-filters" multiple="multiple" data-originaloptionsjson="{{originaloptionsjson}}" class="form-autocomplete-original-select">
{{#filteroptions}}
<option value="{{value}}" {{#selected}}selected="selected"{{/selected}}>{{{label}}}</option>
{{/filteroptions}}
</select>
<input type="hidden" name="unified-filter-submitted" value="1">
</form>
{{#js}}
require(['core_user/unified_filter'], function(Filter) {
Filter.init();
});
{{/js}}

View File

@ -26,6 +26,9 @@ This files describes API changes for code that uses the user API.
* user/templates/local/participantsfilter/autocomplete_selection_items.mustache → lib/templates/datafilter/autocomplete_selection_items.mustache
Class participant_filter now extends core filter api in core user.
* The unified_filter function has been finally deprecated and cannot be used anymore
* The class \core_user\output\unified_filter has been finally deprecated and removed
=== 4.0 ===
* External function core_user_external::update_users() will now fail on a per user basis. Previously if one user