91334a46b5
Co-authored-by: Cursor <cursoragent@cursor.com>
257 lines
12 KiB
PHP
257 lines
12 KiB
PHP
<?php
|
||
// This file is part of Moodle - http://moodle.org/
|
||
|
||
/**
|
||
* Admin UI for voluntary MeetLet site registration (Marketplace free edition).
|
||
*
|
||
* @package mod_meetletacbfree
|
||
* @copyright 2026 MeetLet
|
||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||
*/
|
||
|
||
namespace mod_meetletacbfree\admin;
|
||
|
||
use admin_setting;
|
||
use mod_meetletacbfree\local\icons;
|
||
use mod_meetletacbfree\registration\manager;
|
||
|
||
defined('MOODLE_INTERNAL') || die();
|
||
|
||
/**
|
||
* Transparent online activation panel — no license key in this edition.
|
||
*/
|
||
class setting_registration extends admin_setting {
|
||
public function __construct() {
|
||
parent::__construct(
|
||
'meetletacbfree/registration_panel',
|
||
'',
|
||
'',
|
||
''
|
||
);
|
||
$this->nosave = true;
|
||
}
|
||
|
||
public function get_setting() {
|
||
return true;
|
||
}
|
||
|
||
public function write_setting($data) {
|
||
return '';
|
||
}
|
||
|
||
public function output_html($data, $query = '') {
|
||
global $OUTPUT, $PAGE;
|
||
|
||
$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);
|
||
|
||
$statusbadge = \html_writer::span(
|
||
s($summary['status_label'] ?? ($active
|
||
? get_string('registration_status_active', 'meetletacbfree')
|
||
: get_string('registration_status_inactive', 'meetletacbfree'))),
|
||
'badge meetlet-license-badge ' . ($active ? 'meetlet-license-badge--active' : 'meetlet-license-badge--inactive'),
|
||
['id' => 'meetlet-registration-status-badge']
|
||
);
|
||
|
||
$datalist = \html_writer::tag('ul',
|
||
\html_writer::tag('li', get_string('registration_data_item_domain', 'meetletacbfree', s($summary['domain']))) .
|
||
\html_writer::tag('li', get_string('registration_data_item_moodle', 'meetletacbfree', s($summary['moodle_release']))) .
|
||
\html_writer::tag('li', get_string('registration_data_item_plugin', 'meetletacbfree', s($summary['plugin_release']))) .
|
||
\html_writer::tag('li', get_string('registration_data_item_installation', 'meetletacbfree', s($summary['installation_id']))) .
|
||
\html_writer::tag('li', get_string('registration_data_item_sitename', 'meetletacbfree', s($summary['site_company']))) .
|
||
\html_writer::tag('li', get_string('registration_data_item_email', 'meetletacbfree',
|
||
$summary['site_admin_email'] !== '' ? s($summary['site_admin_email']) : get_string('registration_data_optional', 'meetletacbfree'))),
|
||
['class' => 'meetlet-registration-data']
|
||
);
|
||
|
||
$why = \html_writer::div(
|
||
\html_writer::tag('h4', get_string('registration_why_title', 'meetletacbfree')) .
|
||
\html_writer::tag('p', get_string('registration_why', 'meetletacbfree')),
|
||
'meetlet-guide__section'
|
||
);
|
||
$what = \html_writer::div(
|
||
\html_writer::tag('h4', get_string('registration_data_title', 'meetletacbfree')) .
|
||
\html_writer::tag('p', get_string('registration_data_sent', 'meetletacbfree')) .
|
||
$datalist .
|
||
\html_writer::tag('p',
|
||
get_string(
|
||
'registration_privacy',
|
||
'meetletacbfree',
|
||
\html_writer::link($privacytaburl, get_string('registration_privacy_tablink', 'meetletacbfree'))
|
||
),
|
||
['class' => 'mb-0']
|
||
),
|
||
'meetlet-guide__section'
|
||
);
|
||
|
||
$inactiveactions = [
|
||
'id' => 'meetlet-registration-actions-inactive',
|
||
'class' => 'meetlet-license-actions mt-3' . ($active ? ' d-none' : ''),
|
||
];
|
||
$activeactions = [
|
||
'id' => 'meetlet-registration-actions-active',
|
||
'class' => 'meetlet-license-actions mt-3' . ($active ? '' : ' d-none'),
|
||
];
|
||
|
||
$html = \html_writer::div(
|
||
$why .
|
||
$what .
|
||
\html_writer::div(
|
||
\html_writer::tag('p', get_string('registration_status_label', 'meetletacbfree') . ' ' .
|
||
\html_writer::span($statusbadge, '', ['id' => 'meetlet-registration-status-badge'])) .
|
||
\html_writer::tag('p', get_string('registration_domain', 'meetletacbfree', s($summary['domain'])), [
|
||
'id' => 'meetlet-registration-domain',
|
||
]) .
|
||
\html_writer::tag('p', get_string('registration_installation', 'meetletacbfree', s($summary['installation_id'])), [
|
||
'id' => 'meetlet-registration-installation',
|
||
]) .
|
||
\html_writer::tag('p', s($summary['product_label'] ?? ''), [
|
||
'id' => 'meetlet-registration-product',
|
||
'class' => $active ? '' : 'd-none',
|
||
]) .
|
||
\html_writer::div(
|
||
$summary['error'] ? s($summary['error']) : '',
|
||
'alert alert-danger mt-2' . (!empty($summary['error']) ? '' : ' d-none'),
|
||
['id' => 'meetlet-registration-error']
|
||
),
|
||
'meetlet-license-status mb-2'
|
||
) .
|
||
\html_writer::div(
|
||
\html_writer::tag('button',
|
||
'<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">'
|
||
. '<path fill="currentColor" d="M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z"/></svg>'
|
||
. \html_writer::span(get_string('registration_activate', 'meetletacbfree'), 'meetlet-btn-with-icon__label'),
|
||
[
|
||
'type' => 'button',
|
||
'class' => 'meetlet-settings-btn meetlet-btn-with-icon meetlet-license-btn--free',
|
||
'id' => 'meetlet-registration-activate',
|
||
'title' => get_string('registration_activate_help', 'meetletacbfree'),
|
||
]
|
||
),
|
||
'',
|
||
$inactiveactions
|
||
) .
|
||
\html_writer::div(
|
||
\html_writer::tag('button',
|
||
icons::svg('refresh')
|
||
. \html_writer::span(get_string('registration_recheck', 'meetletacbfree'), 'meetlet-btn-with-icon__label'),
|
||
[
|
||
'type' => 'button',
|
||
'class' => 'btn btn-secondary meetlet-btn-with-icon',
|
||
'id' => 'meetlet-registration-recheck',
|
||
]
|
||
) .
|
||
($candeactivate ? ' ' .
|
||
\html_writer::tag('button',
|
||
'<svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">'
|
||
. '<path fill="currentColor" d="M12 2a10 10 0 1 0 10 10h-2a8 8 0 1 1-8-8V2zm1 5v5.6l3.2 1.9-.8 1.4L11 13.2V7h2z"/></svg>'
|
||
. \html_writer::span(get_string('registration_deactivate', 'meetletacbfree'), 'meetlet-btn-with-icon__label'),
|
||
[
|
||
'type' => 'button',
|
||
'class' => 'btn btn-outline-danger meetlet-btn-with-icon',
|
||
'id' => 'meetlet-registration-deactivate',
|
||
]
|
||
) : ''),
|
||
'',
|
||
$activeactions
|
||
) .
|
||
\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'),
|
||
'data-label-domain' => get_string('registration_domain', 'meetletacbfree', '__V__'),
|
||
'data-label-installation' => get_string('registration_installation', 'meetletacbfree', '__V__'),
|
||
'data-confirm-activate-title' => get_string('registration_activate_confirm_title', 'meetletacbfree'),
|
||
'data-confirm-activate-ok' => get_string('registration_activate_confirm_ok', 'meetletacbfree'),
|
||
'data-confirm-deactivate-title' => get_string('registration_deactivate_confirm_title', 'meetletacbfree'),
|
||
'data-confirm-deactivate-ok' => get_string('registration_deactivate_confirm_ok', 'meetletacbfree'),
|
||
'data-confirm-deactivate' => get_string('registration_deactivate_confirm', 'meetletacbfree'),
|
||
'hidden' => 'hidden',
|
||
]) .
|
||
self::confirm_modal_html(),
|
||
'meetlet-registration-panel meetlet-settings-card'
|
||
);
|
||
|
||
return format_admin_setting($this, '', $html, '', true, '', null, $query);
|
||
}
|
||
|
||
protected static function confirm_modal_html(): string {
|
||
$activatebody = \html_writer::tag('p', get_string('registration_activate_confirm_lead', 'meetletacbfree'), [
|
||
'class' => 'meetlet-modal__lead',
|
||
]) .
|
||
\html_writer::tag('p', get_string('registration_activate_confirm_data', 'meetletacbfree'), [
|
||
'class' => 'meetlet-modal__keep',
|
||
]);
|
||
$deactivatebody = \html_writer::tag('p', get_string('registration_deactivate_confirm_lead', 'meetletacbfree'), [
|
||
'class' => 'meetlet-modal__lead',
|
||
]) .
|
||
\html_writer::div(
|
||
\html_writer::tag('p', get_string('registration_deactivate_confirm_warning', 'meetletacbfree'), [
|
||
'class' => 'meetlet-modal__callout-title',
|
||
]),
|
||
'meetlet-modal__callout'
|
||
);
|
||
|
||
return \html_writer::div(
|
||
\html_writer::div('', 'meetlet-modal__backdrop', ['data-meetlet-modal-dismiss' => '1']) .
|
||
\html_writer::div(
|
||
\html_writer::div(
|
||
\html_writer::tag('h3', '', [
|
||
'class' => 'meetlet-modal__title',
|
||
'id' => 'meetlet-registration-modal-title',
|
||
]) .
|
||
\html_writer::tag('button', '×', [
|
||
'type' => 'button',
|
||
'class' => 'meetlet-modal__close',
|
||
'data-meetlet-modal-dismiss' => '1',
|
||
'aria-label' => get_string('registration_modal_close', 'meetletacbfree'),
|
||
]),
|
||
'meetlet-modal__head'
|
||
) .
|
||
\html_writer::div('', 'meetlet-modal__body', ['id' => 'meetlet-registration-modal-body']) .
|
||
\html_writer::tag('template', $activatebody, ['id' => 'meetlet-registration-tpl-activate']) .
|
||
\html_writer::tag('template', $deactivatebody, ['id' => 'meetlet-registration-tpl-deactivate']) .
|
||
\html_writer::div(
|
||
\html_writer::tag('button', get_string('cancel', 'moodle'), [
|
||
'type' => 'button',
|
||
'class' => 'btn btn-secondary',
|
||
'data-meetlet-modal-dismiss' => '1',
|
||
]) .
|
||
\html_writer::tag('button', '', [
|
||
'type' => 'button',
|
||
'class' => 'btn btn-primary',
|
||
'id' => 'meetlet-registration-modal-confirm',
|
||
]),
|
||
'meetlet-modal__foot'
|
||
),
|
||
'meetlet-modal__dialog',
|
||
[
|
||
'role' => 'dialog',
|
||
'aria-modal' => 'true',
|
||
'aria-labelledby' => 'meetlet-registration-modal-title',
|
||
]
|
||
),
|
||
'meetlet-modal meetlet-modal--confirm',
|
||
[
|
||
'id' => 'meetlet-registration-modal',
|
||
'hidden' => 'hidden',
|
||
]
|
||
);
|
||
}
|
||
}
|