Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
messageaudiocall.php
1<?php
10
17
18Loc::loadMessages(__FILE__);
19
25{
27
29 protected $configuration;
30
34 public function __construct()
35 {
36 $this->configuration = new Message\Configuration();
37 }
38
43 public function getName()
44 {
45 return Loc::getMessage('SENDER_INTEGRATION_AUDIOCALL_MESSAGE_NAME');
46 }
47
53 public function getCode()
54 {
55 return static::CODE;
56 }
57
63 public function getSupportedTransports()
64 {
65 return array(TransportAudioCall::CODE);
66 }
67
73 protected function setConfigurationOptions()
74 {
75 if ($this->configuration->hasOptions())
76 {
77 return;
78 }
79
80 $this->configuration->setArrayOptions(array(
81 array(
82 'type' => 'list',
83 'code' => 'OUTPUT_NUMBER',
84 'name' => Loc::getMessage('SENDER_INTEGRATION_AUDIOCALL_MESSAGE_CONFIG_OUTPUT_NUMBER'),
85 'items' => \CVoxImplantConfig::GetPortalNumbers(false),
86 'view' => function ()
87 {
88 ob_start();
89 $GLOBALS['APPLICATION']->includeComponent(
90 "bitrix:sender.call.number", "",
91 array(
92 "INPUT_NAME" => "%INPUT_NAME%",
93 "VALUE" => "%INPUT_VALUE%",
94 "MESSAGE_TYPE" => $this->getCode()
95 )
96 );
97 return ob_get_clean();
98 },
99 'readonly_view' => function($value)
100 {
102 },
103 'required' => true,
104 'show_in_list' => true,
105 ),
106 array(
107 'type' => 'audio',
108 'code' => 'AUDIO_FILE',
109 'name' => Loc::getMessage('SENDER_INTEGRATION_AUDIOCALL_MESSAGE_CONFIG_MESSAGE_FILE'),
110 'required' => true,
111 'params' => [
112 'allowUpload' => 'F',
113 'allowUploadExt' => 'mp3',
114 'maxCount' => 1,
115 ]
116 ),
117
118 ));
119
120 TimeLimiter::prepareMessageConfiguration($this->configuration);
121 }
122
130 public function loadConfiguration($id = null)
131 {
133 Entity\Message::create()
134 ->setCode($this->getCode())
135 ->loadConfiguration($id, $this->configuration);
136 TimeLimiter::prepareMessageConfigurationView($this->configuration);
137
139 }
140
149 {
150 return Entity\Message::create()
151 ->setCode($this->getCode())
152 ->saveConfiguration($this->configuration);
153 }
154
161 public function removeConfiguration($id)
162 {
163 $result = Entity\Message::removeById($id);
164 return $result->isSuccess();
165 }
166
173 public function copyConfiguration($id)
174 {
175 return Entity\Message::create()
176 ->setCode($this->getCode())
177 ->copyConfiguration($id);
178 }
179
189 public function getAudioValue($optionCode, $newValue)
190 {
191 $valueIsCorrect = false;
192
193 if($newValue <> '')
194 {
195 $audio = (new Audio())
196 ->withValue($newValue)
197 ->withMessageCode($this->getCode());
198
199 if($audio->createdFromPreset())
200 {
201 if($audio->getFileUrl()) // preset $newValue is really exists
202 {
203 $valueIsCorrect = true;
204 }
205 }
206 else
207 {
208 $oldValue = $this->configuration->getOption($optionCode);
209 $oldAudio = (new Audio())
210 ->withJsonString($oldValue->getValue())
211 ->withMessageCode($this->getCode());
212
213 if($oldAudio->getFileId() == $newValue) // file wasn't changed
214 {
215 $audio = $oldAudio;
216 $valueIsCorrect = true;
217 }
218 else
219 {
220 if(
221 $audio->getDuration() && // check if new file is really mp3
222 FileInputUtility::instance()->checkFiles($optionCode, [$newValue]) // check if file was uploaded by current user
223 )
224 {
225 $valueIsCorrect = true;
226 }
227 }
228 }
229 }
230
231 if ($valueIsCorrect)
232 {
233 return $audio->getDbValue();
234 }
235
236 return false;
237 }
238}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
saveConfiguration(Message\Configuration $configuration)
$GLOBALS['____1444769544']
Definition license.php:1