27 if (!Loader::includeModule(
'socialservices'))
29 return $result->addError(
new Error(
'Module socialservices is not installed.'));
32 $meetingResult = ZoomMeetingTable::getById($conferenceId);
34 if ($meetingData = $meetingResult->fetch())
36 $recordingsResult = ZoomMeetingRecordingTable::getList([
39 '=MEETING_ID' => $meetingData[
'ID'],
45 $currentStartDate =
'';
46 while ($recording = $recordingsResult->fetch())
48 if ($currentStartDate != $recording[
'START_DATE']->format(DATE_ATOM))
50 $currentStartDate = $recording[
'START_DATE']->format(DATE_ATOM);
51 $allRecordings[$currentStartDate] = [];
53 $recording[
'LENGTH'] = static::getRecordingLength($recording[
'START_DATE'], $recording[
'END_DATE']);
54 $recording[
'LENGTH_FORMATTED'] = static::formatLength($recording[
'LENGTH']);
55 $recording[
'LENGTH_HUMAN'] = static::formatLength($recording[
'LENGTH'], static::LENGTH_FORMAT_FULL);
57 $recording[
'END_DATE_TS'] = $recording[
'END_DATE']->getTimestamp();
59 if ($recording[
'FILE_ID'] > 0 && Loader::includeModule(
'disk') && $file = \
Bitrix\Disk\File::loadById($recording[
'FILE_ID']))
61 $recording[
'DOWNLOAD_URL'] = \Bitrix\Disk\Driver::getInstance()->getUrlManager()->getUrlForDownloadFile($file,
true);
65 $parsedDownloadUrl =
new Uri($recording[
'DOWNLOAD_URL']);
66 $recording[
'DOWNLOAD_URL'] = $parsedDownloadUrl->addParams([
'access_token' => $recording[
'DOWNLOAD_TOKEN']])->__toString();
68 $allRecordings[$currentStartDate][static::getRecordingKind($recording[
'FILE_TYPE'])] = $recording;
71 if (!empty($allRecordings))
73 $result->setData(array_values($allRecordings));
102 public static function formatLength(
int $lengthSeconds, $format = self::LENGTH_FORMAT_SHORT): string
104 $hours = intdiv($lengthSeconds, 3600);
105 $lengthSeconds -= $hours * 3600;
106 $minutes = intdiv($lengthSeconds, 60);
107 $seconds = $lengthSeconds - $minutes * 60;
109 if ($format === self::LENGTH_FORMAT_FULL)
113 $result =
Loc::getMessage(
"CRM_ZOOM_CONFERENCE_HOUR_F" . static::getNumericSuffix($hours), [
"#VALUE#" => $hours]) .
" ";
119 $result .=
Loc::getMessage(
"CRM_ZOOM_CONFERENCE_MINUTE_F" . static::getNumericSuffix($minutes), [
"#VALUE#" => $minutes]) .
" ";
120 $result .=
Loc::getMessage(
"CRM_ZOOM_CONFERENCE_SECOND_F" . static::getNumericSuffix($seconds), [
"#VALUE#" => $seconds]);
124 $result = $hours ? str_pad($hours, 2,
"0", STR_PAD_LEFT) .
":" :
"";
125 $minutes = str_pad($minutes, 2,
"0", STR_PAD_LEFT);
126 $seconds = str_pad($seconds, 2,
"0", STR_PAD_LEFT);
127 $result .=
"$minutes:$seconds";
143 if (!Loader::includeModule(
'socialservices'))
145 return $result->addError(
new Error(
'Module socialservices is not installed.'));
147 $conferenceRecord = ZoomMeetingTable::getRowByExternalId($conferenceId);
148 if (!$conferenceRecord)
150 return $result->addError(
new Error(
'Conference is not found'));
152 $updateResult = ZoomMeetingTable::update($conferenceRecord[
'ID'], [
153 'HAS_RECORDING' =>
'Y'
155 if (!$updateResult->isSuccess())
157 return $result->addErrors($updateResult->getErrors());
162 public static function delete(
int $conferenceId):
Result
165 if (!Loader::includeModule(
'socialservices'))
167 return $result->addError(
new Error(
'Module socialservices is not installed.'));
170 $recordingsResult = ZoomMeetingRecordingTable::getList([
173 '=MEETING_ID' => $conferenceId,
177 while ($recording = $recordingsResult->fetch())
179 $deleteRecordingsResult = ZoomMeetingRecordingTable::delete($recording[
'ID']);
180 if (!$deleteRecordingsResult->isSuccess())
182 return $result->addErrors($deleteRecordingsResult->getErrors());