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:
2026-09-20 12:41:47 +03:30
parent 91334a46b5
commit be252e49e2
33 changed files with 1281 additions and 1023 deletions
+1 -4
View File
@@ -25,7 +25,6 @@
namespace mod_meetletacbfree\admin;
use mod_meetletacbfree\local\icons;
use moodle_url;
defined('MOODLE_INTERNAL') || die();
@@ -65,7 +64,7 @@ class access_reset_ui {
/**
* Modal + config root (render once on the access settings tab).
*/
public static function page_assets(moodle_url $ajaxurl): string {
public static function page_assets(): string {
if (self::$assetsrendered) {
return '';
}
@@ -75,8 +74,6 @@ class access_reset_ui {
$html = \html_writer::div('', '', [
'id' => 'meetlet-access-reset-root',
'hidden' => 'hidden',
'data-endpoint' => $ajaxurl->out(false),
'data-sesskey' => sesskey(),
'data-strings' => json_encode($strings, JSON_UNESCAPED_UNICODE),
]);
$html .= self::modal_html();
+2 -11
View File
@@ -45,16 +45,9 @@ class setting_registration extends admin_setting {
$summary = manager::status_summary();
$active = !empty($summary['active']);
$candeactivate = !empty($summary['can_deactivate']);
$ajaxurl = new \moodle_url('/mod/meetletacbfree/ajax/registration.php');
$scrolljsurl = new \moodle_url('/mod/meetletacbfree/javascript/meetlet_modal_scroll.js', [
'v' => '2026090146',
]);
$jsurl = new \moodle_url('/mod/meetletacbfree/javascript/settings_registration.js', [
'v' => '2026090146',
]);
$privacytaburl = manager::privacy_tab_url();
$PAGE->requires->js($scrolljsurl);
$PAGE->requires->js($jsurl);
$PAGE->requires->js_call_amd('mod_meetletacbfree/meetlet_modal_scroll', 'init');
$PAGE->requires->js_call_amd('mod_meetletacbfree/settings_registration', 'init');
$statusbadge = \html_writer::span(
s($summary['status_label'] ?? ($active
@@ -169,8 +162,6 @@ class setting_registration extends admin_setting {
\html_writer::div('', 'mt-3 d-none', ['id' => 'meetlet-registration-flash']) .
\html_writer::div('', '', [
'id' => 'meetlet-registration-config',
'data-ajaxurl' => $ajaxurl->out(false),
'data-sesskey' => sesskey(),
'data-api-input' => 'id_s_meetletacbfree_registration_api_url',
'data-label-active' => get_string('registration_status_active', 'meetletacbfree'),
'data-label-inactive' => get_string('registration_status_inactive', 'meetletacbfree'),
+17 -1
View File
@@ -44,6 +44,22 @@ class settingspage_tabs extends \theme_boost_admin_settingspage_tabs {
* @return string
*/
public function output_html() {
return $this->herohtml . parent::output_html();
global $PAGE;
if ($PAGE) {
$PAGE->requires->js_call_amd('mod_meetletacbfree/meetlet_modal_scroll', 'init');
$PAGE->requires->js_call_amd('mod_meetletacbfree/settings_registration', 'init');
$PAGE->requires->js_call_amd('mod_meetletacbfree/settings_conntest', 'init');
$PAGE->requires->js_call_amd('mod_meetletacbfree/settings_toggles', 'init');
$PAGE->requires->js_call_amd('mod_meetletacbfree/featureaccess_matrix', 'init');
$PAGE->requires->js_call_amd('mod_meetletacbfree/settings_access_reset', 'init');
}
// Scope MeetLet admin CSS under this root (Marketplace CSS guideline).
// dir attribute is not processed by Moodle RTLCSS (unlike styles.css values).
$attrs = right_to_left() ? ['dir' => 'rtl'] : [];
return \html_writer::div(
$this->herohtml . parent::output_html(),
'meetlet-admin-settings',
$attrs
);
}
}
+2 -2
View File
@@ -213,7 +213,7 @@ class client {
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
}
if ($this->https) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
}
if (!empty($CFG->proxyhost)) {
@@ -363,7 +363,7 @@ class client {
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
}
if ($this->https) {
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
}
if (!empty($CFG->proxyhost)) {
+2 -1
View File
@@ -1386,7 +1386,8 @@ class service {
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HEADER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_TIMEOUT => 12,
CURLOPT_COOKIE => $cookie !== '' ? ('BREEZESESSION=' . $cookie) : '',
]);
+124
View File
@@ -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
View File
@@ -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
View File
@@ -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,
[]
),
]);
}
}
+2 -1
View File
@@ -161,7 +161,8 @@ class content {
curl_setopt_array($ch, [
CURLOPT_FILE => $fp,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_SSL_VERIFYHOST => 2,
CURLOPT_TIMEOUT => 300,
CURLOPT_COOKIE => $session !== '' ? ('BREEZESESSION=' . $session) : '',
]);
@@ -1,11 +1,24 @@
<?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/>.
/**
* Structured registration API / local client exception.
*
* @package mod_meetletacbfree
* @copyright 2026 MeetLet
* @copyright 2026 MeetLet <info@meetlet.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/