MDL-74453 reportbuilder: Add authentication method filter

- Add authentication method filter to the user entity
This commit is contained in:
David Matamoros
2022-06-03 08:40:06 +02:00
parent 5500d143f4
commit 669e71b956
@@ -21,6 +21,7 @@ namespace core_reportbuilder\local\entities;
use context_helper;
use context_system;
use context_user;
use core_component;
use html_writer;
use lang_string;
use moodle_url;
@@ -470,6 +471,31 @@ class user extends base {
))
->add_joins($this->get_joins());
// Authentication method filter.
$filters[] = (new filter(
select::class,
'auth',
new lang_string('authentication', 'moodle'),
$this->get_entity_name(),
"{$tablealias}.auth"
))
->set_options_callback(static function(): array {
$plugins = core_component::get_plugin_list('auth');
$enabled = get_string('pluginenabled', 'core_plugin');
$disabled = get_string('plugindisabled', 'core_plugin');
$authoptions = [$enabled => [], $disabled => []];
foreach ($plugins as $pluginname => $unused) {
$plugin = get_auth_plugin($pluginname);
if (is_enabled_auth($pluginname)) {
$authoptions[$enabled][$pluginname] = $plugin->get_title();
} else {
$authoptions[$disabled][$pluginname] = $plugin->get_title();
}
}
return $authoptions;
});
return $filters;
}