This commit is contained in:
Huong Nguyen
2025-09-04 15:52:37 +07:00
15 changed files with 414 additions and 15 deletions
@@ -22,6 +22,8 @@ use mod_bigbluebuttonbn\local\extension\broker_meeting_events_addons;
use mod_bigbluebuttonbn\local\extension\custom_completion_addons;
use mod_bigbluebuttonbn\local\extension\mod_form_addons;
use mod_bigbluebuttonbn\local\extension\mod_instance_helper;
use mod_bigbluebuttonbn\local\extension\navigation_append_addon;
use mod_bigbluebuttonbn\local\extension\navigation_override_addon;
use stdClass;
use core_plugin_manager;
use core_component;
@@ -259,4 +261,34 @@ class extension {
public static function broker_meeting_events_addons_instances(instance $instance, string $data): array {
return self::get_instances_implementing(broker_meeting_events_addons::class, [$instance, $data]);
}
/**
* Append settings navigation.
*
* @param \settings_navigation $settingsnav
* @param \navigation_node $nodenav
*/
public static function append_settings_navigation(\settings_navigation $settingsnav, \navigation_node $nodenav) {
$appends = self::get_instances_implementing(navigation_append_addon::class);
foreach ($appends as $addon) {
$addon->append_settings_navigation($settingsnav, $nodenav);
}
}
/**
* Override settings navigation.
*
* @param \settings_navigation $settingsnav
* @param \navigation_node $nodenav
* @return bool true if the settings navigation was overridden, false otherwise.
*/
public static function override_settings_navigation(\settings_navigation $settingsnav, \navigation_node $nodenav) {
$overrides = self::get_instances_implementing(navigation_override_addon::class);
if (!empty($overrides)) {
$firstoverride = reset($overrides);
$firstoverride->override_settings_navigation($settingsnav, $nodenav);
return true;
}
return false;
}
}
@@ -0,0 +1,39 @@
<?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 mod_bigbluebuttonbn\local\extension;
/**
* Interface for appending to the settings navigation in BigBlueButtonBN subplugins.
*
* Implement this interface in a subplugin if you want to append to the settings navigation.
* All subplugins implementing this will be called after the core/default logic, unless an override is present.
*
* @package mod_bigbluebuttonbn
* @copyright 2025 Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
*/
interface navigation_append_addon {
/**
* Appends to the settings navigation.
*
* @param \settings_navigation $settingsnav
* @param \navigation_node $nodenav
* @return void
*/
public function append_settings_navigation(\settings_navigation $settingsnav, \navigation_node $nodenav): void;
}
@@ -0,0 +1,39 @@
<?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 mod_bigbluebuttonbn\local\extension;
/**
* Interface for overriding the settings navigation in BigBlueButtonBN subplugins.
*
* Implement this interface in a subplugin if you want to override the settings navigation.
* Only the first subplugin implementing this will be called, and it will replace the default logic.
*
* @package mod_bigbluebuttonbn
* @copyright 2025 Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
*/
interface navigation_override_addon {
/**
* Overrides the settings navigation.
*
* @param \settings_navigation $settingsnav
* @param \navigation_node $nodenav
* @return void
*/
public function override_settings_navigation(\settings_navigation $settingsnav, \navigation_node $nodenav): void;
}
@@ -50,7 +50,7 @@ trait subplugins_test_helper_trait {
$mockedplugins = $mockedcomponent->getProperty('plugins');
$plugins = $mockedplugins->getValue();
$plugins[extension::BBB_EXTENSION_PLUGIN_NAME] = [$pluginname => $bbbextpath . "/$pluginname"];
$plugins[extension::BBB_EXTENSION_PLUGIN_NAME][$pluginname] = $bbbextpath . "/$pluginname";
$mockedplugins->setValue(null, $plugins);
$mockedplugintypes = $mockedcomponent->getProperty('plugintypes');
+10
View File
@@ -568,6 +568,13 @@ function mod_bigbluebuttonbn_core_calendar_is_event_visible(calendar_event $even
* @param navigation_node $nodenav The node to add module settings to
*/
function bigbluebuttonbn_extend_settings_navigation(settings_navigation $settingsnav, navigation_node $nodenav) {
// Check for overrides.
$overriden = extension::override_settings_navigation($settingsnav, $nodenav);
if ($overriden) {
return;
}
// Run core/default logic here.
global $USER;
$context = context_module::instance($settingsnav->get_page()->cm->id);
// Add validate completion if the callback for meetingevents is enabled and user is allowed to edit the activity.
@@ -582,6 +589,9 @@ function bigbluebuttonbn_extend_settings_navigation(settings_navigation $setting
navigation_node::TYPE_CONTAINER
);
}
// Call all appends.
extension::append_settings_navigation($settingsnav, $nodenav);
}
/**
@@ -246,22 +246,19 @@ XPATH
/**
* Install the simple subplugin
*
* Important note here. Originally we had a step that was installing the plugin, however
* because of race condition (mainly javascript calls), the hack to the core_component was
* randomly lost due to the component cache being cleared. So we have to install the plugin before
* any interaction with the site.
* @BeforeScenario @with_bbbext_simple
*/
public function install_simple_subplugin() {
$this->setup_fake_plugin("simple");
$mockedcomponent = new ReflectionClass(core_component::class);
$mockedplugintypes = $mockedcomponent->getProperty('plugintypes');
$mockedplugintypes->setValue(null, null);
$init = $mockedcomponent->getMethod('init');
$init->invoke(null);
// I enable the plugin.
$manager = core_plugin_manager::resolve_plugininfo_class(\mod_bigbluebuttonbn\extension::BBB_EXTENSION_PLUGIN_NAME);
$manager::enable_plugin("simple", true);
$this->install_bbbext_subplugin('simple');
}
/**
* Install the complex subplugin
*
* @BeforeScenario @with_bbbext_complex
*/
public function install_complex_subplugin() {
$this->install_bbbext_subplugin('complex');
}
/**
@@ -272,4 +269,36 @@ XPATH
public function uninstall_simple_subplugin() {
$this->uninstall_fake_plugin("simple");
}
/**
* Uninstall the complex subplugin
*
* @AfterScenario @with_bbbext_complex
*/
public function uninstall_complex_subplugin() {
$this->uninstall_fake_plugin("complex");
}
/**
* Install subplugin
*
* Important note here. Originally we had a step that was installing the plugin, however
* because of race condition (mainly javascript calls), the hack to the core_component was
* randomly lost due to the component cache being cleared. So we have to install the plugin before
* any interaction with the site.
* @param string $subplugin The subplugin name
*/
public function install_bbbext_subplugin(string $subplugin): void {
$this->setup_fake_plugin($subplugin);
$this->installedsubplugins[] = $subplugin;
$mockedcomponent = new ReflectionClass(core_component::class);
$mockedplugintypes = $mockedcomponent->getProperty('plugintypes');
$mockedplugintypes->setValue(null, null);
$init = $mockedcomponent->getMethod('init');
$init->invoke(null);
// I enable the plugin.
$manager = core_plugin_manager::resolve_plugininfo_class(\mod_bigbluebuttonbn\extension::BBB_EXTENSION_PLUGIN_NAME);
$manager::enable_plugin($subplugin, true);
}
}
@@ -42,7 +42,7 @@ Feature: BigBlueButtonBN Subplugins test
Scenario: I check that new fields are not available when subplugin is disabled
Given I log in as "admin"
And I navigate to "Plugins > Activity modules > BigBlueButton > Manage BigBlueButton extension plugins" in site administration
And I click on "Disable" "link"
And I click on "Disable" "link" in the "Simple" "table_row"
And I am on the "BBB Instance name" "bigbluebuttonbn activity editing" page
When I expand all fieldsets
Then I should not see "New field"
@@ -121,3 +121,19 @@ Feature: BigBlueButtonBN Subplugins test
And I run all adhoc tasks
When I am on fixture page "/mod/bigbluebuttonbn/tests/behat/fixtures/show_simpleplugin_values.php"
Then I should see "(BBB Instance name): meetingevents: 1"
@javascript
Scenario: I check that subplugins can append or override the navigation settings
Given I log in as "admin"
And I am on the "BBB Instance name" "bigbluebuttonbn activity" page logged in as "admin"
And I should see "Append Navigation"
And I should not see "Override Navigation"
@javascript @with_bbbext_complex
Scenario: I check that subplugins can append or override the navigation settings
Given I log in as "admin"
And I navigate to "Plugins > Activity modules > BigBlueButton > Manage BigBlueButton extension plugins" in site administration
And I click on "Enable" "link" in the "Complex" "table_row"
And I am on the "BBB Instance name" "bigbluebuttonbn activity" page logged in as "admin"
Then I should see "Override Navigation"
And I should not see "Append Navigation"
@@ -0,0 +1,46 @@
<?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_complex\bigbluebuttonbn;
use mod_bigbluebuttonbn\local\extension\navigation_override_addon as navigation_override_addon_interface;
/**
* Example override implementation for the complex test subplugin.
*
* @package mod_bigbluebuttonbn
* @copyright 2025 Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
*/
class navigation_override_addon implements navigation_override_addon_interface {
/**
* Overrides the settings navigation for BigBlueButtonBN.
*
* @param \settings_navigation $settingsnav The settings navigation object.
* @param \navigation_node $nodenav The current navigation node.
* @return void
*/
public function override_settings_navigation(\settings_navigation $settingsnav, \navigation_node $nodenav): void {
$nodenav->add(
get_string('settings_navigation_override', 'bbbext_complex'),
new \moodle_url('#'),
\navigation_node::TYPE_SETTING,
null,
'settings_navigation_override'
);
}
}
@@ -0,0 +1,35 @@
<?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/>.
/**
* Install script for BigBlueButton B3Dummy for Override View
*
* Documentation: {@link https://moodledev.io/docs/guides/upgrade}
*
* @package mod_bigbluebuttonbn
* @copyright 2025 Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
*/
/**
* Executed on installation of BigBlueButton B3Dummy for Override View
*
* @return bool
*/
function xmldb_bbbext_complex_install() {
set_config('disabled', 1, 'bbbext_complex');
}
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<XMLDB PATH="mod/bigbluebuttonbn/tests/fixtures/extension/complex/db" VERSION="2023020800" COMMENT="XMLDB file for bbbext_complex">
<TABLES>
<TABLE NAME="bbbext_complex" COMMENT="Default comment for bbbext_complex, please edit me">
<FIELDS>
<FIELD NAME="id" TYPE="int" LENGTH="10" NOTNULL="true" SEQUENCE="true"/>
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="id"/>
</KEYS>
</TABLE>
</TABLES>
</XMLDB>
@@ -0,0 +1,28 @@
<?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/>.
/**
* English strings for bbbext_complex subplugin
*
* @package mod_bigbluebuttonbn
* @copyright 2025 Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
*/
$string['complexsetting'] = 'Complex setting';
$string['pluginname'] = 'Complex BigBlueButtonBN Test Extension';
$string['settings_navigation_override'] = 'Override Navigation';
@@ -0,0 +1,34 @@
<?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/>.
/**
* Settings for bbbext_complex subplugin
*
* @package mod_bigbluebuttonbn
* @copyright 2025 Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
*/
defined('MOODLE_INTERNAL') || die();
// Example setting for the complex extension.
$settings->add(new admin_setting_configcheckbox(
'bbbext_complex/enabled',
get_string('pluginname', 'bbbext_complex'),
get_string('complexsetting', 'bbbext_complex'),
0
));
@@ -0,0 +1,29 @@
<?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/>.
/**
* This file contains the version information for the sample bigbluebuttonbn subplugin
*
* @package mod_bigbluebuttonbn
* @copyright 2025 Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
*/
defined('MOODLE_INTERNAL') || die();
$plugin->version = 2023020800;
$plugin->requires = 2023020300;
$plugin->component = 'bbbext_complex';
@@ -0,0 +1,48 @@
<?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_simple\bigbluebuttonbn;
use mod_bigbluebuttonbn\local\extension\navigation_append_addon as navigation_append_addon_interface;
/**
* Example append implementation for the b3dummy_append_settings_navigation subplugin.
*
* @package mod_bigbluebuttonbn
* @copyright 2025 Blindside Networks Inc
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @author Jesus Federico (jesus [at] blindsidenetworks [dt] com)
*/
class navigation_append_addon implements navigation_append_addon_interface {
/**
* Overrides the settings navigation for BigBlueButtonBN.
*
* This method replaces the default settings navigation with a custom implementation.
*
* @param \settings_navigation $settingsnav The settings navigation object.
* @param \navigation_node $nodenav The current navigation node.
* @return void
*/
public function append_settings_navigation(\settings_navigation $settingsnav, \navigation_node $nodenav): void {
$nodenav->add(
get_string('settings_navigation_append', 'bbbext_simple'),
new \moodle_url('#'),
\navigation_node::TYPE_SETTING,
null,
'settings_navigation_append'
);
}
}
@@ -30,3 +30,4 @@ $string['pluginname'] = 'Simple BigBlueButtonPlugin';
$string['completionextraisehandtwice'] = 'Raise hand twice';
$string['completionextraisehandtwice_desc'] = 'Raise hand twice in a meeting.';
$string['completionextraisehandtwice_help'] = 'Raise hand twice in a meeting.';
$string['settings_navigation_append'] = 'Append Navigation';