-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathinstall.php
173 lines (158 loc) · 5.9 KB
/
install.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
<?php
if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }
// License for all code of this FreePBX module can be found in the license file inside the module directory
// Copyright 2006-2013 Schmooze Com Inc.s
//
//for translation only
if (false) {
_("Voicemail");
_("My Voicemail");
_("Dial Voicemail");
_("Voicemail Admin");
_("Direct Dial Prefix");
_("The Feature Code used to direct dial a users voicemail from their own extension");
_("The Feature Code used to dial any voicemail");
}
global $astman;
global $amp_conf;
global $db;
$fcc = new featurecode('voicemail', 'myvoicemail');
$fcc->setDescription('My Voicemail');
$fcc->setHelpText('The Feature Code used to direct dial a users voicemail from their own extension');
$fcc->setDefault('*97');
$fcc->update();
unset($fcc);
$fcc = new featurecode('voicemail', 'dialvoicemail');
$fcc->setDescription('Dial Voicemail');
$fcc->setHelpText('The Feature Code used to dial any voicemail');
$fcc->setDefault('*98');
$fcc->setProvideDest();
$fcc->update();
unset($fcc);
$fcc = new featurecode('voicemail', 'directdialvoicemail');
$fcc->setDescription('Direct Dial Prefix');
$fcc->setDefault('*');
$fcc->update();
unset($fcc);
$globals_convert['OPERATOR_XTN'] = '';
$globals_convert['VM_OPTS'] = '';
$globals_convert['VM_GAIN'] = '';
$globals_convert['VM_DDTYPE'] = 'u';
$globals_convert['VMX_OPTS_LOOP'] = '';
$globals_convert['VMX_OPTS_DOVM'] = '';
$globals_convert['VMX_TIMEOUT'] = '2';
$globals_convert['VMX_REPEAT'] = '1';
$globals_convert['VMX_LOOPS'] = '1';
if(!empty($globals_convert)) {
foreach ($globals_convert as $key => $value) {
$sql = 'INSERT INTO `voicemail_admin` (`variable`, `value`) VALUES ("' . $key . '","' . $value . '")';;
$result = $db->query($sql);
if(!DB::IsError($result)) {
out(sprintf(_("%s added"),$key));
}
}
}
$freepbx_conf =& freepbx_conf::create();
// VM_SHOW_IMAP
//
$set['value'] = false;
$set['defaultval'] =& $set['value'];
$set['readonly'] = 0;
$set['hidden'] = 0;
$set['level'] = 3;
$set['module'] = 'voicemail';
$set['category'] = 'Voicemail Module';
$set['emptyok'] = 0;
$set['sortorder'] = 100;
$set['name'] = 'Provide IMAP Voicemail Fields';
$set['description'] = 'Installations that have configured Voicemail with IMAP should set this to true so that the IMAP username and password fields are provided in the Voicemail setup screen for extensions. If an extension alread has these fields populated, they will be displayed even if this is set to false.';
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('VM_SHOW_IMAP',$set,true);
// USERESMWIBLF
//
$set['value'] = (file_exists($amp_conf['ASTMODDIR']."/res_mwi_blf.so") || file_exists($amp_conf['ASTMODDIR']."/res_mwi_devstate.so"));
$set['defaultval'] =& $set['value'];
$set['readonly'] = 0;
$set['hidden'] = 0;
$set['level'] = 3;
$set['module'] = 'voicemail';
$set['category'] = 'Voicemail Module';
$set['emptyok'] = 0;
$set['sortorder'] = 100;
$set['name'] = 'Create Voicemail Hints';
$set['description'] = 'Setting this flag with generate the required dialplan to integrate with res_mwi_devstate (res_mwi_blf) which is included with the Official FreePBX Distro. It allows users to subscribe to other voicemail box and be notified via BLF of changes.';
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('USERESMWIBLF',$set,true);
//UCP_MESSAGE_LIMIT
$set['value'] = 3000;
$set['defaultval'] =& $set['value'];
$set['options'] = array(1,100000);
$set['readonly'] = 0;
$set['hidden'] = 0;
$set['level'] = 3;
$set['module'] = 'voicemail';
$set['category'] = 'Voicemail Module';
$set['emptyok'] = 0;
$set['sortorder'] = 100;
$set['name'] = 'UCP Message Limit';
$set['description'] = 'Limit the Messages to be Displayed in UCP. If your device has more processing power you can increase this otherwise lower it if you find your system not responsive';
$set['type'] = CONF_TYPE_INT;
$freepbx_conf->define_conf_setting('UCP_MESSAGE_LIMIT',$set,true);
/*
update modules.conf to make sure it preloads res_mwi_blf.so if they have it
This makes sure that the modules.conf has been updated for older systems
which assures that mwi blf events are captured when Asterisk first starts
*/
$amd = FreePBX::create()->Config->get_conf_setting('ASTMODDIR');
if(file_exists($amd.'/res_mwi_blf.so')) {
FreePBX::create()->ModulesConf->preload('res_mwi_blf.so');
}
/** FREEPBX-8130 Migrate email body into GUI **/
$aed = FreePBX::create()->Config->get_conf_setting('ASTETCDIR');
global $gen_settings;
if(file_exists($aed.'/vm_email.inc')) {
$contents = FreePBX::LoadConfig()->getConfig('vm_email.inc');
$final = array();
if(!empty($contents['HEADER']) && is_array($contents['HEADER'])) {
foreach($contents['HEADER'] as $key => $val) {
$final["gen__".$key] = $val;
$gen_settings[$key] = "";
}
}
if(!empty($final)) {
if(!function_exists('voicemail_update_settings')) {
include(__DIR__.'/functions.inc.php');
}
voicemail_update_settings("settings", "", "", $final);
}
unlink($aed.'/vm_email.inc');
}
if(file_exists($aed.'/vm_general.inc')) {
$contents = FreePBX::LoadConfig()->getConfig('vm_general.inc');
$final = array();
if(!empty($contents['HEADER']) && is_array($contents['HEADER'])) {
foreach($contents['HEADER'] as $key => $val) {
$final["gen__".$key] = $val;
$gen_settings[$key] = "";
}
}
if(!empty($final)) {
if(!function_exists('voicemail_update_settings')) {
include(__DIR__.'/functions.inc.php');
}
voicemail_update_settings("settings", "", "", $final);
}
unlink($aed.'/vm_general.inc');
}
$vmconf = \FreePBX::Voicemail()->getVoicemail(false);
if(!empty($vmconf)) {
$dsettings = $settings = \FreePBX::Voicemail()->constructSettings("general");
foreach($dsettings as $data) {
foreach($data['settings'] as $key => $items) {
if($items['default'] !== '' && !isset($vmconf['general'][$key])) {
$vmconf['general'][$key] = $items['default'];
}
}
}
\FreePBX::Voicemail()->saveVoicemail($vmconf);
}