diff --git a/lang/en/board.php b/lang/en/board.php index bf4fdef..2b5f2b6 100755 --- a/lang/en/board.php +++ b/lang/en/board.php @@ -125,6 +125,8 @@ $string['embed_width_desc'] = 'Width to use for the iframe when embedding the board within the course. This should be a valid CSS value, e.g. px, rem, %, etc...'; $string['embed_height'] = 'Embed height'; $string['embed_height_desc'] = 'Height to use for the iframe when embedding the board within the course. This should be a valid CSS value, e.g. px, rem, %, etc...'; +$string['embed_allowed'] = 'Allow board embedding'; +$string['embed_allowed_desc'] = 'If activated, the board embedding feature is available in the activity settings.'; $string['acceptedfiletypeforbackground'] = 'Accepted filetypes for background images.'; $string['acceptedfiletypeforbackground_desc'] = 'Select the filetypes for background images to be supported.'; diff --git a/lib.php b/lib.php index d2b3088..9683a54 100755 --- a/lib.php +++ b/lib.php @@ -479,8 +479,11 @@ function board_cm_info_dynamic(cm_info $cm) { // Look up the board based on the course module. $board = board::get_board($cm->instance); + // Check if embedding feature is allowed. + $embedallowed = get_config('mod_board', 'embed_allowed'); + // If we are embedding the board, turn off the view link. - if ($board->embed) { + if ($embedallowed && $board->embed) { $cm->set_no_view_link(); } @@ -496,7 +499,10 @@ function board_cm_info_view(cm_info $cm) { // Look up the board based on the course module. $board = board::get_board($cm->instance); - if ($board->embed) { + // Check if embedding feature is allowed. + $embedallowed = get_config('mod_board', 'embed_allowed'); + + if ($embedallowed && $board->embed) { $width = get_config('mod_board', 'embed_width'); $height = get_config('mod_board', 'embed_height'); $output = html_writer::start_tag('div', ['class' => 'mod_board_embed_container']); diff --git a/mod_form.php b/mod_form.php index d33418c..c73ad5a 100755 --- a/mod_form.php +++ b/mod_form.php @@ -83,9 +83,6 @@ public function definition() { $mform->addElement('checkbox', 'hideheaders', get_string('hideheaders', 'mod_board')); $mform->setType('hideheaders', PARAM_INT); - $mform->addElement('advcheckbox', 'hidename', get_string('hidename', 'mod_board')); - $mform->setType('hidename', PARAM_INT); - $mform->addElement('select', 'sortby', get_string('sortby', 'mod_board'), array( board::SORTBYNONE => get_string('sortbynone', 'mod_board'), @@ -131,8 +128,14 @@ public function definition() { $mform->addElement('advcheckbox', 'enableblanktarget', get_string('enableblanktarget', 'mod_board')); $mform->addHelpButton('enableblanktarget', 'enableblanktarget', 'mod_board'); - // Embed board on the course, rather then give a link to it. - $mform->addElement('advcheckbox', 'embed', get_string('embedboard', 'mod_board')); + + // Only add the embed setting, if embedding is allowed globally. + if (get_config('mod_board', 'embed_allowed')) { + // Embed board on the course, rather then give a link to it. + $mform->addElement('advcheckbox', 'embed', get_string('embedboard', 'mod_board')); + + $mform->addElement('advcheckbox', 'hidename', get_string('hidename', 'mod_board')); + } $this->standard_coursemodule_elements(); @@ -167,8 +170,10 @@ public function data_preprocessing(&$defaultvalues) { public function validation($data, $files) { $errors = parent::validation($data, $files); - if (($data['embed'] == 1) && ($data['singleusermode'] != board::SINGLEUSER_DISABLED)) { - $errors['embed'] = get_string('singleusermodenotembed', 'mod_board'); + if (get_config('mod_board', 'embed_allowed')) { + if (($data['embed'] == 1) && ($data['singleusermode'] != board::SINGLEUSER_DISABLED)) { + $errors['embed'] = get_string('singleusermodenotembed', 'mod_board'); + } } return $errors; diff --git a/settings.php b/settings.php index 62c43b8..abec4ec 100755 --- a/settings.php +++ b/settings.php @@ -67,6 +67,13 @@ '1' )); + $settings->add(new admin_setting_configcheckbox( + 'mod_board/embed_allowed', + get_string('embed_allowed', 'mod_board'), + get_string('embed_allowed_desc', 'mod_board'), + '1' + )); + $settings->add(new admin_setting_configtext('mod_board/embed_width', get_string('embed_width', 'mod_board'), get_string('embed_width_desc', 'mod_board'), '99%', PARAM_TEXT)); diff --git a/version.php b/version.php index 4f5c6e9..276cc03 100755 --- a/version.php +++ b/version.php @@ -25,7 +25,7 @@ defined('MOODLE_INTERNAL') || die; $plugin->component = 'mod_board'; // Full name of the plugin (used for diagnostics). -$plugin->version = 2022040114; // The current module version Use 2022.04.01 as base for 4.00. +$plugin->version = 2022040115; // The current module version Use 2022.04.01 as base for 4.00. $plugin->requires = 2022041900; // Moodle 4.00 and up. $plugin->release = '1.401.03 (Build 2022040112)'; $plugin->maturity = MATURITY_STABLE;