|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* MikoPBX - free phone system for small business |
|
4
|
|
|
* Copyright (C) 2017-2020 Alexey Portnov and Nikolay Beketov |
|
5
|
|
|
* |
|
6
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
7
|
|
|
* it under the terms of the GNU General Public License as published by |
|
8
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
9
|
|
|
* (at your option) any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* This program is distributed in the hope that it will be useful, |
|
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14
|
|
|
* GNU General Public License for more details. |
|
15
|
|
|
* |
|
16
|
|
|
* You should have received a copy of the GNU General Public License along with this program. |
|
17
|
|
|
* If not, see <https://www.gnu.org/licenses/>. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace MikoPBX\AdminCabinet\Forms; |
|
21
|
|
|
|
|
22
|
|
|
use MikoPBX\Common\Models\Sip; |
|
23
|
|
|
use Phalcon\Forms\Element\Check; |
|
24
|
|
|
use Phalcon\Forms\Element\Hidden; |
|
25
|
|
|
use Phalcon\Forms\Element\Numeric; |
|
26
|
|
|
use Phalcon\Forms\Element\Password; |
|
27
|
|
|
use Phalcon\Forms\Element\Select; |
|
28
|
|
|
use Phalcon\Forms\Element\Text; |
|
29
|
|
|
use Phalcon\Forms\Element\TextArea; |
|
30
|
|
|
use Phalcon\Forms\Form; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Class SipProviderEditForm |
|
34
|
|
|
* |
|
35
|
|
|
* @package MikoPBX\AdminCabinet\Forms |
|
36
|
|
|
* @property \MikoPBX\Common\Providers\TranslationProvider translation |
|
37
|
|
|
*/ |
|
38
|
|
|
class SipProviderEditForm extends Form |
|
39
|
|
|
{ |
|
40
|
|
|
public function initialize($entity = null): void |
|
41
|
|
|
{ |
|
42
|
|
|
// Не нужны провайдеру |
|
43
|
|
|
// Busylevel |
|
44
|
|
|
// Extension |
|
45
|
|
|
// Networkfilterid |
|
46
|
|
|
|
|
47
|
|
|
// ProviderType |
|
48
|
|
|
$this->add(new Hidden('providerType', ['value' => 'SIP'])); |
|
49
|
|
|
|
|
50
|
|
|
// Disabled |
|
51
|
|
|
$this->add(new Hidden('disabled')); |
|
52
|
|
|
|
|
53
|
|
|
// ID |
|
54
|
|
|
$this->add(new Hidden('id')); |
|
55
|
|
|
|
|
56
|
|
|
// Uniqid |
|
57
|
|
|
$this->add(new Hidden('uniqid')); |
|
58
|
|
|
|
|
59
|
|
|
// Type |
|
60
|
|
|
$this->add(new Hidden('type')); |
|
61
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
// Description |
|
64
|
|
|
$this->add(new Text('description')); |
|
65
|
|
|
|
|
66
|
|
|
// Username |
|
67
|
|
|
$this->add(new Text('username')); |
|
68
|
|
|
|
|
69
|
|
|
// Secret |
|
70
|
|
|
$this->add(new Password('secret')); |
|
71
|
|
|
|
|
72
|
|
|
// Host |
|
73
|
|
|
$this->add(new Text('host')); |
|
74
|
|
|
|
|
75
|
|
|
// Dtmfmode |
|
76
|
|
|
$arrDTMFType = [ |
|
77
|
|
|
'auto' => $this->translation->_('auto'), |
|
78
|
|
|
'inband' => $this->translation->_('inband'), |
|
79
|
|
|
'info' => $this->translation->_('info'), |
|
80
|
|
|
'rfc4733' => $this->translation->_('rfc4733'), |
|
81
|
|
|
'auto_info' => $this->translation->_('auto_info'), |
|
82
|
|
|
]; |
|
83
|
|
|
|
|
84
|
|
|
$dtmfmode = new Select( |
|
85
|
|
|
'dtmfmode', $arrDTMFType, [ |
|
86
|
|
|
'using' => [ |
|
87
|
|
|
'id', |
|
88
|
|
|
'name', |
|
89
|
|
|
], |
|
90
|
|
|
'useEmpty' => false, |
|
91
|
|
|
'value' => $entity->dtmfmode, |
|
92
|
|
|
'class' => 'ui selection dropdown', |
|
93
|
|
|
] |
|
94
|
|
|
); |
|
95
|
|
|
$this->add($dtmfmode); |
|
96
|
|
|
|
|
97
|
|
|
$regTypeArray = [ |
|
98
|
|
|
Sip::REG_TYPE_OUTBOUND => $this->translation->_('sip_REG_TYPE_OUTBOUND'), |
|
99
|
|
|
Sip::REG_TYPE_INBOUND => $this->translation->_('sip_REG_TYPE_INBOUND'), |
|
100
|
|
|
Sip::REG_TYPE_NONE => $this->translation->_('sip_REG_TYPE_NONE'), |
|
101
|
|
|
]; |
|
102
|
|
|
|
|
103
|
|
|
$regTypeValue = $entity->registration_type; |
|
104
|
|
|
if(empty($regTypeValue)){ |
|
105
|
|
|
$regTypeValue = ($entity->noregister === '0')?Sip::REG_TYPE_OUTBOUND: Sip::REG_TYPE_NONE; |
|
106
|
|
|
} |
|
107
|
|
|
$regType = new Select( |
|
108
|
|
|
'registration_type', $regTypeArray, [ |
|
109
|
|
|
'using' => [ |
|
110
|
|
|
'id', |
|
111
|
|
|
'name', |
|
112
|
|
|
], |
|
113
|
|
|
'useEmpty' => false, |
|
114
|
|
|
'value' => $regTypeValue, |
|
115
|
|
|
'class' => 'ui selection dropdown', |
|
116
|
|
|
] |
|
117
|
|
|
); |
|
118
|
|
|
$this->add($regType); |
|
119
|
|
|
|
|
120
|
|
|
// Transport |
|
121
|
|
|
$arrTransport = [ |
|
122
|
|
|
Sip::TRANSPORT_UDP => Sip::TRANSPORT_UDP, |
|
123
|
|
|
Sip::TRANSPORT_TCP => Sip::TRANSPORT_TCP, |
|
124
|
|
|
Sip::TRANSPORT_TLS => Sip::TRANSPORT_TLS, |
|
125
|
|
|
]; |
|
126
|
|
|
$transport = new Select( |
|
127
|
|
|
'transport', $arrTransport, [ |
|
128
|
|
|
'using' => [ |
|
129
|
|
|
'id', |
|
130
|
|
|
'name', |
|
131
|
|
|
], |
|
132
|
|
|
'emptyText' => 'udp, tcp', |
|
133
|
|
|
'emptyValue' => ' ', |
|
134
|
|
|
'useEmpty' => true, |
|
135
|
|
|
'value' => empty($entity->transport)?' ': $entity->transport, |
|
136
|
|
|
'class' => 'ui selection dropdown', |
|
137
|
|
|
] |
|
138
|
|
|
); |
|
139
|
|
|
$this->add($transport); |
|
140
|
|
|
|
|
141
|
|
|
// Port |
|
142
|
|
|
$this->add(new Numeric('port')); |
|
143
|
|
|
$this->add(new Text('outbound_proxy')); |
|
144
|
|
|
|
|
145
|
|
|
// Nat |
|
146
|
|
|
$arrNatType = [ |
|
|
|
|
|
|
147
|
|
|
'force_rport,comedia' => 'force_rport, comedia', |
|
148
|
|
|
'force_rport' => 'force_rport', |
|
149
|
|
|
'comedia' => 'comedia', |
|
150
|
|
|
'auto_force_rport' => 'auto_force_rport', |
|
151
|
|
|
'no' => 'no', |
|
152
|
|
|
]; |
|
153
|
|
|
|
|
154
|
|
|
// Qualify |
|
155
|
|
|
$cheskarr = ['value' => null]; |
|
156
|
|
|
if ($entity->qualify) { |
|
157
|
|
|
$cheskarr = ['checked' => 'checked', 'value' => null]; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
$this->add(new Check('qualify', $cheskarr)); |
|
161
|
|
|
|
|
162
|
|
|
// Qualifyfreq |
|
163
|
|
|
$this->add(new Numeric('qualifyfreq')); |
|
164
|
|
|
|
|
165
|
|
|
// Fromuser |
|
166
|
|
|
$this->add(new Text('fromuser')); |
|
167
|
|
|
|
|
168
|
|
|
// Fromdomain |
|
169
|
|
|
$this->add(new Text('fromdomain')); |
|
170
|
|
|
|
|
171
|
|
|
// Noregister |
|
172
|
|
|
$cheskarr = ['value' => null]; |
|
173
|
|
|
if ($entity->noregister) { |
|
174
|
|
|
$cheskarr = ['checked' => 'checked', 'value' => null]; |
|
175
|
|
|
} |
|
176
|
|
|
$this->add(new Check('noregister', $cheskarr)); |
|
177
|
|
|
|
|
178
|
|
|
|
|
179
|
|
|
// Disablefromuser |
|
180
|
|
|
$cheskarr = ['value' => null]; |
|
181
|
|
|
if ($entity->disablefromuser) { |
|
182
|
|
|
$cheskarr = ['checked' => 'checked', 'value' => null]; |
|
183
|
|
|
} |
|
184
|
|
|
$this->add(new Check('disablefromuser', $cheskarr)); |
|
185
|
|
|
|
|
186
|
|
|
// Receive_calls_without_auth |
|
187
|
|
|
$cheskarr = ['value' => null]; |
|
188
|
|
|
if ($entity->receive_calls_without_auth) { |
|
189
|
|
|
$cheskarr = ['checked' => 'checked', 'value' => null]; |
|
190
|
|
|
} |
|
191
|
|
|
$this->add(new Check('receive_calls_without_auth', $cheskarr)); |
|
192
|
|
|
|
|
193
|
|
|
// Manualattributes |
|
194
|
|
|
$rows = max(round(strlen($entity->manualattributes) / 95), 2); |
|
195
|
|
|
$this->add(new TextArea('manualattributes', ["rows" => $rows])); |
|
196
|
|
|
} |
|
197
|
|
|
} |