Merge branch 'MDL-79586-master' of https://github.com/safatshahin/moodle

This commit is contained in:
Ilya Tregubov 2023-10-06 10:25:39 +08:00
commit 2b4041f93c
No known key found for this signature in database
GPG key ID: 0F58186F748E55C1
3 changed files with 6 additions and 25 deletions

View file

@ -178,7 +178,10 @@ class api {
$selection[processor::PROVIDER_NONE] = get_string('nocommunicationselected', 'communication'); $selection[processor::PROVIDER_NONE] = get_string('nocommunicationselected', 'communication');
$communicationplugins = \core\plugininfo\communication::get_enabled_plugins(); $communicationplugins = \core\plugininfo\communication::get_enabled_plugins();
foreach ($communicationplugins as $pluginname => $notusing) { foreach ($communicationplugins as $pluginname => $notusing) {
$selection['communication_' . $pluginname] = get_string('pluginname', 'communication_' . $pluginname); $provider = 'communication_' . $pluginname;
if (processor::is_provider_available($provider)) {
$selection[$provider] = get_string('pluginname', 'communication_' . $pluginname);
}
} }
return $selection; return $selection;
} }

View file

@ -43,17 +43,6 @@ class api_test extends \advanced_testcase {
$this->initialise_mock_server(); $this->initialise_mock_server();
} }
/**
* Test the communication plugin list for the form element returns the correct number of plugins.
*/
public function test_get_communication_plugin_list_for_form(): void {
$communicationplugins = \core_communication\api::get_communication_plugin_list_for_form();
// Get the communication plugins.
$plugins = \core_component::get_plugin_list('communication');
// Check the number of plugins matches plus 1 as we have none in the selection.
$this->assertCount(count($plugins) + 1, $communicationplugins);
}
/** /**
* Test set data to the instance. * Test set data to the instance.
*/ */
@ -296,18 +285,6 @@ class api_test extends \advanced_testcase {
$this->assertCount(1, $adhoctask); $this->assertCount(1, $adhoctask);
} }
/**
* Test the enabled communication plugin list and default.
*/
public function test_get_enabled_providers_and_default(): void {
[$communicationproviders, $defaulprovider] = \core_communication\api::get_enabled_providers_and_default();
// Get the communication plugins.
$plugins = \core_component::get_plugin_list('communication');
// Check the number of plugins matches plus 1 as we have none in the selection.
$this->assertCount(count($plugins) + 1, $communicationproviders);
$this->assertEquals(processor::PROVIDER_NONE, $defaulprovider);
}
/** /**
* Test the update of room membership with the change user role. * Test the update of room membership with the change user role.
* *

View file

@ -78,7 +78,8 @@ class communication extends base {
// Filter to return only enabled plugins. // Filter to return only enabled plugins.
$enabled = []; $enabled = [];
foreach ($plugins as $plugin) { foreach ($plugins as $plugin) {
if (processor::is_provider_available('communication_' . $plugin)) { $disabled = get_config('communication_' . $plugin, 'disabled');
if (empty($disabled)) {
$enabled[$plugin] = $plugin; $enabled[$plugin] = $plugin;
} }
} }