91334a46b5
Co-authored-by: Cursor <cursoragent@cursor.com>
89 lines
3.1 KiB
PHP
89 lines
3.1 KiB
PHP
<?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/>.
|
|
|
|
/**
|
|
* Admin setting: default Moodle role → Adobe Connect role mapping.
|
|
*
|
|
* @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\admin;
|
|
|
|
use admin_setting;
|
|
use mod_meetletacbfree\local\roles;
|
|
|
|
defined('MOODLE_INTERNAL') || die();
|
|
|
|
/**
|
|
* Stores default participant rules JSON used for new activities / empty lists.
|
|
*/
|
|
class setting_rolemapping extends admin_setting {
|
|
public function __construct() {
|
|
parent::__construct(
|
|
'meetletacbfree/default_participants',
|
|
get_string('siterolemapping', 'meetletacbfree'),
|
|
get_string('siterolemapping_desc', 'meetletacbfree'),
|
|
json_encode(roles::builtin_site_defaults(), JSON_UNESCAPED_UNICODE)
|
|
);
|
|
}
|
|
|
|
public function get_setting() {
|
|
return $this->config_read($this->name);
|
|
}
|
|
|
|
public function write_setting($data) {
|
|
if (!is_array($data)) {
|
|
$data = [];
|
|
}
|
|
$json = roles::rules_json_from_matrix_post($data);
|
|
return $this->config_write($this->name, $json) ? '' : get_string('errorsetting', 'admin');
|
|
}
|
|
|
|
public function output_html($data, $query = '') {
|
|
$rules = roles::builtin_site_defaults();
|
|
if (is_string($data) && $data !== '') {
|
|
$decoded = json_decode($data, true);
|
|
if (is_array($decoded) && !empty($decoded)) {
|
|
$rules = roles::normalize_rules($decoded);
|
|
}
|
|
} else if (is_array($data) && !empty($data) && isset($data[0]) && is_array($data[0])) {
|
|
$rules = roles::normalize_rules($data);
|
|
} else if (is_array($data) && !empty($data)) {
|
|
// Posted radio matrix already (preview / validation).
|
|
$json = roles::rules_json_from_matrix_post($data);
|
|
$decoded = json_decode($json, true);
|
|
if (is_array($decoded)) {
|
|
$rules = roles::normalize_rules($decoded);
|
|
}
|
|
}
|
|
|
|
$html = access_reset_ui::toolbar('rolemapping');
|
|
$html .= roles::render_site_mapping_html($rules, $this->get_full_name());
|
|
return format_admin_setting(
|
|
$this,
|
|
$this->visiblename,
|
|
$html,
|
|
$this->description,
|
|
true,
|
|
'',
|
|
get_string('siterolemapping_defaultinfo', 'meetletacbfree'),
|
|
$query
|
|
);
|
|
}
|
|
}
|