From 669e71b95652c504aff9c6a5361cf274a483eb72 Mon Sep 17 00:00:00 2001 From: David Matamoros Date: Thu, 7 Apr 2022 14:20:28 +0200 Subject: [PATCH] MDL-74453 reportbuilder: Add authentication method filter - Add authentication method filter to the user entity --- reportbuilder/classes/local/entities/user.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/reportbuilder/classes/local/entities/user.php b/reportbuilder/classes/local/entities/user.php index 5337efd725b..201887185d7 100644 --- a/reportbuilder/classes/local/entities/user.php +++ b/reportbuilder/classes/local/entities/user.php @@ -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; }