91334a46b5
Co-authored-by: Cursor <cursoragent@cursor.com>
128 lines
4.3 KiB
PHP
128 lines
4.3 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/>.
|
|
|
|
/**
|
|
* Recording list sync (community edition — no offline MP4 / agent).
|
|
*
|
|
* @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\local;
|
|
|
|
use mod_meetletacbfree\api\service;
|
|
use stdClass;
|
|
|
|
defined('MOODLE_INTERNAL') || die();
|
|
|
|
class recordings {
|
|
public static function for_tab(instance $instance): array {
|
|
self::sync($instance);
|
|
return self::load_local($instance);
|
|
}
|
|
|
|
public static function sync(instance $instance, ?service $service = null): array {
|
|
global $DB;
|
|
|
|
$ownsclient = false;
|
|
if ($service === null) {
|
|
$service = new service();
|
|
$service->login_admin();
|
|
$ownsclient = true;
|
|
}
|
|
|
|
$scoid = $instance->meetingscoid();
|
|
if (!$scoid) {
|
|
if ($ownsclient) {
|
|
$service->logout();
|
|
}
|
|
return [];
|
|
}
|
|
|
|
$remote = $service->list_recordings($scoid);
|
|
$now = time();
|
|
$out = [];
|
|
|
|
foreach ($remote as $rec) {
|
|
$record = $DB->get_record('meetletacbfree_recordings', [
|
|
'instanceid' => $instance->record->id,
|
|
'recordingscoid' => $rec->scoid,
|
|
]);
|
|
|
|
$zipurl = service::zip_url($rec->urlpath);
|
|
|
|
if (!$record) {
|
|
$record = new stdClass();
|
|
$record->instanceid = $instance->record->id;
|
|
$record->meetingscoid = $scoid;
|
|
$record->recordingscoid = $rec->scoid;
|
|
$record->name = $rec->name;
|
|
$record->urlpath = $rec->urlpath;
|
|
$record->zipurl = $zipurl;
|
|
$record->duration = $rec->duration;
|
|
$record->timestart = $rec->datebegin ? strtotime($rec->datebegin) : 0;
|
|
$record->timeend = $rec->dateend ? strtotime($rec->dateend) : 0;
|
|
$record->timemodified = $now;
|
|
$record->id = $DB->insert_record('meetletacbfree_recordings', $record);
|
|
} else {
|
|
$record->name = $rec->name;
|
|
$record->urlpath = $rec->urlpath;
|
|
$record->zipurl = $zipurl;
|
|
$record->duration = $rec->duration;
|
|
$record->timestart = $rec->datebegin ? strtotime($rec->datebegin) : 0;
|
|
$record->timeend = $rec->dateend ? strtotime($rec->dateend) : 0;
|
|
$record->timemodified = $now;
|
|
$DB->update_record('meetletacbfree_recordings', $record);
|
|
}
|
|
|
|
$record->playurl = config::public_url($rec->urlpath);
|
|
$record->editurl = config::recording_editor_url($rec->urlpath);
|
|
$out[] = $record;
|
|
}
|
|
|
|
if ($ownsclient) {
|
|
$service->logout();
|
|
}
|
|
return $out;
|
|
}
|
|
|
|
public static function load_local(instance $instance): array {
|
|
global $DB;
|
|
|
|
$rows = $DB->get_records(
|
|
'meetletacbfree_recordings',
|
|
['instanceid' => $instance->record->id],
|
|
'timestart DESC, id DESC'
|
|
);
|
|
foreach ($rows as $record) {
|
|
$record->playurl = config::public_url((string)$record->urlpath);
|
|
$record->editurl = config::recording_editor_url((string)$record->urlpath);
|
|
$record->mp4ready = false;
|
|
$record->mp4url = '';
|
|
}
|
|
return $rows;
|
|
}
|
|
|
|
public static function jobstatus_label(string $status, bool $mp4ready = false): string {
|
|
return $status !== '' ? $status : '—';
|
|
}
|
|
|
|
public static function job_is_busy(string $status): bool {
|
|
return false;
|
|
}
|
|
}
|