Skip to content

Commit

Permalink
CONTRIB-9484: Default server warning message
Browse files Browse the repository at this point in the history
  • Loading branch information
ssj365 committed Feb 6, 2024
1 parent 3befec5 commit 37887a8
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 10 deletions.
10 changes: 10 additions & 0 deletions classes/locallib/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,16 @@ 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 {
return (self::get('server_url') == BIGBLUEBUTTONBN_DEFAULT_SERVER_URL ||
self::get('server_url') == 'https://test-moodle.blindsidenetworks.com/bigbluebutton/');
}

/**
* Wraps current settings in an array.
*
Expand Down
5 changes: 3 additions & 2 deletions classes/settings/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,14 @@ 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',
global $OUTPUT;
$output = $OUTPUT->box_start('box boxalignleft adminerror alert alert-' . $type . ' alert-block fade in',
'bigbluebuttonbn_' . $name)."\n";
if ($closable) {
$output .= ' <button type="button" class="close" data-dismiss="alert">&times;</button>' . "\n";
}
$output .= ' ' . $message . "\n";
$output .= $this->output->box_end() . "\n";
$output .= $OUTPUT->box_end() . "\n";
$item = new \admin_setting_heading('bigbluebuttonbn_' . $name, '', $output);
$this->settings->add($item);
return $item;
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 Tier 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 BigBlueButtonBN plugin credentials will soon be invalid. To continue using this plugin, please register through the <a href="https://registration-portal.blindsidenetworks.com/" target="_blank">Blindside Networks Registration Portal (opens in a new window)</a> or use your own configured server.';
$string['view_warning_default_server_no_capability'] = 'To use BigBlueButton, your site will soon require new server credentials. Please contact your site administrator for help with this.';
$string['credentials_warning'] = 'The use of the default server credentials will soon be removed. Before using this plugin, you must enter a valid server URL and secret.';

$string['view_room'] = 'View room';
$string['mod_form_block_clienttype'] = 'Web Client Technology';
Expand Down
3 changes: 3 additions & 0 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2684,6 +2684,9 @@ 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)
Expand Down
13 changes: 9 additions & 4 deletions viewlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,25 @@ 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'])) {
if (!\mod_bigbluebuttonbn\locallib\config::server_credentials_invalid()) {
return '';
}
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');
// Admin should see warning with link to registration portal.
if (is_siteadmin($bbbsession['userID'])) {
return bigbluebuttonbn_render_warning(get_string('view_warning_default_server', 'bigbluebuttonbn'), 'danger');
}

return bigbluebuttonbn_render_warning(get_string('view_warning_default_server_no_capability', 'bigbluebuttonbn'), 'danger');
}

/**
Expand Down

0 comments on commit 37887a8

Please sign in to comment.