Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
Background.php
1<?php
2
4
7
8class Background extends Controller
9{
13 public function getAction()
14 {
15 $diskFolder = \Bitrix\Im\Call\Background::getUploadFolder();
16 $diskFolderId = $diskFolder? (int)$diskFolder->getId(): 0;
17 $infoHelperParams = \Bitrix\Main\Loader::includeModule('ui')? InfoHelper::getInitParams(): [];
18
19 return [
20 'backgrounds' => [
21 'default' => \Bitrix\Im\Call\Background::get(),
22 'custom' => \Bitrix\Im\Call\Background::getCustom(),
23 ],
24 'upload' => [
25 'folderId' => $diskFolderId,
26 ],
27 'limits' => \Bitrix\Im\Call\Background::getLimitForJs(),
28 'infoHelperParams' => $infoHelperParams,
29 ];
30 }
31
35 public function commitAction(int $fileId)
36 {
37 $result = \CIMDisk::CommitBackgroundFile(
38 $this->getCurrentUser()->getId(),
39 $fileId
40 );
41
42 if (!$result)
43 {
44 $this->addError(new \Bitrix\Main\Error(
45 "Specified fileId is not located in background folder.",
46 "FILE_ID_ERROR"
47 ));
48
49 return false;
50 }
51
52 return [
53 'result' => true
54 ];
55 }
56
60 public function deleteAction(int $fileId)
61 {
62 $result = \CIMDisk::DeleteBackgroundFile(
63 $this->getCurrentUser()->getId(),
64 $fileId
65 );
66
67 if (!$result)
68 {
69 $this->addError(new \Bitrix\Main\Error(
70 "Specified fileId is not located in background folder.",
71 "FILE_ID_ERROR"
72 ));
73
74 return false;
75 }
76
77 return [
78 'result' => true
79 ];
80 }
81}
static getInitParams(?string $currentUrl=null)