|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* Copyright © MIKO LLC - All Rights Reserved |
|
4
|
|
|
* Unauthorized copying of this file, via any medium is strictly prohibited |
|
5
|
|
|
* Proprietary and confidential |
|
6
|
|
|
* Written by Alexey Portnov, 9 2020 |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace MikoPBX\Core\Asterisk\Configs; |
|
10
|
|
|
|
|
11
|
|
|
use MikoPBX\Common\Models\ConferenceRooms; |
|
12
|
|
|
use MikoPBX\Modules\Config\ConfigClass; |
|
13
|
|
|
|
|
14
|
|
|
|
|
15
|
|
|
class ConferenceConf extends ConfigClass |
|
16
|
|
|
{ |
|
17
|
|
|
|
|
18
|
|
|
protected string $description = 'confbridge.conf'; |
|
19
|
|
|
protected function generateConfigProtected(): void |
|
20
|
|
|
{ |
|
21
|
|
|
$conf = ""; |
|
22
|
|
|
file_put_contents($this->config->path('asterisk.astetcdir') . '/confbridge.conf', $conf); |
|
23
|
|
|
} |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Возвращает номерной план для internal контекста. |
|
27
|
|
|
* |
|
28
|
|
|
* @return string |
|
29
|
|
|
*/ |
|
30
|
|
|
public function extensionGenInternal(): string |
|
31
|
|
|
{ |
|
32
|
|
|
$conf = ''; |
|
33
|
|
|
$data = self::getConferenceExtensions(); |
|
34
|
|
|
foreach ($data as $conference) { |
|
35
|
|
|
$conf .= "exten => {$conference},1,Goto(conference-rooms,{$conference},1)" . "\n"; |
|
36
|
|
|
} |
|
37
|
|
|
$conf .= "\n"; |
|
38
|
|
|
|
|
39
|
|
|
return $conf; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @return string |
|
44
|
|
|
*/ |
|
45
|
|
|
public function extensionGenInternalTransfer(): string |
|
46
|
|
|
{ |
|
47
|
|
|
$conf = ''; |
|
48
|
|
|
$data = self::getConferenceExtensions(); |
|
49
|
|
|
foreach ($data as $conference) { |
|
50
|
|
|
$conf .= "exten => {$conference},1,Goto(conference-rooms,{$conference},1)" . "\n"; |
|
51
|
|
|
} |
|
52
|
|
|
$conf .= "\n"; |
|
53
|
|
|
|
|
54
|
|
|
return $conf; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* Генерация дополнительных контекстов. |
|
59
|
|
|
* |
|
60
|
|
|
* @return string |
|
61
|
|
|
*/ |
|
62
|
|
|
public function extensionGenContexts(): string |
|
63
|
|
|
{ |
|
64
|
|
|
$PBXRecordCalls = $this->generalSettings['PBXRecordCalls']; |
|
65
|
|
|
$rec_options = ($PBXRecordCalls === '1') ? 'r' : ''; |
|
66
|
|
|
|
|
67
|
|
|
// Генерация внутреннего номерного плана. |
|
68
|
|
|
$conf = ''; |
|
69
|
|
|
$conf .= "[hangup_handler_meetme]\n\n"; |
|
70
|
|
|
$conf .= "exten => s,1,AGI(cdr_connector.php,hangup_chan_meetme)\n\t"; |
|
71
|
|
|
$conf .= "same => n,return\n\n"; |
|
72
|
|
|
$conf .= "[conference-rooms] \n"; |
|
73
|
|
|
$data = self::getConferenceExtensions(); |
|
74
|
|
|
foreach ($data as $conference) { |
|
75
|
|
|
$conf .= 'exten => ' . $conference . ',1,NoOp(---)' . "\n\t"; |
|
76
|
|
|
$conf .= 'same => n,ExecIf($["${CHANNEL(channeltype)}" == "Local"]?Hangup())' . "\n\t"; |
|
77
|
|
|
$conf .= 'same => n,AGI(cdr_connector.php,meetme_dial)' . "\n\t"; |
|
78
|
|
|
$conf .= 'same => n,Answer()' . "\n\t"; |
|
79
|
|
|
$conf .= 'same => n,Set(CHANNEL(hangup_handler_wipe)=hangup_handler_meetme,s,1)' . "\n\t"; |
|
80
|
|
|
$conf .= 'same => n,Meetme(${EXTEN},qdMT' . $rec_options . ')' . "\n\t"; |
|
81
|
|
|
$conf .= 'same => n,Hangup()' . "\n\n"; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
return $conf; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Генерация хинтов. |
|
89
|
|
|
* |
|
90
|
|
|
* @return string |
|
91
|
|
|
*/ |
|
92
|
|
|
public function extensionGenHints(): string |
|
93
|
|
|
{ |
|
94
|
|
|
$conf = ''; |
|
95
|
|
|
$data = self::getConferenceExtensions(); |
|
96
|
|
|
foreach ($data as $conference) { |
|
97
|
|
|
$conf .= "exten => {$conference},hint,Custom:{$conference} \n"; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
return $conf; |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* Возвращает массив номеров конференц комнат. |
|
105
|
|
|
* @return array |
|
106
|
|
|
*/ |
|
107
|
|
|
public static function getConferenceExtensions():array{ |
|
108
|
|
|
$confExtensions = []; |
|
109
|
|
|
$conferences = ConferenceRooms::find(['order' => 'extension', 'columns' => 'extension'])->toArray(); |
|
110
|
|
|
foreach ($conferences as $conference){ |
|
111
|
|
|
$confExtensions[] = $conference['extension']; |
|
112
|
|
|
} |
|
113
|
|
|
return $confExtensions; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
} |