Skip to content

Commit

Permalink
Make board-embedding configurable, solves #63
Browse files Browse the repository at this point in the history
  • Loading branch information
christianwolters authored and learningtechnologyservices committed Oct 3, 2024
1 parent 1387a5d commit 356e86b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
2 changes: 2 additions & 0 deletions lang/en/board.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.';
Expand Down
10 changes: 8 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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']);
Expand Down
19 changes: 12 additions & 7 deletions mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;
Expand Down
7 changes: 7 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit 356e86b

Please sign in to comment.