Skip to content

Commit

Permalink
MOOD-45: Rename flexurl to bnurl (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssj365 authored Nov 1, 2024
1 parent d697245 commit cdb68b2
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 121 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
BigBlueButton Extension - FlexURL
BigBlueButton Extension - BN URL
=======================
* Copyright: Blindside Networks Inc
* License: GNU GENERAL PUBLIC LICENSE Version 3

Overview
===========
The FlexURL subplugin enhances the BigBlueButtonBN module by passing additional parameters when a BigBlueButtonBN session is created, joined or both. The parameters can be custom defined, or information from user, course and activity module.
The BN URL subplugin enhances the BigBlueButtonBN module by passing additional parameters when a BigBlueButtonBN session is created, joined or both. The parameters can be custom defined, or information from user, course and activity module.

Features
===========
Expand All @@ -22,15 +22,15 @@ Git installation
------------
1. Clone the repository:

`git clone https://github.com/blindsidenetworks-ps/moodle-bbbext_flexurl.git`
`git clone https://github.com/blindsidenetworks-ps/moodle-bbbext_bnurl.git`

2. Rename the downloaded directory:

`mv moodle-bbbext_flexurl flexurl`
`mv moodle-bbbext_bnurl bnurl`

3. Move the folder to the Moodle BigBlueButtonBN extensions directory:

`mv flexurl /var/www/html/moodle/mod/bigbluebuttonbn/extension/`
`mv bnurl /var/www/html/moodle/mod/bigbluebuttonbn/extension/`

4. Run the Moodle upgrade script:

Expand All @@ -40,7 +40,7 @@ Manual installation
------------
1. Download the sub plugin zip file and extract it.
2. Place the extracted folder into `mod/bigbluebuttonbn/extension/`
3. Rename the folder `flexurl`
3. Rename the folder `bnurl`
4. Access Moodle's Admin UI at `Site administration > Plugins > Install plugins` to complete the installation.

Configuration
Expand Down Expand Up @@ -86,4 +86,4 @@ Requirements
============
Requires BigBlueButtonBN module version > 2022112802

For more detailed updates and support, visit the [FlexURL Subplugin GitHub Repository](https://github.com/blindsidenetworks-ps/moodle-bbbext_flexurl)
For more detailed updates and support, visit the [BN URL Subplugin GitHub Repository](https://github.com/blindsidenetworks-ps/moodle-bbbext_bnurl)
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
/**
* Provides the information for backup.
*
* @package bbbext_flexurl
* @package bbbext_bnurl
* @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 {
class backup_bbbext_bnurl_subplugin extends backup_subplugin {

/**
* Returns the subplugin information to attach the BigBlueButton instance.
Expand All @@ -35,7 +35,7 @@ protected function define_bigbluebuttonbn_subplugin_structure() {
$subplugin = $this->get_subplugin_element();
$subpluginwrapper = new backup_nested_element($this->get_recommended_name());
$subpluginelement = new backup_nested_element(
'bbbext_flexurl',
'bbbext_bnurl',
null,
['eventtype', 'paramname', 'paramvalue']
);
Expand All @@ -46,7 +46,7 @@ protected function define_bigbluebuttonbn_subplugin_structure() {

// Set source to populate the data.
$subpluginelement->set_source_table(
'bbbext_flexurl',
'bbbext_bnurl',
['bigbluebuttonbnid' => backup::VAR_PARENTID]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
* Provides the information for restore.
*
*
* @package bbbext_flexurl
* @package bbbext_bnurl
* @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 {
class restore_bbbext_bnurl_subplugin extends restore_subplugin {
/**
* Returns the paths to be handled by the subplugin.
*
Expand All @@ -34,7 +34,7 @@ protected function define_bigbluebuttonbn_subplugin_structure() {

$elename = $this->get_namefor('bigbluebuttonbn');
// We used get_recommended_name() so this works.
$elepath = $this->get_pathfor('/bbbext_flexurl');
$elepath = $this->get_pathfor('/bbbext_bnurl');

$paths[] = new restore_path_element($elename, $elepath);
return $paths;
Expand All @@ -45,11 +45,11 @@ protected function define_bigbluebuttonbn_subplugin_structure() {
*
* @param mixed $data
*/
public function process_bbbext_flexurl_bigbluebuttonbn($data) {
public function process_bbbext_bnurl_bigbluebuttonbn($data) {
global $DB;

$data = (object) $data;
$data->bigbluebuttonbnid = $this->get_new_parentid('bigbluebuttonbn');
$DB->insert_record('bbbext_flexurl', $data);
$DB->insert_record('bbbext_bnurl', $data);
}
}
16 changes: 8 additions & 8 deletions classes/bigbluebuttonbn/action_url_addons.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
// 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;
namespace bbbext_bnurl\bigbluebuttonbn;

use bbbext_flexurl\utils;
use bbbext_bnurl\utils;
use core_form\util;
use mod_bigbluebuttonbn\instance;

/**
* A single action class to mutate the action URL.
*
* @package bbbext_flexurl
* @package bbbext_bnurl
* @copyright 2023 onwards, Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Laurent David ([email protected])
Expand All @@ -44,16 +44,16 @@ public function execute(string $action = '', array $data = [], array $metadata =
global $DB;
if ($instanceid) {
$instance = instance::get_from_instanceid($instanceid);
$flexurlrecords = $DB->get_records(mod_instance_helper::SUBPLUGIN_TABLE, [
$bnurlrecords = $DB->get_records(mod_instance_helper::SUBPLUGIN_TABLE, [
'bigbluebuttonbnid' => $instanceid,
]);
$eventtypes = array_flip(utils::ACTION_CODES);
foreach ($flexurlrecords as $flexurlrecord) {
if ($flexurlrecord->eventtype != utils::ACTION_CODES['all'] &&
$eventtypes[$flexurlrecord->eventtype] != $action) {
foreach ($bnurlrecords as $bnurlrecord) {
if ($bnurlrecord->eventtype != utils::ACTION_CODES['all'] &&
$eventtypes[$bnurlrecord->eventtype] != $action) {
continue;
}
$data[$flexurlrecord->paramname] = utils::get_real_value($flexurlrecord->paramvalue, $instance);
$data[$bnurlrecord->paramname] = utils::get_real_value($bnurlrecord->paramvalue, $instance);

}
}
Expand Down
100 changes: 50 additions & 50 deletions classes/bigbluebuttonbn/mod_form_addons.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
// 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;
namespace bbbext_bnurl\bigbluebuttonbn;

use bbbext_flexurl\utils;
use bbbext_bnurl\utils;
use stdClass;

/**
* A class for the main mod form extension
*
* @package bbbext_flexurl
* @package bbbext_bnurl
* @copyright 2023 onwards, Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Laurent David ([email protected])
Expand All @@ -42,7 +42,7 @@ public function __construct(\MoodleQuickForm &$mform, ?stdClass $bigbluebuttonbn
if (!empty($bigbluebuttonbndata->id)) {
$data = $this->retrieve_additional_data($bigbluebuttonbndata->id);
$this->bigbluebuttonbndata = (object) array_merge((array) $this->bigbluebuttonbndata, $data);
$this->bigbluebuttonbndata->flexurl_paramcount = count($data["flexurl_".array_key_first(utils::PARAM_TYPES)] ?? []);
$this->bigbluebuttonbndata->bnurl_paramcount = count($data["bnurl_".array_key_first(utils::PARAM_TYPES)] ?? []);
}
}

Expand All @@ -55,17 +55,17 @@ public function __construct(\MoodleQuickForm &$mform, ?stdClass $bigbluebuttonbn
private function retrieve_additional_data(int $id): array {
global $DB;
$data = [];
$flexurlrecords = $DB->get_records(mod_instance_helper::SUBPLUGIN_TABLE, [
$bnurlrecords = $DB->get_records(mod_instance_helper::SUBPLUGIN_TABLE, [
'bigbluebuttonbnid' => $id,
]);
if ($flexurlrecords) {
$flexurlrecords = array_values($flexurlrecords);
foreach ($flexurlrecords as $flexurlrecord) {
if ($bnurlrecords) {
$bnurlrecords = array_values($bnurlrecords);
foreach ($bnurlrecords as $bnurlrecord) {
foreach (utils::PARAM_TYPES as $paramtype => $paramtypevalue) {
if (!isset($data["flexurl_{$paramtype}"])) {
$data["flexurl_{$paramtype}"] = [];
if (!isset($data["bnurl_{$paramtype}"])) {
$data["bnurl_{$paramtype}"] = [];
}
$data["flexurl_{$paramtype}"][] = $flexurlrecord->{$paramtype} ?? '';
$data["bnurl_{$paramtype}"][] = $bnurlrecord->{$paramtype} ?? '';
}
}
}
Expand All @@ -92,7 +92,7 @@ public function data_postprocessing(\stdClass &$data): void {
* @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.
// This is where we can add the data from the bnurl table to the data provided.
if (!empty($defaultvalues['id'])) {
$data = $this->retrieve_additional_data(intval($defaultvalues['id']));
$defaultvalues = (object) array_merge($defaultvalues, $data);
Expand Down Expand Up @@ -132,57 +132,57 @@ public function completion_rule_enabled(array $data): bool {
*/
public function definition_after_data() {
// After data.
$isdeleting = optional_param_array('flexurl_paramdelete', [], PARAM_RAW);
$isdeleting = optional_param_array('bnurl_paramdelete', [], PARAM_RAW);
// Get the index of the delete button that was pressed.
if (!empty($isdeleting)) {
$firstindex = array_key_first($isdeleting);
// Then reassign values from the deleted group to the previous group.
$paramcount = optional_param('flexurl_paramcount', 0, PARAM_INT);
$paramcount = optional_param('bnurl_paramcount', 0, PARAM_INT);
for ($index = $firstindex; $index < $paramcount; $index++) {
$nextindex = $index + 1;
if ($this->mform->elementExists("flexurl_paramgroup[{$nextindex}]")) {
$nextgroupelement = $this->mform->getElement("flexurl_paramgroup[{$nextindex}]");
if ($this->mform->elementExists("bnurl_paramgroup[{$nextindex}]")) {
$nextgroupelement = $this->mform->getElement("bnurl_paramgroup[{$nextindex}]");
if (!empty($nextgroupelement)) {
$nextgroupvalue = $nextgroupelement->getValue();
$currentgroupelement = $this->mform->getElement("flexurl_paramgroup[{$index}]");
$currentgroupelement = $this->mform->getElement("bnurl_paramgroup[{$index}]");
$value = [
"flexurl_paramname[{$index}]" => $nextgroupvalue["flexurl_paramname[{$nextindex}]"],
"flexurl_paramvalue[{$index}]" => $nextgroupvalue["flexurl_paramvalue[{$nextindex}]"],
"bnurl_paramname[{$index}]" => $nextgroupvalue["bnurl_paramname[{$nextindex}]"],
"bnurl_paramvalue[{$index}]" => $nextgroupvalue["bnurl_paramvalue[{$nextindex}]"],
];
$currentgroupelement->setValue($value);
}
}
}
$newparamcount = $paramcount - 1;
$this->mform->removeElement("flexurl_paramgroup[{$newparamcount}]");
$this->mform->getElement('flexurl_paramcount')->setValue($newparamcount);
$this->mform->removeElement("bnurl_paramgroup[{$newparamcount}]");
$this->mform->getElement('bnurl_paramcount')->setValue($newparamcount);
}
}

/**
* Add new form field definition
*/
public function add_fields(): void {
$this->mform->addElement('header', 'flexurl', get_string('formname', 'bbbext_flexurl'));
$this->mform->addHelpButton('flexurl', 'formname', 'bbbext_flexurl');
$paramcount = optional_param('flexurl_paramcount', $this->bigbluebuttonbndata->flexurl_paramcount ?? 0, PARAM_RAW);
$paramcount += optional_param('flexurl_addparamgroup', 0, PARAM_RAW) ? 1 : 0;
$isdeleting = optional_param_array('flexurl_paramdelete', [], PARAM_RAW);
$this->mform->addElement('header', 'bnurl', get_string('formname', 'bbbext_bnurl'));
$this->mform->addHelpButton('bnurl', 'formname', 'bbbext_bnurl');
$paramcount = optional_param('bnurl_paramcount', $this->bigbluebuttonbndata->bnurl_paramcount ?? 0, PARAM_RAW);
$paramcount += optional_param('bnurl_addparamgroup', 0, PARAM_RAW) ? 1 : 0;
$isdeleting = optional_param_array('bnurl_paramdelete', [], PARAM_RAW);
foreach ($isdeleting as $index => $value) {
// This prevents the last delete button from submitting the form.
$this->mform->registerNoSubmitButton("flexurl_paramdelete[$index]");
$this->mform->registerNoSubmitButton("bnurl_paramdelete[$index]");
}
for ($index = 0; $index < $paramcount; $index++) {
$paramname = $this->mform->createElement(
'text',
"flexurl_paramname[$index]",
get_string('param_name', 'bbbext_flexurl'),
"bnurl_paramname[$index]",
get_string('param_name', 'bbbext_bnurl'),
['size' => '6']
);
$paramvalue = $this->mform->createElement(
'autocomplete',
"flexurl_paramvalue[$index]",
get_string('param_value', 'bbbext_flexurl'),
"bnurl_paramvalue[$index]",
get_string('param_value', 'bbbext_bnurl'),
utils::get_options_for_parameters(),
[
'tags' => true,
Expand All @@ -191,13 +191,13 @@ public function add_fields(): void {
$paramvalue->setValue('');
$paramtype = $this->mform->createElement(
'select',
"flexurl_eventtype[$index]",
get_string('param_eventtype', 'bbbext_flexurl'),
"bnurl_eventtype[$index]",
get_string('param_eventtype', 'bbbext_bnurl'),
utils::get_option_for_eventtype(),
);
$paramdelete = $this->mform->createElement(
'submit',
"flexurl_paramdelete[$index]",
"bnurl_paramdelete[$index]",
get_string('delete'),
[],
false,
Expand All @@ -208,26 +208,26 @@ public function add_fields(): void {
[
$paramname, $paramvalue, $paramtype, $paramdelete,
],
"flexurl_paramgroup[$index]",
get_string('paramgroup', 'bbbext_flexurl'),
"bnurl_paramgroup[$index]",
get_string('paramgroup', 'bbbext_bnurl'),
[' '],
false
);
$this->mform->setType("flexurl_paramname[$index]", utils::PARAM_TYPES['paramname']);
$this->mform->setType("flexurl_paramvalue[$index]", utils::PARAM_TYPES['paramvalue']);
$this->mform->setType("flexurl_eventtype[$index]", utils::PARAM_TYPES['eventtype']);
$this->mform->setType("flexurl_paramdelete[$index]", PARAM_RAW);
$this->mform->setType("bnurl_paramname[$index]", utils::PARAM_TYPES['paramname']);
$this->mform->setType("bnurl_paramvalue[$index]", utils::PARAM_TYPES['paramvalue']);
$this->mform->setType("bnurl_eventtype[$index]", utils::PARAM_TYPES['eventtype']);
$this->mform->setType("bnurl_paramdelete[$index]", PARAM_RAW);

$this->mform->registerNoSubmitButton("flexurl_paramdelete[$index]");
$this->mform->registerNoSubmitButton("bnurl_paramdelete[$index]");

}
// Add a button to add new param groups.
$this->mform->addElement('submit', 'flexurl_addparamgroup', get_string('addparamgroup', 'bbbext_flexurl'));
$this->mform->setType('flexurl_addparamgroup', PARAM_TEXT);
$this->mform->registerNoSubmitButton('flexurl_addparamgroup');
$this->mform->addElement('hidden', 'flexurl_paramcount');
$this->mform->setType('flexurl_paramcount', PARAM_INT);
$this->mform->setConstants(['flexurl_paramcount' => $paramcount]);
$this->mform->addElement('submit', 'bnurl_addparamgroup', get_string('addparamgroup', 'bbbext_bnurl'));
$this->mform->setType('bnurl_addparamgroup', PARAM_TEXT);
$this->mform->registerNoSubmitButton('bnurl_addparamgroup');
$this->mform->addElement('hidden', 'bnurl_paramcount');
$this->mform->setType('bnurl_paramcount', PARAM_INT);
$this->mform->setConstants(['bnurl_paramcount' => $paramcount]);
}

/**
Expand All @@ -240,9 +240,9 @@ public function add_fields(): void {
public function validation(array $data, array $files): array {
$errors = [];
foreach (utils::PARAM_TYPES as $paramtype => $paramtypevalue) {
if (!empty($data['flexurl_' . $paramtype])
&& clean_param_array($data['flexurl_' . $paramtype], $paramtypevalue, true) === false) {
$errors["flexurl_{$paramtype}"] = get_string('invalidvalue', 'bbbext_flexurl');
if (!empty($data['bnurl_' . $paramtype])
&& clean_param_array($data['bnurl_' . $paramtype], $paramtypevalue, true) === false) {
$errors["bnurl_{$paramtype}"] = get_string('invalidvalue', 'bbbext_bnurl');
}
}
return $errors;
Expand Down
Loading

0 comments on commit cdb68b2

Please sign in to comment.