Adobe Connect Bridge free edition (meetletacbfree) v1.1.3
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+110
@@ -0,0 +1,110 @@
|
||||
<?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/>.
|
||||
|
||||
/**
|
||||
* Ajax: search/list existing Adobe meetings for the mod form.
|
||||
*
|
||||
* @package mod_meetletacbfree
|
||||
* @copyright 2026 MeetLet
|
||||
* @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\api\service;
|
||||
use mod_meetletacbfree\local\config;
|
||||
use moodle_exception;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Return a short list of server meetings (latest / search).
|
||||
*/
|
||||
class search_server_meetings extends external_api {
|
||||
public static function execute_parameters(): external_function_parameters {
|
||||
return new external_function_parameters([
|
||||
'query' => new external_value(PARAM_TEXT, 'Search query', VALUE_DEFAULT, ''),
|
||||
'limit' => new external_value(PARAM_INT, 'Max results', VALUE_DEFAULT, 10),
|
||||
'courseid' => new external_value(PARAM_INT, 'Course id for capability check', VALUE_DEFAULT, 0),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function execute(string $query = '', int $limit = 10, int $courseid = 0): array {
|
||||
$params = self::validate_parameters(self::execute_parameters(), [
|
||||
'query' => $query,
|
||||
'limit' => $limit,
|
||||
'courseid' => $courseid,
|
||||
]);
|
||||
|
||||
\mod_meetletacbfree\registration\manager::require_registered();
|
||||
|
||||
if (!empty($params['courseid'])) {
|
||||
$context = \context_course::instance((int)$params['courseid']);
|
||||
} else {
|
||||
$context = \context_system::instance();
|
||||
}
|
||||
self::validate_context($context);
|
||||
if (!has_capability('moodle/course:manageactivities', $context)
|
||||
&& !has_capability('mod/meetletacbfree:addinstance', $context)) {
|
||||
throw new moodle_exception('nopermissions', 'error', '', 'search meetings');
|
||||
}
|
||||
|
||||
if (!config::is_configured()) {
|
||||
throw new moodle_exception('notconfigured', 'meetletacbfree');
|
||||
}
|
||||
|
||||
$limit = max(1, min(50, (int)$params['limit']));
|
||||
$service = new service();
|
||||
$service->login_admin();
|
||||
$rows = $service->list_server_meetings((string)$params['query'], $limit);
|
||||
$service->logout();
|
||||
|
||||
$out = [];
|
||||
foreach ($rows as $m) {
|
||||
$label = $m->name;
|
||||
if (!empty($m->urlpath)) {
|
||||
$label .= ' (' . $m->urlpath . ')';
|
||||
}
|
||||
$out[] = [
|
||||
'scoid' => (int)$m->scoid,
|
||||
'name' => (string)$m->name,
|
||||
'label' => $label,
|
||||
'urlpath' => trim((string)$m->urlpath, '/'),
|
||||
'starttime' => !empty($m->datebegin) ? (int)strtotime((string)$m->datebegin) : 0,
|
||||
'endtime' => !empty($m->dateend) ? (int)strtotime((string)$m->dateend) : 0,
|
||||
];
|
||||
}
|
||||
return ['meetings' => $out];
|
||||
}
|
||||
|
||||
public static function execute_returns(): external_single_structure {
|
||||
return new external_single_structure([
|
||||
'meetings' => new external_multiple_structure(new external_single_structure([
|
||||
'scoid' => new external_value(PARAM_INT, 'SCO id'),
|
||||
'name' => new external_value(PARAM_TEXT, 'Meeting name'),
|
||||
'label' => new external_value(PARAM_TEXT, 'Select label'),
|
||||
'urlpath' => new external_value(PARAM_TEXT, 'URL path'),
|
||||
'starttime' => new external_value(PARAM_INT, 'Start unix time'),
|
||||
'endtime' => new external_value(PARAM_INT, 'End unix time'),
|
||||
])),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user