Skip to content

Commit

Permalink
Merge branch 'v2.4-stable' into 2.4.10-release
Browse files Browse the repository at this point in the history
  • Loading branch information
jfederico committed Apr 24, 2024
2 parents 7d16099 + 023a3ed commit 8c7fb24
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 18 deletions.
25 changes: 23 additions & 2 deletions classes/locallib/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ public static function get_moodle_version_major() {
*/
public static function defaultvalues() {
return array(
'server_url' => (string) BIGBLUEBUTTONBN_DEFAULT_SERVER_URL,
'shared_secret' => (string) BIGBLUEBUTTONBN_DEFAULT_SHARED_SECRET,
'server_url' => '',
'shared_secret' => '',
'checksum_algorithm' => (string) BIGBLUEBUTTONBN_DEFAULT_CHECKSUM_ALGORITHM,
'voicebridge_editable' => false,
'importrecordings_enabled' => false,
Expand Down Expand Up @@ -179,6 +179,27 @@ public static function clienttype_enabled() {
return (boolean)self::get('clienttype_enabled');
}

/**
* Check if bbb server credentials are invalid.
*
* @return bool
*/
public static function server_credentials_invalid(): bool {
// Test server credentials across all versions of the plugin are flagged.
$parsedurl = parse_url(self::get('server_url'));
$defaultserverurl = parse_url(BIGBLUEBUTTONBN_DEFAULT_SERVER_URL);
if (!isset($parsedurl['host'])) {
return false;
}
if (strpos($parsedurl['host'], $defaultserverurl['host']) === 0) {
return true;
}
if (strpos($parsedurl['host'], 'test-moodle.blindsidenetworks.com') === 0) {
return true;
}
return false;
}

/**
* Wraps current settings in an array.
*
Expand Down
6 changes: 3 additions & 3 deletions classes/settings/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@ public function render_group_element_password($name, $default = null, $type = PA
* @return Object
*/
public function render_warning_message($name, $message, $type = 'warning', $closable = true) {
$output = $this->output->box_start('box boxalignleft adminerror alert alert-' . $type . ' alert-block fade in',
'bigbluebuttonbn_' . $name)."\n";
$output = '<div class="box boxalignleft adminerror alert alert-' . $type . ' alert-block fade in" id=
"bigbluebuttonbn_' . $name . '">';
if ($closable) {
$output .= ' <button type="button" class="close" data-dismiss="alert">&times;</button>' . "\n";
}
$output .= ' ' . $message . "\n";
$output .= $this->output->box_end() . "\n";
$output .= '</div>';
$item = new \admin_setting_heading('bigbluebuttonbn_' . $name, '', $output);
$this->settings->add($item);
return $item;
Expand Down
4 changes: 2 additions & 2 deletions config-dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
* checksum_algorithm can be set to SHA1 (default), SHA256, SHA384 and SHA512.
**/

$CFG->bigbluebuttonbn['server_url'] = 'http://test-install.blindsidenetworks.com/bigbluebutton/';
$CFG->bigbluebuttonbn['shared_secret'] = '8cd8ef52e8e101574e400365b55e11a6';
$CFG->bigbluebuttonbn['server_url'] = '';
$CFG->bigbluebuttonbn['shared_secret'] = '';
$CFG->bigbluebuttonbn['checksum_algorithm'] = 'SHA1';

/*
Expand Down
10 changes: 6 additions & 4 deletions lang/en/bigbluebuttonbn.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@
$string['minutes'] = 'minutes';

$string['config_general'] = 'General configuration';
$string['config_general_description'] = 'These settings are <b>always</b> used';
$string['config_general_description'] = '<p>These settings are always used.</p><p>To use BigBlueButton, you can setup your own BigBlueButton server and enter the credentials below, or visit the <a href="https://registration-portal.blindsidenetworks.com/" target="_blank">Blindside Networks Registration Portal (opens in a new window)</a> to obtain free trial credentials</p>';
$string['config_server_url'] = 'BigBlueButton Server URL';
$string['config_server_url_description'] = 'The URL of your BigBlueButton server must end with /bigbluebutton/. (This default URL is for a BigBlueButton server provided by Blindside Networks that you can use for testing.)';
$string['config_server_url_description'] = 'The URL of your BigBlueButton server must end with /bigbluebutton/';
$string['config_shared_secret'] = 'BigBlueButton Shared Secret';
$string['config_shared_secret_description'] = 'The security salt of your BigBlueButton server. (This default salt is for a BigBlueButton server provided by Blindside Networks that you can use for testing.)';
$string['config_shared_secret_description'] = 'The security salt of your BigBlueButton server.';
$string['config_checksum_algorithm'] = 'BigBlueButton Checksum Algorithm';
$string['config_checksum_algorithm_description'] = 'The checksum algorithm of your BigBlueButton server. (SHA1 guarantees compatability with older server versions but is less secure whereas SHA512 is FIPS 140-2 compliant.)';

Expand Down Expand Up @@ -539,7 +539,9 @@
$string['view_error_meeting_not_running'] = 'Something went wrong, the meeting is not running.';
$string['view_error_current_state_not_found'] = 'Current state was not found. The recording may have been deleted or the BigBlueButton server is not compatible with the action performed.';
$string['view_error_action_not_completed'] = 'Action could not be completed';
$string['view_warning_default_server'] = 'This Moodle server is making use of the BigBlueButton testing server that comes pre-configured by default. It should be replaced for production.';
$string['view_warning_default_server'] = 'Default BigBlueButton plugin credentials will soon expire. See BigBlueButton<a href="{$a->settingslink}" target="_blank"> plugin settings (opens in a new window)</a> for more information.';
$string['view_warning_default_server_no_capability'] = 'The use of default server credentials will soon expire. To use BigBlueButton your site will require new server credentials. Please contact your site administrator for help with this.';
$string['credentials_warning'] = 'The use of default server credentials will soon expire (see note above to obtain new credentials).';

$string['view_room'] = 'View room';
$string['mod_form_block_clienttype'] = 'Web Client Technology';
Expand Down
7 changes: 5 additions & 2 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2685,13 +2685,16 @@ function bigbluebuttonbn_settings_general(&$renderer) {
// Configuration for BigBlueButton.
if ((boolean) \mod_bigbluebuttonbn\settings\validator::section_general_shown()) {
$renderer->render_group_header('general');
if ((boolean) \mod_bigbluebuttonbn\locallib\config::server_credentials_invalid()) {
$renderer->render_warning_message('credentials_warning', get_string('credentials_warning', 'bigbluebuttonbn'), 'danger');
}
$renderer->render_group_element(
'server_url',
$renderer->render_group_element_text('server_url', BIGBLUEBUTTONBN_DEFAULT_SERVER_URL)
$renderer->render_group_element_text('server_url', '')
);
$renderer->render_group_element(
'shared_secret',
$renderer->render_group_element_password('shared_secret', BIGBLUEBUTTONBN_DEFAULT_SHARED_SECRET)
$renderer->render_group_element_password('shared_secret', '')
);
$checksumchoices = array('SHA1' => 'SHA1', 'SHA256' => 'SHA256', 'SHA512' => 'SHA512');
$renderer->render_group_element(
Expand Down
3 changes: 3 additions & 0 deletions tests/behat/behat_mod_bigbluebuttonbn.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ public function before_scenario(BeforeScenarioScope $scope) {
if (defined('TEST_MOD_BIGBLUEBUTTONBN_MOCK_SERVER')) {
$this->send_mock_request('backoffice/reset');
}
// Fields are empty by default which causes tests to fail.
set_config('bigbluebuttonbn_server_url', 'http://test-install.blindsidenetworks.com/bigbluebutton/');
set_config('bigbluebuttonbn_shared_secret', '8cd8ef52e8e101574e400365b55e11a6');
}

/**
Expand Down
3 changes: 3 additions & 0 deletions tests/lib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ public function setUp(): void {
global $CFG;
parent::setUp();
set_config('enablecompletion', true); // Enable completion for all tests.
// Fields are empty by default which causes tests to fail.
set_config('bigbluebuttonbn_server_url', BIGBLUEBUTTONBN_DEFAULT_SERVER_URL);
set_config('bigbluebuttonbn_shared_secret', BIGBLUEBUTTONBN_DEFAULT_SHARED_SECRET);
$this->generator = $this->getDataGenerator();
$this->course = $this->generator->create_course(['enablecompletion' => 1]);
}
Expand Down
19 changes: 14 additions & 5 deletions viewlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,29 @@ function bigbluebuttonbn_view_ended(&$bbbsession) {
}

/**
* Renders a default server warning message when using test-install.
* Renders a default server warning message when using test-install or test-moodle.
*
* @param array $bbbsession
*
* @return string
*/
function bigbluebuttonbn_view_warning_default_server(&$bbbsession) {
if (!is_siteadmin($bbbsession['userID'])) {
return '';
if (\mod_bigbluebuttonbn\locallib\config::server_credentials_invalid()) {
$context = context_module::instance($bbbsession['cm']->id);
// Admin and teacher should see warning.
if (is_siteadmin($bbbsession['userID'])) {
$settingslink = new moodle_url('/admin/settings.php', ['section' => 'modsettingbigbluebuttonbn']);
return bigbluebuttonbn_render_warning(get_string('view_warning_default_server', 'bigbluebuttonbn',
['settingslink' => $settingslink->out()]), 'danger');
} else if (has_capability('moodle/course:manageactivities', $context, $bbbsession['userID'])) {
return bigbluebuttonbn_render_warning(get_string('view_warning_default_server_no_capability', 'bigbluebuttonbn'),
'danger');
}
}
if (BIGBLUEBUTTONBN_DEFAULT_SERVER_URL != \mod_bigbluebuttonbn\locallib\config::get('server_url')) {
if (!bigbluebuttonbn_view_warning_shown($bbbsession)) {
return '';
}
return bigbluebuttonbn_render_warning(get_string('view_warning_default_server', 'bigbluebuttonbn'), 'warning');
return '';
}

/**
Expand Down

0 comments on commit 8c7fb24

Please sign in to comment.