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:
+124
@@ -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/>.
|
||||
|
||||
/**
|
||||
* External: activate / recheck / deactivate MeetLet site registration.
|
||||
*
|
||||
* @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\registration\error_mapper;
|
||||
use mod_meetletacbfree\registration\manager;
|
||||
use mod_meetletacbfree\registration\registration_exception;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Ajax-capable registration actions for admin settings.
|
||||
*/
|
||||
class registration_action extends external_api {
|
||||
public static function execute_parameters(): external_function_parameters {
|
||||
return new external_function_parameters([
|
||||
'action' => new external_value(PARAM_ALPHA, 'activate|recheck|deactivate|status'),
|
||||
'registration_api_url' => new external_value(PARAM_URL, 'Optional API base URL', VALUE_DEFAULT, ''),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function execute(string $action, string $registrationapiurl = ''): array {
|
||||
$params = self::validate_parameters(self::execute_parameters(), [
|
||||
'action' => $action,
|
||||
'registration_api_url' => $registrationapiurl,
|
||||
]);
|
||||
|
||||
$context = \context_system::instance();
|
||||
self::validate_context($context);
|
||||
require_capability('moodle/site:config', $context);
|
||||
|
||||
try {
|
||||
if ($params['registration_api_url'] !== '') {
|
||||
set_config(manager::CONFIG_API_URL, rtrim($params['registration_api_url'], '/'), 'meetletacbfree');
|
||||
}
|
||||
|
||||
$message = '';
|
||||
if ($params['action'] === 'activate') {
|
||||
manager::activate();
|
||||
$message = get_string('registration_activated', 'meetletacbfree');
|
||||
} else if (in_array($params['action'], ['recheck', 'refresh', 'validate'], true)) {
|
||||
manager::recheck(true);
|
||||
$message = get_string('registration_rechecked', 'meetletacbfree');
|
||||
} else if ($params['action'] === 'deactivate') {
|
||||
manager::deactivate();
|
||||
$message = get_string('registration_deactivated', 'meetletacbfree');
|
||||
} else if ($params['action'] === 'status') {
|
||||
$message = '';
|
||||
} else {
|
||||
throw new \moodle_exception('invalidparameter');
|
||||
}
|
||||
|
||||
return self::pack_response(true, $message, '');
|
||||
} catch (\Throwable $e) {
|
||||
$ex = registration_exception::from_throwable($e);
|
||||
$mapped = error_mapper::from_exception($ex);
|
||||
return self::pack_response(
|
||||
false,
|
||||
'',
|
||||
(string)($mapped['message'] ?? $ex->get_api_message())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,mixed>
|
||||
*/
|
||||
protected static function pack_response(bool $success, string $message, string $error): array {
|
||||
$summary = manager::status_summary();
|
||||
return [
|
||||
'success' => $success,
|
||||
'message' => $message,
|
||||
'error' => $error,
|
||||
'active' => !empty($summary['active']),
|
||||
'status' => (string)($summary['status'] ?? ''),
|
||||
'status_label' => (string)($summary['status_label'] ?? ''),
|
||||
'product_label' => (string)($summary['product_label'] ?? ''),
|
||||
'domain' => (string)($summary['domain'] ?? ''),
|
||||
'installation_id' => (string)($summary['installation_id'] ?? ''),
|
||||
'can_deactivate' => !empty($summary['can_deactivate']),
|
||||
];
|
||||
}
|
||||
|
||||
public static function execute_returns(): external_single_structure {
|
||||
return new external_single_structure([
|
||||
'success' => new external_value(PARAM_BOOL, 'Whether the action succeeded'),
|
||||
'message' => new external_value(PARAM_TEXT, 'Success message'),
|
||||
'error' => new external_value(PARAM_TEXT, 'Error message when unsuccessful'),
|
||||
'active' => new external_value(PARAM_BOOL, 'Whether activation is active'),
|
||||
'status' => new external_value(PARAM_ALPHANUMEXT, 'Raw status code'),
|
||||
'status_label' => new external_value(PARAM_TEXT, 'Human status label'),
|
||||
'product_label' => new external_value(PARAM_TEXT, 'Product label'),
|
||||
'domain' => new external_value(PARAM_TEXT, 'Site domain'),
|
||||
'installation_id' => new external_value(PARAM_TEXT, 'Installation id'),
|
||||
'can_deactivate' => new external_value(PARAM_BOOL, 'Whether deactivate is allowed'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+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'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
<?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: run one Adobe Connect connection-test step.
|
||||
*
|
||||
* @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_multiple_structure;
|
||||
use core_external\external_single_structure;
|
||||
use core_external\external_value;
|
||||
use mod_meetletacbfree\local\conntest_runner;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Ajax-capable connection test step runner for admin settings.
|
||||
*/
|
||||
class run_conntest_step extends external_api {
|
||||
public static function execute_parameters(): external_function_parameters {
|
||||
return new external_function_parameters([
|
||||
'step' => new external_value(PARAM_ALPHA, 'Connection test step name'),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function execute(string $step): array {
|
||||
$params = self::validate_parameters(self::execute_parameters(), ['step' => $step]);
|
||||
$context = \context_system::instance();
|
||||
self::validate_context($context);
|
||||
require_capability('moodle/site:config', $context);
|
||||
|
||||
\mod_meetletacbfree\registration\manager::require_registered();
|
||||
|
||||
$result = conntest_runner::run_step($params['step']);
|
||||
$subresults = [];
|
||||
if (!empty($result['subresults']) && is_array($result['subresults'])) {
|
||||
foreach ($result['subresults'] as $sub) {
|
||||
$subresults[] = [
|
||||
'label' => (string)($sub['label'] ?? ''),
|
||||
'ok' => !empty($sub['ok']),
|
||||
'detail' => (string)($sub['detail'] ?? ''),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'step' => (string)($result['step'] ?? $params['step']),
|
||||
'label' => (string)($result['label'] ?? ''),
|
||||
'ok' => !empty($result['ok']),
|
||||
'detail' => (string)($result['detail'] ?? ''),
|
||||
'done' => !empty($result['done']),
|
||||
'abort' => !empty($result['abort']),
|
||||
'subresults' => $subresults,
|
||||
];
|
||||
}
|
||||
|
||||
public static function execute_returns(): external_single_structure {
|
||||
return new external_single_structure([
|
||||
'step' => new external_value(PARAM_ALPHANUMEXT, 'Step id'),
|
||||
'label' => new external_value(PARAM_TEXT, 'Step label'),
|
||||
'ok' => new external_value(PARAM_BOOL, 'Whether the step passed'),
|
||||
'detail' => new external_value(PARAM_RAW, 'Detail message'),
|
||||
'done' => new external_value(PARAM_BOOL, 'Whether the run is finished'),
|
||||
'abort' => new external_value(PARAM_BOOL, 'Whether remaining steps should abort'),
|
||||
'subresults' => new external_multiple_structure(
|
||||
new external_single_structure([
|
||||
'label' => new external_value(PARAM_TEXT, 'Sub-step label'),
|
||||
'ok' => new external_value(PARAM_BOOL, 'Sub-step ok'),
|
||||
'detail' => new external_value(PARAM_RAW, 'Sub-step detail'),
|
||||
]),
|
||||
'Optional nested results',
|
||||
VALUE_DEFAULT,
|
||||
[]
|
||||
),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user