|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* MikoPBX - free phone system for small business |
|
5
|
|
|
* Copyright © 2017-2023 Alexey Portnov and Nikolay Beketov |
|
6
|
|
|
* |
|
7
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
8
|
|
|
* it under the terms of the GNU General Public License as published by |
|
9
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
10
|
|
|
* (at your option) any later version. |
|
11
|
|
|
* |
|
12
|
|
|
* This program is distributed in the hope that it will be useful, |
|
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
15
|
|
|
* GNU General Public License for more details. |
|
16
|
|
|
* |
|
17
|
|
|
* You should have received a copy of the GNU General Public License along with this program. |
|
18
|
|
|
* If not, see <https://www.gnu.org/licenses/>. |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
namespace MikoPBX\AdminCabinet\Forms; |
|
22
|
|
|
|
|
23
|
|
|
use MikoPBX\AdminCabinet\Library\Cidr; |
|
24
|
|
|
use MikoPBX\Common\Providers\TranslationProvider; |
|
25
|
|
|
use Phalcon\Forms\Element\Hidden; |
|
26
|
|
|
use Phalcon\Forms\Element\Select; |
|
27
|
|
|
use Phalcon\Forms\Element\Text; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Class FirewallEditForm |
|
31
|
|
|
* |
|
32
|
|
|
* @package MikoPBX\AdminCabinet\Forms |
|
33
|
|
|
* @property TranslationProvider translation |
|
34
|
|
|
*/ |
|
35
|
|
|
class FirewallEditForm extends BaseForm |
|
36
|
|
|
{ |
|
37
|
|
|
public function initialize($entity = null, $options = null): void |
|
38
|
|
|
{ |
|
39
|
|
|
parent::initialize($entity, $options); |
|
40
|
|
|
|
|
41
|
|
|
$this->add(new Hidden('id')); |
|
42
|
|
|
$this->add(new Text('description')); |
|
43
|
|
|
$this->add(new Text('network', ['value' => $options['network']])); |
|
44
|
|
|
|
|
45
|
|
|
// Makes subnet select |
|
46
|
|
|
$arrMasks = Cidr::getNetMasks(); |
|
47
|
|
|
|
|
48
|
|
|
$mask = new Select( |
|
49
|
|
|
'subnet', |
|
50
|
|
|
$arrMasks, |
|
51
|
|
|
[ |
|
52
|
|
|
'using' => [ |
|
53
|
|
|
'id', |
|
54
|
|
|
'name', |
|
55
|
|
|
], |
|
56
|
|
|
'useEmpty' => false, |
|
57
|
|
|
'value' => $options['subnet'], |
|
58
|
|
|
'class' => 'ui selection dropdown ipaddress', |
|
59
|
|
|
] |
|
60
|
|
|
); |
|
61
|
|
|
$this->add($mask); |
|
62
|
|
|
|
|
63
|
|
|
// Newer_block_ip |
|
64
|
|
|
$this->addCheckBox( |
|
65
|
|
|
'newer_block_ip', |
|
66
|
|
|
intval($entity->newer_block_ip) === 1 |
|
67
|
|
|
); |
|
68
|
|
|
|
|
69
|
|
|
// Local_network |
|
70
|
|
|
$this->addCheckBox( |
|
71
|
|
|
'local_network', |
|
72
|
|
|
intval($entity->local_network) === 1 |
|
73
|
|
|
); |
|
74
|
|
|
} |
|
75
|
|
|
} |
|
76
|
|
|
|