-
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.
MOOD-45: Rename flexurl to bnurl (#14)
- Loading branch information
Showing
13 changed files
with
121 additions
and
121 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
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 |
---|---|---|
|
@@ -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. | ||
|
@@ -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'] | ||
); | ||
|
@@ -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] | ||
); | ||
|
||
|
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 |
---|---|---|
|
@@ -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. | ||
* | ||
|
@@ -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; | ||
|
@@ -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); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -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]) | ||
|
@@ -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); | ||
|
||
} | ||
} | ||
|
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 |
---|---|---|
|
@@ -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]) | ||
|
@@ -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)] ?? []); | ||
} | ||
} | ||
|
||
|
@@ -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} ?? ''; | ||
} | ||
} | ||
} | ||
|
@@ -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); | ||
|
@@ -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, | ||
|
@@ -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, | ||
|
@@ -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]); | ||
} | ||
|
||
/** | ||
|
@@ -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; | ||
|
Oops, something went wrong.