Merge branch 'MDL-78523-master' of https://github.com/safatshahin/moodle
This commit is contained in:
@@ -51,9 +51,6 @@ class processor {
|
||||
private stdClass $instancedata,
|
||||
) {
|
||||
$providercomponent = $this->instancedata->provider;
|
||||
if (!\core\plugininfo\communication::is_plugin_enabled($providercomponent)) {
|
||||
throw new \moodle_exception('communicationproviderdisabled', 'core_communication', '', $providercomponent);
|
||||
}
|
||||
$providerclass = $this->get_classname_for_provider($providercomponent);
|
||||
if (!class_exists($providerclass)) {
|
||||
throw new \moodle_exception('communicationproviderclassnotfound', 'core_communication', '', $providerclass);
|
||||
@@ -329,8 +326,8 @@ class processor {
|
||||
*/
|
||||
public static function load_by_id(int $id): ?self {
|
||||
global $DB;
|
||||
|
||||
if ($record = $DB->get_record('communication', ['id' => $id])) {
|
||||
$record = $DB->get_record('communication', ['id' => $id]);
|
||||
if ($record && self::is_provider_enabled($record->provider)) {
|
||||
return new self($record);
|
||||
}
|
||||
|
||||
@@ -359,7 +356,7 @@ class processor {
|
||||
'instancetype' => $instancetype,
|
||||
]);
|
||||
|
||||
if ($record) {
|
||||
if ($record && self::is_provider_enabled($record->provider)) {
|
||||
return new self($record);
|
||||
}
|
||||
|
||||
@@ -600,4 +597,14 @@ class processor {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is communication provider enabled/disabled.
|
||||
*
|
||||
* @param string $provider provider component name
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_provider_enabled(string $provider): bool {
|
||||
return \core\plugininfo\communication::is_plugin_enabled($provider);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,3 +34,19 @@ Feature: Display communication room status banner
|
||||
# Not for students to see.
|
||||
When I am on the "Test course" "Course" page logged in as "student1"
|
||||
Then I should not see "Your Matrix room is ready!" in the "page-content" "region"
|
||||
|
||||
Scenario: Enabling or disabling the matrix plugin hides the banner accordingly
|
||||
Given I am on the "Test course" "Course" page logged in as "teacher1"
|
||||
Then I should see "Your Matrix room will be ready soon." in the "page-content" "region"
|
||||
When I log in as "admin"
|
||||
And I navigate to "Plugins > Communication > Manage communication providers" in site administration
|
||||
And I should see "Matrix"
|
||||
And I click on "Disable" "link" in the "Matrix" "table_row"
|
||||
And I am on the "Test course" "Course" page logged in as "teacher1"
|
||||
And I should not see "Your Matrix room will be ready soon." in the "page-content" "region"
|
||||
And I log in as "admin"
|
||||
And I navigate to "Plugins > Communication > Manage communication providers" in site administration
|
||||
And I should see "Matrix"
|
||||
And I click on "Enable" "link" in the "Matrix" "table_row"
|
||||
And I am on the "Test course" "Course" page logged in as "teacher1"
|
||||
Then I should see "Your Matrix room will be ready soon." in the "page-content" "region"
|
||||
|
||||
@@ -395,4 +395,19 @@ class processor_test extends \advanced_testcase {
|
||||
$this->assertEquals($avatar->get_filepath(), '/');
|
||||
$this->assertEquals($avatar->get_filearea(), 'avatar');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the provider is enabled or disabled.
|
||||
*
|
||||
* @covers ::is_provider_enabled
|
||||
*/
|
||||
public function test_is_provider_enabled(): void {
|
||||
$this->resetAfterTest();
|
||||
$communicationprovider = 'communication_matrix';
|
||||
$this->assertTrue(processor::is_provider_enabled($communicationprovider));
|
||||
|
||||
// Now test is disabling the plugin returns false.
|
||||
set_config('disabled', 1, $communicationprovider);
|
||||
$this->assertFalse(processor::is_provider_enabled($communicationprovider));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user