|
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\Core\System\Upgrade\Releases; |
|
21
|
|
|
|
|
22
|
|
|
use MikoPBX\Common\Models\Extensions; |
|
23
|
|
|
use MikoPBX\Core\System\Upgrade\UpgradeSystemConfigInterface; |
|
24
|
|
|
use Phalcon\Di\Injectable; |
|
25
|
|
|
|
|
26
|
|
|
class UpdateConfigsUpToVer20220284 extends Injectable implements UpgradeSystemConfigInterface |
|
27
|
|
|
{ |
|
28
|
|
|
public const PBX_VERSION = '2022.2.85'; |
|
29
|
|
|
|
|
30
|
|
|
private bool $isLiveCD; |
|
31
|
|
|
|
|
32
|
|
|
/** |
|
33
|
|
|
* Class constructor. |
|
34
|
|
|
*/ |
|
35
|
|
|
public function __construct() |
|
36
|
|
|
{ |
|
37
|
|
|
$this->isLiveCD = file_exists('/offload/livecd'); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* https://github.com/mikopbx/Core/issues/155 |
|
42
|
|
|
*/ |
|
43
|
|
|
public function processUpdate():void |
|
44
|
|
|
{ |
|
45
|
|
|
if ($this->isLiveCD) { |
|
46
|
|
|
return; |
|
47
|
|
|
} |
|
48
|
|
|
$extensions = [ |
|
49
|
|
|
'hangup', |
|
50
|
|
|
'busy', |
|
51
|
|
|
'did2user' |
|
52
|
|
|
]; |
|
53
|
|
|
foreach ($extensions as $extension){ |
|
54
|
|
|
$data = Extensions::findFirst('number="' . $extension . '"'); |
|
55
|
|
|
if ($data===null) { |
|
56
|
|
|
$data = new Extensions(); |
|
57
|
|
|
$data->number = $extension; |
|
58
|
|
|
} |
|
59
|
|
|
$data->type = Extensions::TYPE_SYSTEM; |
|
60
|
|
|
$data->callerid = 'System Extension'; |
|
61
|
|
|
$data->public_access = 0; |
|
62
|
|
|
$data->show_in_phonebook = 1; |
|
63
|
|
|
$data->save(); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
} |