Skip to content

Commit

Permalink
Moved recordings name update to upgrade.php
Browse files Browse the repository at this point in the history
  • Loading branch information
cebounph committed Apr 18, 2024
2 parents 0dd7ed9 + bfaf268 commit 88453f5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 38 deletions.
42 changes: 7 additions & 35 deletions classes/task/get_meeting_recordings.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,6 @@ public function execute() {

mtrace('Finding meeting recordings for this account...');

$recordingtypestrings = [
'active_speaker' => get_string('recordingtype_active_speaker', 'mod_zoom'),
'audio_interpretation' => get_string('recordingtype_audio_interpretation', 'mod_zoom'),
'audio_only' => get_string('recordingtype_audio_only', 'mod_zoom'),
'audio_transcript' => get_string('recordingtype_audio_transcript', 'mod_zoom'),
'chat_file' => get_string('recordingtype_chat', 'mod_zoom'),
'closed_caption' => get_string('recordingtype_closed_caption', 'mod_zoom'),
'gallery_view' => get_string('recordingtype_gallery', 'mod_zoom'),
'poll' => get_string('recordingtype_poll', 'mod_zoom'),
'production_studio' => get_string('recordingtype_production_studio', 'mod_zoom'),
'shared_screen' => get_string('recordingtype_shared', 'mod_zoom'),
'shared_screen_with_gallery_view' => get_string('recordingtype_shared_gallery', 'mod_zoom'),
'shared_screen_with_speaker_view' => get_string('recordingtype_shared_speaker', 'mod_zoom'),
'shared_screen_with_speaker_view(CC)' => get_string('recordingtype_shared_speaker_cc', 'mod_zoom'),
'sign_interpretation' => get_string('recordingtype_sign', 'mod_zoom'),
'speaker_view' => get_string('recordingtype_speaker', 'mod_zoom'),
'summary' => get_string('recordingtype_summary', 'mod_zoom'),
'summary_next_steps' => get_string('recordingtype_summary_next_steps', 'mod_zoom'),
'summary_smart_chapters' => get_string('recordingtype_summary_smart_chapters', 'mod_zoom'),
'timeline' => get_string('recordingtype_timeline', 'mod_zoom'),
];

$localmeetings = zoom_get_all_meeting_records();

$now = time();
Expand Down Expand Up @@ -126,22 +104,19 @@ public function execute() {
$zoomrecordings = $service->get_user_recordings($hostid, $from, $to);

foreach ($zoomrecordings as $recordingid => $recording) {
if (isset($localrecordings[$recording->meetinguuid][$recordingid])) {
mtrace('Recording id: ' . $recordingid . ' exists...verifying current data.');
if ($localrecordings[$recording->meetinguuid][$recordingid]->name != $meetings[$recording->meetingid]->name) {
$updatemeeting = $localrecordings[$recording->meetinguuid][$recordingid];
$updatemeeting->name = $meetings[$recording->meetingid]->name;
$DB->update_record('zoom_meeting_recordings', $updatemeeting);
}
continue;
}

if (empty($meetings[$recording->meetingid])) {
// Skip meetings that are not in Moodle.
mtrace('Meeting id: ' . $recording->meetingid . ' does not exist...skipping');
continue;
}

$zoom = $meetings[$recording->meetingid];

if (isset($localrecordings[$recording->meetinguuid][$recordingid])) {
mtrace('Recording id: ' . $recordingid . ' exists...skipping');
continue;
}

// As of 2023-09-24, 'password' is not present in the user recordings API response.
if (empty($meetingpasscodes[$recording->meetinguuid])) {
try {
Expand All @@ -152,10 +127,7 @@ public function execute() {
}
}

$zoom = $meetings[$recording->meetingid];

$recordingtype = $recording->recordingtype;
$recordingtypestring = $recordingtypestrings[$recordingtype];

$record = new stdClass();
$record->zoomid = $zoom->id;
Expand Down
7 changes: 4 additions & 3 deletions classes/webservice.php
Original file line number Diff line number Diff line change
Expand Up @@ -1005,11 +1005,12 @@ public function get_recording_url_list($meetingid) {

if (!empty($response->recording_files)) {
foreach ($response->recording_files as $recording) {
if (!empty($recording->play_url) && isset($allowedrecordingtypes[$recording->file_type])) {
$url = $recording->play_url ?? $recording->download_url ?? null;
if (!empty($url) && isset($allowedrecordingtypes[$recording->file_type])) {
$recordinginfo = new stdClass();
$recordinginfo->recordingid = $recording->id;
$recordinginfo->meetinguuid = $response->uuid;
$recordinginfo->url = $recording->play_url;
$recordinginfo->url = $url;
$recordinginfo->filetype = $recording->file_type;
$recordinginfo->recordingtype = $recording->recording_type;
$recordinginfo->passcode = $response->password;
Expand Down Expand Up @@ -1062,7 +1063,7 @@ public function get_user_recordings($userid, $from, $to) {
$recordinginfo->recordingid = $recording->id;
$recordinginfo->meetingid = $meeting->id;
$recordinginfo->meetinguuid = $meeting->uuid;
$recordinginfo->url = $recording->play_url;
$recordinginfo->url = $url;
$recordinginfo->filetype = $recording->file_type;
$recordinginfo->recordingtype = $recording->recording_type;
$recordinginfo->recordingstart = strtotime($recording->recording_start);
Expand Down
17 changes: 17 additions & 0 deletions db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -965,5 +965,22 @@ function xmldb_zoom_upgrade($oldversion) {
upgrade_mod_savepoint(true, 2024030100, 'zoom');
}

if ($oldversion < 2024030101) {

// Update existing recording names to default for translatable recordingtype strings.
$meetings = $DB->get_records('zoom');

foreach ($meetings as $meeting) {
var_dump($meeting);
$value = $meeting->name;
$select = "zoomid = ". $meeting->id;

$DB->set_field_select('zoom_meeting_recordings', 'name', $value, $select);
}

// Zoom savepoint reached.
upgrade_mod_savepoint(true, 2024030101, 'zoom');
}

return true;
}
7 changes: 7 additions & 0 deletions recordings.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@
}
}

/**
* Get the display name for a Zoom recording type.
*
* @package mod_zoom
* @param string $recordingtype Zoom recording type.
* @return string
*/
function zoom_get_recording_type_string($recordingtype) {
$recordingtypestringmap = [
'active_speaker' => 'recordingtype_active_speaker',
Expand Down

0 comments on commit 88453f5

Please sign in to comment.