Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
messageaudiocall.php
1
<?php
9
namespace
Bitrix\Sender\Integration\VoxImplant
;
10
11
use
Bitrix\Main\Localization\Loc
;
12
use
Bitrix\Main\Result
;
13
use
Bitrix\Main\UI\FileInputUtility
;
14
use
Bitrix\Sender\Message
;
15
use
Bitrix\Sender\Entity
;
16
use
Bitrix\Sender\Transport\TimeLimiter
;
17
18
Loc::loadMessages
(__FILE__);
19
24
class
MessageAudioCall
implements
Message\iBase
,
Message\iMailable
,
Message\iAudible
25
{
26
const
CODE
=
self::CODE_AUDIO_CALL
;
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
{
101
return
Service::getFormattedOutputNumber
($value);
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
{
132
$this->
setConfigurationOptions
();
133
Entity\Message::create()
134
->setCode($this->
getCode
())
135
->loadConfiguration($id, $this->configuration);
136
TimeLimiter::prepareMessageConfigurationView($this->configuration);
137
138
return
$this->configuration
;
139
}
140
148
public
function
saveConfiguration
(
Message
\
Configuration
$configuration
)
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
}
Bitrix\Main\Config\Configuration
Definition
configuration.php:7
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\UI\FileInputUtility
Definition
fileinpututility.php:7
Bitrix\Sender\Entity\Message
Definition
message.php:27
Bitrix\Sender\Integration\VoxImplant\Audio
Definition
audio.php:22
Bitrix\Sender\Integration\VoxImplant\MessageAudioCall
Definition
messageaudiocall.php:25
Bitrix\Sender\Integration\VoxImplant\MessageAudioCall\CODE
const CODE
Definition
messageaudiocall.php:26
Bitrix\Sender\Integration\VoxImplant\MessageAudioCall\__construct
__construct()
Definition
messageaudiocall.php:34
Bitrix\Sender\Integration\VoxImplant\MessageAudioCall\setConfigurationOptions
setConfigurationOptions()
Definition
messageaudiocall.php:73
Bitrix\Sender\Integration\VoxImplant\MessageAudioCall\getName
getName()
Definition
messageaudiocall.php:43
Bitrix\Sender\Integration\VoxImplant\MessageAudioCall\removeConfiguration
removeConfiguration($id)
Definition
messageaudiocall.php:161
Bitrix\Sender\Integration\VoxImplant\MessageAudioCall\getAudioValue
getAudioValue($optionCode, $newValue)
Definition
messageaudiocall.php:189
Bitrix\Sender\Integration\VoxImplant\MessageAudioCall\loadConfiguration
loadConfiguration($id=null)
Definition
messageaudiocall.php:130
Bitrix\Sender\Integration\VoxImplant\MessageAudioCall\$configuration
$configuration
Definition
messageaudiocall.php:29
Bitrix\Sender\Integration\VoxImplant\MessageAudioCall\getCode
getCode()
Definition
messageaudiocall.php:53
Bitrix\Sender\Integration\VoxImplant\MessageAudioCall\copyConfiguration
copyConfiguration($id)
Definition
messageaudiocall.php:173
Bitrix\Sender\Integration\VoxImplant\MessageAudioCall\saveConfiguration
saveConfiguration(Message\Configuration $configuration)
Definition
messageaudiocall.php:148
Bitrix\Sender\Integration\VoxImplant\MessageAudioCall\getSupportedTransports
getSupportedTransports()
Definition
messageaudiocall.php:63
Bitrix\Sender\Integration\VoxImplant\Service\getFormattedOutputNumber
static getFormattedOutputNumber($value)
Definition
service.php:125
Bitrix\Sender\Integration\VoxImplant\TransportAudioCall\CODE
const CODE
Definition
transportaudiocall.php:26
Bitrix\Sender\Transport\TimeLimiter
Definition
timelimiter.php:16
Bitrix\Sender\Message\iAudible
Definition
iaudible.php:16
Bitrix\Sender\Message\iBase
Definition
ibase.php:16
Bitrix\Sender\Message\iBase\CODE_AUDIO_CALL
const CODE_AUDIO_CALL
Definition
ibase.php:23
Bitrix\Sender\Message\iMailable
Definition
imailable.php:16
Bitrix\Main\$GLOBALS
$GLOBALS['____1444769544']
Definition
license.php:1
Bitrix\Sender\Entity
Definition
ad.php:8
Bitrix\Sender\Integration\VoxImplant
Definition
audio.php:9
Bitrix\Sender\Message
Definition
adapter.php:9
modules
sender
lib
integration
voximplant
messageaudiocall.php
Создано системой
1.10.0