Address Moodle Marketplace review for mod_meetletacbfree 1.1.3.
Migrate legacy ajax/JS to external services and AMD, enable TLS verification, scope admin CSS with RTLCSS-safe rules, and fix README/lang/boilerplate gaps. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+89
@@ -0,0 +1,89 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* External: reset site role mapping or feature-access matrix to defaults.
|
||||
*
|
||||
* @package mod_meetletacbfree
|
||||
* @copyright 2026 MeetLet <info@meetlet.net>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_meetletacbfree\external;
|
||||
|
||||
use core_external\external_api;
|
||||
use core_external\external_function_parameters;
|
||||
use core_external\external_single_structure;
|
||||
use core_external\external_value;
|
||||
use mod_meetletacbfree\local\featureaccess;
|
||||
use mod_meetletacbfree\local\roles;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Ajax-capable reset of access settings defaults.
|
||||
*/
|
||||
class reset_access_settings extends external_api {
|
||||
public static function execute_parameters(): external_function_parameters {
|
||||
return new external_function_parameters([
|
||||
'section' => new external_value(PARAM_ALPHA, 'Section: rolemapping or featureaccess'),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function execute(string $section): array {
|
||||
$params = self::validate_parameters(self::execute_parameters(), ['section' => $section]);
|
||||
$context = \context_system::instance();
|
||||
self::validate_context($context);
|
||||
require_capability('moodle/site:config', $context);
|
||||
|
||||
\mod_meetletacbfree\registration\manager::require_registered();
|
||||
|
||||
if ($params['section'] === 'rolemapping') {
|
||||
$rules = roles::builtin_site_defaults();
|
||||
$json = json_encode($rules, JSON_UNESCAPED_UNICODE);
|
||||
set_config('default_participants', $json, 'meetletacbfree');
|
||||
return [
|
||||
'success' => true,
|
||||
'section' => 'rolemapping',
|
||||
'matrixjson' => json_encode(roles::matrix_from_rules($rules), JSON_UNESCAPED_UNICODE),
|
||||
'message' => get_string('reset_success_rolemapping', 'meetletacbfree'),
|
||||
];
|
||||
}
|
||||
|
||||
if ($params['section'] === 'featureaccess') {
|
||||
$matrix = featureaccess::builtin_defaults();
|
||||
$json = json_encode($matrix, JSON_UNESCAPED_UNICODE);
|
||||
set_config('featureaccess', $json, 'meetletacbfree');
|
||||
return [
|
||||
'success' => true,
|
||||
'section' => 'featureaccess',
|
||||
'matrixjson' => json_encode($matrix, JSON_UNESCAPED_UNICODE),
|
||||
'message' => get_string('reset_success_featureaccess', 'meetletacbfree'),
|
||||
];
|
||||
}
|
||||
|
||||
throw new \moodle_exception('invalidparameter');
|
||||
}
|
||||
|
||||
public static function execute_returns(): external_single_structure {
|
||||
return new external_single_structure([
|
||||
'success' => new external_value(PARAM_BOOL, 'Whether reset succeeded'),
|
||||
'section' => new external_value(PARAM_ALPHA, 'Section that was reset'),
|
||||
'matrixjson' => new external_value(PARAM_RAW, 'JSON-encoded matrix payload'),
|
||||
'message' => new external_value(PARAM_TEXT, 'Success message'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user