Adobe Connect Bridge free edition (meetletacbfree) v1.1.3
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+108
@@ -0,0 +1,108 @@
|
||||
<?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: rename a recording SCO.
|
||||
*
|
||||
* @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_single_structure;
|
||||
use core_external\external_value;
|
||||
use mod_meetletacbfree\api\service;
|
||||
use mod_meetletacbfree\local\instance;
|
||||
use moodle_exception;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
/**
|
||||
* Rename Adobe Connect recording.
|
||||
*/
|
||||
class rename_recording extends external_api {
|
||||
public static function execute_parameters(): external_function_parameters {
|
||||
return new external_function_parameters([
|
||||
'cmid' => new external_value(PARAM_INT, 'Course module id'),
|
||||
'recordingscoid' => new external_value(PARAM_INT, 'Recording sco id'),
|
||||
'name' => new external_value(PARAM_TEXT, 'New recording name'),
|
||||
'groupid' => new external_value(PARAM_INT, 'Group id', VALUE_DEFAULT, 0),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function execute(int $cmid, int $recordingscoid, string $name, int $groupid = 0): array {
|
||||
global $DB;
|
||||
|
||||
$params = self::validate_parameters(self::execute_parameters(), [
|
||||
'cmid' => $cmid,
|
||||
'recordingscoid' => $recordingscoid,
|
||||
'name' => $name,
|
||||
'groupid' => $groupid,
|
||||
]);
|
||||
|
||||
\mod_meetletacbfree\registration\manager::require_registered();
|
||||
|
||||
$inst = instance::get_from_cmid($params['cmid'], $params['groupid']);
|
||||
self::validate_context($inst->context);
|
||||
require_capability('mod/meetletacbfree:view', $inst->context);
|
||||
\mod_meetletacbfree\local\featureaccess::require_feature(
|
||||
\mod_meetletacbfree\local\featureaccess::EDITRECORDING,
|
||||
$inst->context,
|
||||
$inst->record
|
||||
);
|
||||
|
||||
$name = trim($params['name']);
|
||||
if ($name === '') {
|
||||
throw new moodle_exception('error', 'meetletacbfree');
|
||||
}
|
||||
|
||||
$service = new service();
|
||||
$service->login_admin();
|
||||
$ok = $service->rename_sco((int)$params['recordingscoid'], $name);
|
||||
$service->logout();
|
||||
if (!$ok) {
|
||||
throw new moodle_exception('errorrenamerecording', 'meetletacbfree');
|
||||
}
|
||||
|
||||
$record = $DB->get_record('meetletacbfree_recordings', [
|
||||
'instanceid' => $inst->record->id,
|
||||
'recordingscoid' => (int)$params['recordingscoid'],
|
||||
]);
|
||||
if ($record) {
|
||||
$record->name = $name;
|
||||
$record->timemodified = time();
|
||||
$DB->update_record('meetletacbfree_recordings', $record);
|
||||
}
|
||||
|
||||
return [
|
||||
'success' => true,
|
||||
'name' => $name,
|
||||
'message' => get_string('recordingrenamed', 'meetletacbfree'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function execute_returns(): external_single_structure {
|
||||
return new external_single_structure([
|
||||
'success' => new external_value(PARAM_BOOL, 'OK'),
|
||||
'name' => new external_value(PARAM_TEXT, 'New name'),
|
||||
'message' => new external_value(PARAM_TEXT, 'Message'),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user