-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 700a785
Showing
9 changed files
with
476 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
BigblueButton Extension - FlexURL | ||
======================= | ||
* Maintained by: Laurent David | ||
* Copyright: Blindside Networks Inc | ||
* License: GNU GENERAL PUBLIC LICENSE Version 3 | ||
|
||
This is an extension plugin for BigBluebButtonBN module that will allow you to some parameters dynamically | ||
to the create and join URL. This is sometimes needed for specific BigBlueButton integrations. | ||
|
||
|
||
Description | ||
=========== | ||
This plugin shows how to extend BigBluebButtonBN module to: | ||
* Add a new parameter to an Action URL (create and join) | ||
* Setup a new parameter in the BigBlueButtonBN module settings (and edit form) | ||
|
||
|
||
Installation | ||
============ | ||
Drop the module in the mod/bigbluebuttonbn/extension folder | ||
|
||
|
||
Requirements | ||
------------ | ||
BigblueButtonBN module version > 2022112802 | ||
|
||
Code from ticket https://tracker.moodle.org/browse/MDL-78960 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
/** | ||
* Provides the information for backup. | ||
* | ||
* @package bbbext_flexurl | ||
* @copyright 2023 onwards, Blindside Networks Inc | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* @author Laurent David ([email protected]) | ||
*/ | ||
class backup_bbbext_flexurl_subplugin extends backup_subplugin { | ||
|
||
/** | ||
* Returns the subplugin information to attach the BigBlueButton instance. | ||
* | ||
* @return backup_subplugin_element | ||
*/ | ||
protected function define_bigbluebuttonbn_subplugin_structure() { | ||
|
||
// Create XML elements. | ||
$subplugin = $this->get_subplugin_element(); | ||
$subpluginwrapper = new backup_nested_element($this->get_recommended_name()); | ||
$subpluginelement = new backup_nested_element('bbbext_flexurl', | ||
null, | ||
['additionalparams']); | ||
|
||
// Connect XML elements into the tree. | ||
$subplugin->add_child($subpluginwrapper); | ||
$subpluginwrapper->add_child($subpluginelement); | ||
|
||
// Set source to populate the data. | ||
$subpluginelement->set_source_table('bbbext_flexurl', | ||
array('bigbluebuttonbnid' => backup::VAR_PARENTID)); | ||
|
||
return $subplugin; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Provides the information for restore. | ||
* | ||
* | ||
* @package bbbext_flexurl | ||
* @copyright 2023 onwards, Blindside Networks Inc | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* @author Laurent David ([email protected]) | ||
*/ | ||
class restore_bbbext_flexurl_subplugin extends restore_subplugin { | ||
/** | ||
* Returns the paths to be handled by the subplugin. | ||
* | ||
* @return array | ||
*/ | ||
protected function define_bigbluebuttonbn_subplugin_structure() { | ||
|
||
$paths = array(); | ||
|
||
$elename = $this->get_namefor('bigbluebuttonbn'); | ||
// We used get_recommended_name() so this works. | ||
$elepath = $this->get_pathfor('/bbbext_flexurl'); | ||
|
||
$paths[] = new restore_path_element($elename, $elepath); | ||
|
||
return $paths; | ||
} | ||
|
||
/** | ||
* Processes one subplugin instance additional parameter. | ||
* | ||
* @param mixed $data | ||
*/ | ||
public function process_bbbext_flexurl_bigbluebuttonbn($data) { | ||
global $DB; | ||
|
||
$data = (object) $data; | ||
$data->bigbluebuttonbnid = $this->get_new_parentid('bigbluebuttonbn'); | ||
$DB->insert_record('bbbext_flexurl', $data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
namespace bbbext_flexurl\bigbluebuttonbn; | ||
|
||
/** | ||
* A single action class to mutate the action URL. | ||
* | ||
* @package bbbext_flexurl | ||
* @copyright 2023 onwards, Blindside Networks Inc | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* @author Laurent David ([email protected]) | ||
*/ | ||
class action_url_addons extends \mod_bigbluebuttonbn\local\extension\action_url_addons { | ||
/** | ||
* Sample mutate the action URL. | ||
* | ||
* | ||
* @param string $action | ||
* @param array $data | ||
* @param array $metadata | ||
* @param int|null $instanceid | ||
* @return array associative array with the additional data and metadata (indexed by 'data' and | ||
* 'metadata' keys) | ||
*/ | ||
public function execute(string $action = '', array $data = [], array $metadata = [], ?int $instanceid = null): array { | ||
if ($action == 'create' || $action == 'join') { | ||
if (empty($instanceid)) { | ||
if (!(defined('PHPUNIT_TEST') && PHPUNIT_TEST) && !defined('BEHAT_SITE_RUNNING')) { | ||
// Debugging messages will fail mod_bigbluebuttonbn behat or phpunit tests as soon as the plugin is installed. | ||
// Which is not what we want here. | ||
debugging('No instanceid provided to action_url_addons, this mean we will not be able to retrieve any' . | ||
'instance specific data in the subplugins.'); | ||
} | ||
} else { | ||
global $DB; | ||
$record = $DB->get_record(mod_instance_helper::SUBPLUGIN_TABLE, [ | ||
'bigbluebuttonbnid' => $instanceid, | ||
]); | ||
if ($record) { | ||
$metadata['additionalparams'] = $record->additionalparams ?? ''; | ||
} | ||
} | ||
} | ||
|
||
return ['data' => $data, 'metadata' => $metadata]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
namespace bbbext_flexurl\bigbluebuttonbn; | ||
|
||
use stdClass; | ||
|
||
/** | ||
* A class for the main mod form extension | ||
* | ||
* @package bbbext_flexurl | ||
* @copyright 2023 onwards, Blindside Networks Inc | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* @author Laurent David ([email protected]) | ||
*/ | ||
class mod_form_addons extends \mod_bigbluebuttonbn\local\extension\mod_form_addons { | ||
/** | ||
* Allows modules to modify the data returned by form get_data(). | ||
* This method is also called in the bulk activity completion form. | ||
* | ||
* Only available on moodleform_mod. | ||
* | ||
* @param stdClass $data passed by reference | ||
*/ | ||
public function data_postprocessing(\stdClass &$data): void { | ||
// Nothing for now. | ||
} | ||
|
||
/** | ||
* Allow module to modify the data at the pre-processing stage. | ||
* | ||
* This method is also called in the bulk activity completion form. | ||
* | ||
* @param array|null $defaultvalues | ||
*/ | ||
public function data_preprocessing(?array &$defaultvalues): void { | ||
// This is where we can add the data from the flexurl table to the data provided. | ||
if (!empty($defaultvalues['id'])) { | ||
global $DB; | ||
$flexurlrecord = $DB->get_record(mod_instance_helper::SUBPLUGIN_TABLE, [ | ||
'bigbluebuttonbnid' => $defaultvalues['id'], | ||
]); | ||
if ($flexurlrecord) { | ||
$defaultvalues['additionalparams'] = $flexurlrecord->additionalparams; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Can be overridden to add custom completion rules if the module wishes | ||
* them. If overriding this, you should also override completion_rule_enabled. | ||
* <p> | ||
* Just add elements to the form as needed and return the list of IDs. The | ||
* system will call disabledIf and handle other behaviour for each returned | ||
* ID. | ||
* | ||
* @return array Array of string IDs of added items, empty array if none | ||
*/ | ||
public function add_completion_rules(): array { | ||
return []; | ||
} | ||
|
||
/** | ||
* Called during validation. Override to indicate, based on the data, whether | ||
* a custom completion rule is enabled (selected). | ||
* | ||
* @param array $data Input data (not yet validated) | ||
* @return bool True if one or more rules is enabled, false if none are; | ||
* default returns false | ||
*/ | ||
public function completion_rule_enabled(array $data): bool { | ||
return false; | ||
} | ||
|
||
/** | ||
* Form adjustments after setting data | ||
* | ||
* @return void | ||
*/ | ||
public function definition_after_data() { | ||
// Nothing for now. | ||
} | ||
|
||
/** | ||
* Add new form field definition | ||
*/ | ||
public function add_fields(): void { | ||
$this->mform->addElement('header', 'flexurl', get_string('pluginname', 'bbbext_flexurl')); | ||
$this->mform->addElement('text', 'additionalparams', get_string('additionalparams', 'bbbext_flexurl')); | ||
$this->mform->setType('additionalparams', PARAM_TEXT); | ||
} | ||
|
||
/** | ||
* Validate form and returns an array of errors indexed by field name | ||
* | ||
* @param array $data | ||
* @param array $files | ||
* @return array | ||
*/ | ||
public function validation(array $data, array $files): array { | ||
$errors = []; | ||
if (strip_tags($data['additionalparams']) != $data['additionalparams']) { | ||
$errors['additionalparams'] = get_string('additionalparams:error', 'bbbext_flexurl'); | ||
} | ||
return $errors; | ||
} | ||
} |
Oops, something went wrong.