|
1
|
|
|
<?php |
|
2
|
|
|
// |
|
3
|
|
|
|
|
4
|
|
|
|
|
5
|
|
|
namespace MikoPBX\Core\Asterisk\Configs; |
|
6
|
|
|
|
|
7
|
|
|
use MikoPBX\Common\Models\SoundFiles; |
|
8
|
|
|
use MikoPBX\Core\System\Util; |
|
9
|
|
|
|
|
10
|
|
|
class ExtensionsAnnonceRecording extends CoreConfigClass |
|
11
|
|
|
{ |
|
12
|
|
|
/** |
|
13
|
|
|
* Генератор extensions, дополнительные контексты. |
|
14
|
|
|
* @return string |
|
15
|
|
|
*/ |
|
16
|
|
|
public function extensionGenContexts(): string |
|
17
|
|
|
{ |
|
18
|
|
|
return '[annonce-spy]'. PHP_EOL. |
|
19
|
|
|
'exten => _.!,1,ExecIf($[ "${EXTEN}" == "h" ]?Hangup()'. PHP_EOL."\t". |
|
20
|
|
|
'same => n,ExecIf($["${CHANNELS(PJSIP/${EXTEN})}x" != "x" && "${PBX_REC_ANNONCE}x" != "x"]?Chanspy(PJSIP/${EXTEN},uBq))'. PHP_EOL."\t". |
|
21
|
|
|
'same => n,Hangup()'.PHP_EOL |
|
22
|
|
|
.PHP_EOL. |
|
23
|
|
|
'[annonce-playback]'.PHP_EOL. |
|
24
|
|
|
'exten => annonce,1,Answer()'.PHP_EOL."\t". |
|
25
|
|
|
'same => n,ExecIf("${PBX_REC_ANNONCE}x" != "x"]?Playback(${PBX_REC_ANNONCE}))'.PHP_EOL."\t". |
|
26
|
|
|
'same => n,Hangup()'.PHP_EOL; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Prepares additional parameters for [globals] section in the extensions.conf file |
|
31
|
|
|
* |
|
32
|
|
|
* @return string |
|
33
|
|
|
*/ |
|
34
|
|
|
public static function getPathAnnonceFile($id): string |
|
35
|
|
|
{ |
|
36
|
|
|
$filename = ''; |
|
37
|
|
|
if(!empty($id)){ |
|
38
|
|
|
/** @var SoundFiles $fileData */ |
|
39
|
|
|
$fileData = SoundFiles::findFirst($id); |
|
40
|
|
|
if($fileData){ |
|
|
|
|
|
|
41
|
|
|
$filename = Util::trimExtensionForFile($fileData->path); |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
return $filename; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Prepares additional parameters for each outgoing route context |
|
49
|
|
|
* before dial call in the extensions.conf file |
|
50
|
|
|
* |
|
51
|
|
|
* @param array $rout |
|
52
|
|
|
* |
|
53
|
|
|
* @return string |
|
54
|
|
|
*/ |
|
55
|
|
|
public function generateOutRoutContext(array $rout): string |
|
56
|
|
|
{ |
|
57
|
|
|
return 'same => n,Set(_OUT_NEED_ANNONCE=1)' . "\n\t"; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Prepares additional parameters for each incoming context for each incoming route before dial in the |
|
62
|
|
|
* extensions.conf file |
|
63
|
|
|
* |
|
64
|
|
|
* @param string $rout_number |
|
65
|
|
|
* |
|
66
|
|
|
* @return string |
|
67
|
|
|
*/ |
|
68
|
|
|
public function generateIncomingRoutBeforeDial(string $rout_number): string |
|
69
|
|
|
{ |
|
70
|
|
|
return 'same => n,Set(IN_NEED_ANNONCE=1)' . "\n\t"; |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
} |