mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 04:22:07 +02:00
MDL-77576 core: Register new communication sub-system
Create a new subsystem for communication and create associated experimental settings to safely use the new subsystem. Originally implemented as MDL-76699. Co-Authored-By: Huong Nguyen <huongnv13@gmail.com>
This commit is contained in:
parent
5d320dd7d1
commit
163b4134df
65
admin/communication.php
Normal file
65
admin/communication.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Communication and its plugins settings.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage communication
|
||||
* @copyright 2023 Huong Nguyen <huongnv13@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require_once($CFG->libdir . '/adminlib.php');
|
||||
|
||||
$action = required_param('action', PARAM_ALPHANUMEXT);
|
||||
$name = required_param('name', PARAM_PLUGIN);
|
||||
|
||||
$syscontext = context_system::instance();
|
||||
$PAGE->set_url('/admin/communication.php');
|
||||
$PAGE->set_context($syscontext);
|
||||
|
||||
require_admin();
|
||||
require_sesskey();
|
||||
|
||||
$return = new moodle_url('/admin/settings.php', ['section' => 'managecommunicationproviders']);
|
||||
|
||||
$plugins = core_plugin_manager::instance()->get_plugins_of_type('communication');
|
||||
$sortorder = array_flip(array_keys($plugins));
|
||||
|
||||
if (!isset($plugins[$name])) {
|
||||
throw new moodle_exception('communicationprovidernotfound', 'core_communication', $return, $name);
|
||||
}
|
||||
|
||||
$plugintypename = $plugins[$name]->type . '_' . $plugins[$name]->name;
|
||||
|
||||
switch ($action) {
|
||||
case 'disable':
|
||||
if ($plugins[$name]->is_enabled()) {
|
||||
$class = core_plugin_manager::resolve_plugininfo_class('communication');
|
||||
$class::enable_plugin($name, false);
|
||||
}
|
||||
break;
|
||||
case 'enable':
|
||||
if (!$plugins[$name]->is_enabled()) {
|
||||
$class = core_plugin_manager::resolve_plugininfo_class('communication');
|
||||
$class::enable_plugin($name, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
redirect($return);
|
@ -38,6 +38,11 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
new lang_string('enablesharingtomoodlenet', 'core_admin'),
|
||||
new lang_string('enablesharingtomoodlenet_desc', 'core_admin'), 0));
|
||||
|
||||
// New communication subsystem setting.
|
||||
$temp->add(new admin_setting_configcheckbox('enablecommunicationsubsystem',
|
||||
new lang_string('enablecommunicationsubsystem', 'core_admin'),
|
||||
new lang_string('enablecommunicationsubsystem_desc', 'core_admin'), 0));
|
||||
|
||||
$ADMIN->add('experimental', $temp);
|
||||
|
||||
// "debugging" settingpage
|
||||
|
@ -781,6 +781,20 @@ if ($hassiteconfig) {
|
||||
}
|
||||
}
|
||||
|
||||
// Communication plugins.
|
||||
if ($hassiteconfig && core_communication\api::is_available()) {
|
||||
$ADMIN->add('modules', new admin_category('communicationsettings', new lang_string('communication', 'core_communication')));
|
||||
$temp = new admin_settingpage('managecommunicationproviders',
|
||||
new lang_string('managecommunicationproviders', 'core_communication'));
|
||||
$temp->add(new \core_communication\admin\manage_communication_providers_page());
|
||||
$ADMIN->add('communicationsettings', $temp);
|
||||
$plugins = core_plugin_manager::instance()->get_plugins_of_type('communication');
|
||||
foreach ($plugins as $plugin) {
|
||||
/** @var \core\plugininfo\communication $plugin */
|
||||
$plugin->load_settings($ADMIN, 'communicationsettings', $hassiteconfig);
|
||||
}
|
||||
}
|
||||
|
||||
// Content bank content types.
|
||||
if ($hassiteconfig) {
|
||||
$ADMIN->add('modules', new admin_category('contentbanksettings', new lang_string('contentbank')));
|
||||
|
@ -0,0 +1,124 @@
|
||||
<?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 core_communication\admin;
|
||||
|
||||
use admin_setting;
|
||||
use core_plugin_manager;
|
||||
use core_text;
|
||||
use html_table;
|
||||
use html_table_row;
|
||||
use html_writer;
|
||||
use moodle_url;
|
||||
|
||||
/**
|
||||
* Communication providers manager. Allow enable/disable communication providers and jump to settings.
|
||||
*
|
||||
* @package core_communication
|
||||
* @copyright 2023 Huong Nguyen <huongnv13@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class manage_communication_providers_page extends admin_setting {
|
||||
|
||||
public function __construct() {
|
||||
$this->nosave = true;
|
||||
parent::__construct('managecommunications',
|
||||
new \lang_string('managecommunicationproviders', 'core_communication'), '', '');
|
||||
}
|
||||
|
||||
public function get_setting(): bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
public function write_setting($data): string {
|
||||
// Do not write any setting.
|
||||
return '';
|
||||
}
|
||||
|
||||
public function output_html($data, $query = ''): string {
|
||||
global $OUTPUT;
|
||||
|
||||
$pluginmanager = core_plugin_manager::instance();
|
||||
$plugins = $pluginmanager->get_plugins_of_type('communication');
|
||||
if (empty($plugins)) {
|
||||
return get_string('nocommunicationprovider', 'core_communication');
|
||||
}
|
||||
|
||||
$table = new html_table();
|
||||
$table->head = [
|
||||
get_string('name'),
|
||||
get_string('enable'),
|
||||
get_string('settings'),
|
||||
get_string('uninstallplugin', 'core_admin'),
|
||||
];
|
||||
$table->align = ['left', 'center', 'center', 'center'];
|
||||
$table->attributes['class'] = 'managecommunicationtable generaltable admintable';
|
||||
$table->data = [];
|
||||
|
||||
foreach ($plugins as $plugin) {
|
||||
$class = '';
|
||||
$actionurl = new moodle_url('/admin/communication.php', ['sesskey' => sesskey(), 'name' => $plugin->name]);
|
||||
if ($pluginmanager->get_plugin_info('communication_' . $plugin->name)->get_status() ===
|
||||
core_plugin_manager::PLUGIN_STATUS_MISSING) {
|
||||
$strtypename = $plugin->displayname . ' (' . get_string('missingfromdisk') . ')';
|
||||
} else {
|
||||
$strtypename = $plugin->displayname;
|
||||
}
|
||||
|
||||
if ($plugin->is_enabled()) {
|
||||
$hideshow = html_writer::link($actionurl->out(false, ['action' => 'disable']),
|
||||
$OUTPUT->pix_icon('t/hide', get_string('disable'), 'moodle', ['class' => 'iconsmall']));
|
||||
} else {
|
||||
$class = 'dimmed_text';
|
||||
$hideshow = html_writer::link($actionurl->out(false, ['action' => 'enable']),
|
||||
$OUTPUT->pix_icon('t/show', get_string('enable'), 'moodle', ['class' => 'iconsmall']));
|
||||
}
|
||||
|
||||
$settings = '';
|
||||
if ($plugin->get_settings_url()) {
|
||||
$settings = html_writer::link($plugin->get_settings_url(), get_string('settings'));
|
||||
}
|
||||
|
||||
$uninstall = '';
|
||||
if ($uninstallurl = core_plugin_manager::instance()->get_uninstall_url(
|
||||
'communication_' . $plugin->name, 'manage')) {
|
||||
$uninstall = html_writer::link($uninstallurl, get_string('uninstallplugin', 'core_admin'));
|
||||
}
|
||||
|
||||
$row = new html_table_row([$strtypename, $hideshow, $settings, $uninstall]);
|
||||
if ($class) {
|
||||
$row->attributes['class'] = $class;
|
||||
}
|
||||
$table->data[] = $row;
|
||||
}
|
||||
|
||||
return highlight($query, html_writer::table($table));
|
||||
}
|
||||
|
||||
public function is_related($query): bool {
|
||||
if (parent::is_related($query)) {
|
||||
return true;
|
||||
}
|
||||
$types = core_plugin_manager::instance()->get_plugins_of_type('communication');
|
||||
foreach ($types as $type) {
|
||||
if (strpos($type->component, $query) !== false ||
|
||||
strpos(core_text::strtolower($type->displayname), $query) !== false) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
39
communication/classes/privacy/provider.php
Normal file
39
communication/classes/privacy/provider.php
Normal file
@ -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 core_communication\privacy;
|
||||
|
||||
use core_privacy\local\metadata\null_provider;
|
||||
|
||||
/**
|
||||
* Privacy Subsystem for core_communication implementing null_provider.
|
||||
*
|
||||
* @package core_communication
|
||||
* @copyright 2023 Huong Nguyen <huongnv13@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class provider implements null_provider {
|
||||
|
||||
/**
|
||||
* Get the language string identifier with the component's language
|
||||
* file to explain why this plugin stores no data.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_reason(): string {
|
||||
return 'privacy:metadata';
|
||||
}
|
||||
}
|
@ -589,6 +589,8 @@ $string['enableanalytics'] = 'Analytics';
|
||||
$string['enableblogs'] = 'Enable blogs';
|
||||
$string['enablecalendarexport'] = 'Enable calendar export';
|
||||
$string['enablecomments'] = 'Enable comments';
|
||||
$string['enablecommunicationsubsystem'] = 'Enable communication subsystem';
|
||||
$string['enablecommunicationsubsystem_desc'] = 'This setting enables the new communication subsystem. This new subsystem allow teachers and students to more easily communicate while using Moodle for teaching and learning';
|
||||
$string['enablecourserelativedates'] = 'Enable course relative dates';
|
||||
$string['enablecourserelativedates_desc'] = 'Allow courses to be set up to display dates relative to the user\'s start date in the course.';
|
||||
$string['enablecourserequests'] = 'Enable course requests';
|
||||
|
29
lang/en/communication.php
Normal file
29
lang/en/communication.php
Normal file
@ -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/>.
|
||||
|
||||
/**
|
||||
* Strings for component 'communication', language 'en'.
|
||||
*
|
||||
* @package core_communication
|
||||
* @copyright 2022 Huong Nguyen <huongnv13@gmail.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
$string['communication'] = 'Communication';
|
||||
$string['communicationprovidernotfound'] = 'The \'{$a}\' communication provider doesn\'t exist or is not recognised.';
|
||||
$string['managecommunicationproviders'] = 'Manage communication providers';
|
||||
$string['nocommunicationprovider'] = 'No communication provider found.';
|
||||
$string['privacy:metadata'] = 'The Moodle communication subsystem does not store any personal data.';
|
@ -1825,6 +1825,8 @@ class core_plugin_manager {
|
||||
'gregorian'
|
||||
),
|
||||
|
||||
'communication' => [],
|
||||
|
||||
'contenttype' => array(
|
||||
'h5p'
|
||||
),
|
||||
|
@ -59,6 +59,7 @@
|
||||
"calendar": "calendar",
|
||||
"cohort": "cohort",
|
||||
"comment": "comment",
|
||||
"communication": "communication",
|
||||
"competency": "competency",
|
||||
"completion": "completion",
|
||||
"contentbank": "contentbank",
|
||||
|
@ -31,7 +31,7 @@ class component_test extends advanced_testcase {
|
||||
* this is defined here to annoy devs that try to add more without any thinking,
|
||||
* always verify that it does not collide with any existing add-on modules and subplugins!!!
|
||||
*/
|
||||
const SUBSYSTEMCOUNT = 76;
|
||||
const SUBSYSTEMCOUNT = 77;
|
||||
|
||||
public function setUp(): void {
|
||||
$psr0namespaces = new ReflectionProperty('core_component', 'psr0namespaces');
|
||||
|
Loading…
x
Reference in New Issue
Block a user