| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
function voicemail_get_config($engine) { |
|---|
| 4 |
$modulename = 'voicemail'; |
|---|
| 5 |
|
|---|
| 6 |
// This generates the dialplan |
|---|
| 7 |
global $ext; |
|---|
| 8 |
switch($engine) { |
|---|
| 9 |
case "asterisk": |
|---|
| 10 |
if (is_array($featurelist = featurecodes_getModuleFeatures($modulename))) { |
|---|
| 11 |
foreach($featurelist as $item) { |
|---|
| 12 |
$featurename = $item['featurename']; |
|---|
| 13 |
$fname = $modulename.'_'.$featurename; |
|---|
| 14 |
if (function_exists($fname)) { |
|---|
| 15 |
$fcc = new featurecode($modulename, $featurename); |
|---|
| 16 |
$fc = $fcc->getCodeActive(); |
|---|
| 17 |
unset($fcc); |
|---|
| 18 |
|
|---|
| 19 |
if ($fc != '') |
|---|
| 20 |
$fname($fc); |
|---|
| 21 |
} else { |
|---|
| 22 |
$ext->add('from-internal-additional', 'debug', '', new ext_noop($modulename.": No func $fname")); |
|---|
| 23 |
var_dump($item); |
|---|
| 24 |
} |
|---|
| 25 |
} |
|---|
| 26 |
} |
|---|
| 27 |
break; |
|---|
| 28 |
} |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
function voicemail_myvoicemail($c) { |
|---|
| 32 |
global $ext; |
|---|
| 33 |
|
|---|
| 34 |
$id = "app-vmmain"; // The context to be included |
|---|
| 35 |
|
|---|
| 36 |
$ext->addInclude('from-internal-additional', $id); // Add the include from from-internal |
|---|
| 37 |
|
|---|
| 38 |
$ext->add($id, $c, '', new ext_answer('')); // $cmd,1,Answer |
|---|
| 39 |
$ext->add($id, $c, '', new ext_wait('1')); // $cmd,n,Wait(1) |
|---|
| 40 |
$ext->add($id, $c, '', new ext_macro('user-callerid')); // $cmd,n,Macro(user-callerid) |
|---|
| 41 |
$ext->add($id, $c, '', new ext_macro('get-vmcontext','${AMPUSER}')); |
|---|
| 42 |
$ext->add($id, $c, 'check', new ext_vmexists('${AMPUSER}@${VMCONTEXT}')); // n,VoiceMailMain(${VMCONTEXT}) |
|---|
| 43 |
$ext->add($id, $c, '', new ext_gotoif('$["${VMBOXEXISTSSTATUS}" = "SUCCESS"]', 'mbexist')); |
|---|
| 44 |
$ext->add($id, $c, '', new ext_vmmain('')); // n,VoiceMailMain(${VMCONTEXT}) |
|---|
| 45 |
$ext->add($id, $c, '', new ext_macro('hangupcall')); // $cmd,n,Macro(user-callerid) |
|---|
| 46 |
$ext->add($id, $c, 'mbexist', new ext_vmmain('${CALLERID(num)}@${VMCONTEXT}'),'check',101); // n,VoiceMailMain(${VMCONTEXT}) |
|---|
| 47 |
$ext->add($id, $c, '', new ext_macro('hangupcall')); // $cmd,n,Macro(user-callerid) |
|---|
| 48 |
} |
|---|
| 49 |
|
|---|
| 50 |
function voicemail_dialvoicemail($c) { |
|---|
| 51 |
global $ext; |
|---|
| 52 |
|
|---|
| 53 |
$id = "app-dialvm"; // The context to be included |
|---|
| 54 |
|
|---|
| 55 |
$ext->addInclude('from-internal-additional', $id); // Add the include from from-internal |
|---|
| 56 |
|
|---|
| 57 |
$ext->add($id, $c, '', new ext_answer('')); // $cmd,1,Answer |
|---|
| 58 |
$ext->add($id, $c, '', new ext_wait('1')); // $cmd,n,Wait(1) |
|---|
| 59 |
$ext->add($id, $c, '', new ext_vmmain('')); // n,VoiceMailMain(${VMCONTEXT}) |
|---|
| 60 |
$ext->add($id, $c, '', new ext_macro('hangupcall')); |
|---|
| 61 |
|
|---|
| 62 |
// Note that with this one, it has paramters. So we have to add '_' to the start and '.' to the end |
|---|
| 63 |
// of $c |
|---|
| 64 |
$c = "_$c."; |
|---|
| 65 |
$ext->add($id, $c, '', new ext_answer('')); // $cmd,1,Answer |
|---|
| 66 |
$ext->add($id, $c, '', new ext_wait('1')); // $cmd,n,Wait(1) |
|---|
| 67 |
// How long is the command? We need to strip that off the front |
|---|
| 68 |
$clen = strlen($c)-2; |
|---|
| 69 |
$ext->add($id, $c, '', new ext_macro('get-vmcontext','${EXTEN:'.$clen.'}')); |
|---|
| 70 |
$ext->add($id, $c, '', new ext_vmmain('${EXTEN:'.$clen.'}@${VMCONTEXT}')); // n,VoiceMailMain(${VMCONTEXT}) |
|---|
| 71 |
$ext->add($id, $c, '', new ext_macro('hangupcall')); // $cmd,n,Macro(user-callerid) |
|---|
| 72 |
} |
|---|
| 73 |
|
|---|
| 74 |
function voicemail_configpageinit($pagename) { |
|---|
| 75 |
global $currentcomponent; |
|---|
| 76 |
|
|---|
| 77 |
$action = isset($_REQUEST['action'])?$_REQUEST['action']:null; |
|---|
| 78 |
$extdisplay = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:null; |
|---|
| 79 |
$extension = isset($_REQUEST['extension'])?$_REQUEST['extension']:null; |
|---|
| 80 |
$tech_hardware = isset($_REQUEST['tech_hardware'])?$_REQUEST['tech_hardware']:null; |
|---|
| 81 |
|
|---|
| 82 |
// We only want to hook 'users' or 'extensions' pages. |
|---|
| 83 |
if ($pagename != 'users' && $pagename != 'extensions') |
|---|
| 84 |
return true; |
|---|
| 85 |
// On a 'new' user, 'tech_hardware' is set, and there's no extension. Hook into the page. |
|---|
| 86 |
if ($tech_hardware != null ) { |
|---|
| 87 |
voicemail_applyhooks(); |
|---|
| 88 |
} elseif ($action=="add") { |
|---|
| 89 |
// We don't need to display anything on an 'add', but we do need to handle returned data. |
|---|
| 90 |
// ** WARNING ** |
|---|
| 91 |
// Mailbox must be processed before adding / deleting users, therefore $sortorder = 1 |
|---|
| 92 |
$currentcomponent->addprocessfunc('voicemail_configprocess', 1); |
|---|
| 93 |
// JS function needed for checking voicemail = Enabled |
|---|
| 94 |
$js = 'return (theForm.vm.value == "enabled");'; |
|---|
| 95 |
} elseif ($extdisplay != '' || $pagename == 'users') { |
|---|
| 96 |
// We're now viewing an extension, so we need to display _and_ process. |
|---|
| 97 |
voicemail_applyhooks(); |
|---|
| 98 |
$currentcomponent->addprocessfunc('voicemail_configprocess', 1); |
|---|
| 99 |
$js = 'return (theForm.vm.value == "enabled");'; |
|---|
| 100 |
$currentcomponent->addjsfunc('isVoiceMailEnabled(notused)',$js); |
|---|
| 101 |
} |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|
| 104 |
function voicemail_applyhooks() { |
|---|
| 105 |
global $currentcomponent; |
|---|
| 106 |
|
|---|
| 107 |
// Setup two option lists we need |
|---|
| 108 |
// Enable / Disable list |
|---|
| 109 |
$currentcomponent->addoptlistitem('vmena', 'enabled', 'Enabled'); |
|---|
| 110 |
$currentcomponent->addoptlistitem('vmena', 'disabled', 'Disabled'); |
|---|
| 111 |
$currentcomponent->setoptlistopts('vmena', 'sort', false); |
|---|
| 112 |
// Enable / Disable vmx list |
|---|
| 113 |
$currentcomponent->addoptlistitem('vmxena', '', 'Disabled'); |
|---|
| 114 |
$currentcomponent->addoptlistitem('vmxena', 'checked', 'Enabled'); |
|---|
| 115 |
$currentcomponent->setoptlistopts('vmxena', 'sort', false); |
|---|
| 116 |
// Yes / No Radio button list |
|---|
| 117 |
$currentcomponent->addoptlistitem('vmyn', 'yes', 'yes'); |
|---|
| 118 |
$currentcomponent->addoptlistitem('vmyn', 'no', 'no'); |
|---|
| 119 |
$currentcomponent->setoptlistopts('vmyn', 'sort', false); |
|---|
| 120 |
|
|---|
| 121 |
// Add the 'proces' function |
|---|
| 122 |
$currentcomponent->addguifunc('voicemail_configpageload'); |
|---|
| 123 |
} |
|---|
| 124 |
|
|---|
| 125 |
|
|---|
| 126 |
function voicemail_configpageload() { |
|---|
| 127 |
global $currentcomponent; |
|---|
| 128 |
|
|---|
| 129 |
// Init vars from $_REQUEST[] |
|---|
| 130 |
$action = isset($_REQUEST['action'])?$_REQUEST['action']:null; |
|---|
| 131 |
$ext = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:null; |
|---|
| 132 |
$extn = isset($_REQUEST['extension'])?$_REQUEST['extension']:null; |
|---|
| 133 |
$display = isset($_REQUEST['display'])?$_REQUEST['display']:null; |
|---|
| 134 |
|
|---|
| 135 |
if ($ext==='') { |
|---|
| 136 |
$extdisplay = $extn; |
|---|
| 137 |
} else { |
|---|
| 138 |
$extdisplay = $ext; |
|---|
| 139 |
} |
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
if ($action != 'del') { |
|---|
| 143 |
$vmbox = voicemail_mailbox_get($extdisplay); |
|---|
| 144 |
if ( $vmbox == null ) { |
|---|
| 145 |
$vm = false; |
|---|
| 146 |
$incontext = 'default'; |
|---|
| 147 |
$vmpwd = null; |
|---|
| 148 |
$name = null; |
|---|
| 149 |
$email = null; |
|---|
| 150 |
$pager = null; |
|---|
| 151 |
$vmoptions = null; |
|---|
| 152 |
|
|---|
| 153 |
$vmx_state = ''; |
|---|
| 154 |
} else { |
|---|
| 155 |
$incontext = isset($vmbox['vmcontext'])?$vmbox['vmcontext']:'default'; |
|---|
| 156 |
$vmpwd = $vmbox['pwd']; |
|---|
| 157 |
$name = $vmbox['name']; |
|---|
| 158 |
$email = $vmbox['email']; |
|---|
| 159 |
$pager = $vmbox['pager']; |
|---|
| 160 |
$vmoptions = $vmbox['options']; |
|---|
| 161 |
$vm = true; |
|---|
| 162 |
|
|---|
| 163 |
$vmx_state = voicemail_vmxGet($extdisplay); |
|---|
| 164 |
} |
|---|
| 165 |
|
|---|
| 166 |
//loop through all options |
|---|
| 167 |
$options=""; |
|---|
| 168 |
if ( isset($vmoptions) && is_array($vmoptions) ) { |
|---|
| 169 |
$alloptions = array_keys($vmoptions); |
|---|
| 170 |
if (isset($alloptions)) { |
|---|
| 171 |
foreach ($alloptions as $option) { |
|---|
| 172 |
if ( ($option!="attach") && ($option!="envelope") && ($option!="saycid") && ($option!="delete") && ($option!='') ) |
|---|
| 173 |
$options .= $option.'='.$vmoptions[$option].'|'; |
|---|
| 174 |
} |
|---|
| 175 |
$options = rtrim($options,'|'); |
|---|
| 176 |
// remove the = sign if there are no options set |
|---|
| 177 |
$options = rtrim($options,'='); |
|---|
| 178 |
|
|---|
| 179 |
} |
|---|
| 180 |
extract($vmoptions, EXTR_PREFIX_ALL, "vmops"); |
|---|
| 181 |
} else { |
|---|
| 182 |
$vmops_attach = 'no'; |
|---|
| 183 |
$vmops_saycid = 'no'; |
|---|
| 184 |
$vmops_envelope = 'no'; |
|---|
| 185 |
$vmops_delete = 'no'; |
|---|
| 186 |
} |
|---|
| 187 |
|
|---|
| 188 |
if (empty($vmcontext)) |
|---|
| 189 |
$vmcontext = (isset($_REQUEST['vmcontext']) ? $_REQUEST['vmcontext'] : $incontext); |
|---|
| 190 |
if (empty($vmcontext)) |
|---|
| 191 |
$vmcontext = 'default'; |
|---|
| 192 |
|
|---|
| 193 |
if ( $vm==true ) { |
|---|
| 194 |
$vmselect = "enabled"; |
|---|
| 195 |
} else { |
|---|
| 196 |
$vmselect = "disabled"; |
|---|
| 197 |
} |
|---|
| 198 |
|
|---|
| 199 |
$fc_vm = featurecodes_getFeatureCode('voicemail', 'dialvoicemail'); |
|---|
| 200 |
|
|---|
| 201 |
$msgInvalidVmPwd = 'Please enter a valid Voicemail Password, using digits only'; |
|---|
| 202 |
$msgInvalidEmail = 'Please enter a valid Email Address'; |
|---|
| 203 |
$msgInvalidPager = 'Please enter a valid Pager Email Address'; |
|---|
| 204 |
$msgInvalidVMContext = 'VM Context cannot be blank'; |
|---|
| 205 |
|
|---|
| 206 |
$section = 'Voicemail & Directory'; |
|---|
| 207 |
$currentcomponent->addguielem($section, new gui_selectbox('vm', $currentcomponent->getoptlist('vmena'), $vmselect, 'Status', '', false)); |
|---|
| 208 |
$currentcomponent->addguielem($section, new gui_textbox('vmpwd', $vmpwd, 'voicemail password', "This is the password used to access the voicemail system.<br><br>This password can only contain numbers.<br><br>A user can change the password you enter here after logging into the voicemail system ($fc_vm) with a phone.", "frm_${display}_isVoiceMailEnabled() && !isInteger()", $msgInvalidVmPwd, false)); |
|---|
| 209 |
$currentcomponent->addguielem($section, new gui_textbox('email', $email, 'email address', "The email address that voicemails are sent to.", "frm_${display}_isVoiceMailEnabled() && !isEmail()", $msgInvalidEmail, true)); |
|---|
| 210 |
$currentcomponent->addguielem($section, new gui_textbox('pager', $pager, 'pager email address', "Pager/mobile email address that short voicemail notifcations are sent to.", "frm_${display}_isVoiceMailEnabled() && !isEmail()", $msgInvalidEmail, true)); |
|---|
| 211 |
$currentcomponent->addguielem($section, new gui_radio('attach', $currentcomponent->getoptlist('vmyn'), $vmops_attach, 'email attachment', "Option to attach voicemails to email.")); |
|---|
| 212 |
$currentcomponent->addguielem($section, new gui_radio('saycid', $currentcomponent->getoptlist('vmyn'), $vmops_saycid, 'Play CID', "Read back caller's telephone number prior to playing the incoming message, and just after announcing the date and time the message was left.")); |
|---|
| 213 |
$currentcomponent->addguielem($section, new gui_radio('envelope', $currentcomponent->getoptlist('vmyn'), $vmops_envelope, 'Play Envelope', "Envelope controls whether or not the voicemail system will play the message envelope (date/time) before playing the voicemail message. This settng does not affect the operation of the envelope option in the advanced voicemail menu.")); |
|---|
| 214 |
$currentcomponent->addguielem($section, new gui_radio('delete', $currentcomponent->getoptlist('vmyn'), $vmops_delete, 'Delete Vmail', "If set to \"yes\" the message will be deleted from the voicemailbox (after having been emailed). Provides functionality that allows a user to receive their voicemail via email alone, rather than having the voicemail able to be retrieved from the Webinterface or the Extension handset. CAUTION: MUST HAVE attach voicemail to email SET TO YES OTHERWISE YOUR MESSAGES WILL BE LOST FOREVER.")); |
|---|
| 215 |
$currentcomponent->addguielem($section, new gui_textbox('options', $options, 'vm options', 'Separate options with pipe ( | )<br><br>ie: review=yes|maxmessage=60')); |
|---|
| 216 |
$currentcomponent->addguielem($section, new gui_textbox('vmcontext', $vmcontext, 'vm context', '', "frm_${display}_isVoiceMailEnabled() && isEmpty()", $msgInvalidVMContext, false)); |
|---|
| 217 |
$currentcomponent->addguielem($section, new gui_selectbox('vmx_state', $currentcomponent->getoptlist('vmxena'), $vmx_state, 'VmX IVR', 'Enable/Disable the Extended Voicemail IVR ability on this extension. Defaults will be set an d the user can make changes in the ARI or equivalent portal. Unchecking will disabled the feature but not delete any existing settings', false)); |
|---|
| 218 |
} |
|---|
| 219 |
} |
|---|
| 220 |
|
|---|
| 221 |
function voicemail_configprocess() { |
|---|
| 222 |
//create vars from the request |
|---|
| 223 |
extract($_REQUEST); |
|---|
| 224 |
$action = isset($_REQUEST['action'])?$_REQUEST['action']:null; |
|---|
| 225 |
$extdisplay = isset($_REQUEST['extdisplay'])?$_REQUEST['extdisplay']:null; |
|---|
| 226 |
|
|---|
| 227 |
//if submitting form, update database |
|---|
| 228 |
switch ($action) { |
|---|
| 229 |
case "add": |
|---|
| 230 |
voicemail_mailbox_add($extdisplay, $_REQUEST); |
|---|
| 231 |
needreload(); |
|---|
| 232 |
break; |
|---|
| 233 |
case "del": |
|---|
| 234 |
// call remove before del, it needs to know context info |
|---|
| 235 |
// |
|---|
| 236 |
voicemail_mailbox_remove($extdisplay); |
|---|
| 237 |
voicemail_mailbox_del($extdisplay); |
|---|
| 238 |
needreload(); |
|---|
| 239 |
break; |
|---|
| 240 |
case "edit": |
|---|
| 241 |
voicemail_mailbox_del($extdisplay); |
|---|
| 242 |
if ( $vm != 'disabled' ) |
|---|
| 243 |
voicemail_mailbox_add($extdisplay, $_REQUEST); |
|---|
| 244 |
needreload(); |
|---|
| 245 |
break; |
|---|
| 246 |
} |
|---|
| 247 |
} |
|---|
| 248 |
|
|---|
| 249 |
function voicemail_mailbox_get($mbox) { |
|---|
| 250 |
$uservm = voicemail_getVoicemail(); |
|---|
| 251 |
$vmcontexts = array_keys($uservm); |
|---|
| 252 |
|
|---|
| 253 |
foreach ($vmcontexts as $vmcontext) { |
|---|
| 254 |
if(isset($uservm[$vmcontext][$mbox])){ |
|---|
| 255 |
$vmbox['vmcontext'] = $vmcontext; |
|---|
| 256 |
$vmbox['pwd'] = $uservm[$vmcontext][$mbox]['pwd']; |
|---|
| 257 |
$vmbox['name'] = $uservm[$vmcontext][$mbox]['name']; |
|---|
| 258 |
$vmbox['email'] = $uservm[$vmcontext][$mbox]['email']; |
|---|
| 259 |
$vmbox['pager'] = $uservm[$vmcontext][$mbox]['pager']; |
|---|
| 260 |
$vmbox['options'] = $uservm[$vmcontext][$mbox]['options']; |
|---|
| 261 |
return $vmbox; |
|---|
| 262 |
} |
|---|
| 263 |
} |
|---|
| 264 |
|
|---|
| 265 |
return null; |
|---|
| 266 |
} |
|---|
| 267 |
|
|---|
| 268 |
function voicemail_mailbox_remove($mbox) { |
|---|
| 269 |
global $amp_conf; |
|---|
| 270 |
$uservm = voicemail_getVoicemail(); |
|---|
| 271 |
$vmcontexts = array_keys($uservm); |
|---|
| 272 |
|
|---|
| 273 |
$return = true; |
|---|
| 274 |
|
|---|
| 275 |
foreach ($vmcontexts as $vmcontext) { |
|---|
| 276 |
if(isset($uservm[$vmcontext][$mbox])){ |
|---|
| 277 |
|
|---|
| 278 |
$vm_dir = $amp_conf['ASTSPOOLDIR']."/voicemail/$vmcontext/$mbox"; |
|---|
| 279 |
exec("rm -rf $vm_dir",$output,$ret); |
|---|
| 280 |
if ($ret) { |
|---|
| 281 |
$return = false; |
|---|
| 282 |
$text = sprintf(_("Failed to delete vmbox: %s@%s"),$mbox, $vmcontext); |
|---|
| 283 |
$etext = sprintf(_("failed with retcode %s while removing %s:"),$ret, $vm_dir)."<br>"; |
|---|
| 284 |
$etext .= implode("<br>",$output); |
|---|
| 285 |
$nt =& notifications::create($db); |
|---|
| 286 |
$nt->add_error('voicemail', 'MBOXREMOVE', $text, $etext, '', true, true); |
|---|
| 287 |
// |
|---|
| 288 |
// TODO: this does not work but we should give some sort of feedback that id did not work |
|---|
| 289 |
// |
|---|
| 290 |
// echo "<script>javascript:alert('$text\n"._("See notification panel for details")."')</script>"; |
|---|
| 291 |
} |
|---|
| 292 |
} |
|---|
| 293 |
} |
|---|
| 294 |
return $return; |
|---|
| 295 |
} |
|---|
| 296 |
|
|---|
| 297 |
function voicemail_mailbox_del($mbox) { |
|---|
| 298 |
$uservm = voicemail_getVoicemail(); |
|---|
| 299 |
$vmcontexts = array_keys($uservm); |
|---|
| 300 |
|
|---|
| 301 |
foreach ($vmcontexts as $vmcontext) { |
|---|
| 302 |
if(isset($uservm[$vmcontext][$mbox])){ |
|---|
| 303 |
unset($uservm[$vmcontext][$mbox]); |
|---|
| 304 |
voicemail_saveVoicemail($uservm); |
|---|
| 305 |
return true; |
|---|
| 306 |
} |
|---|
| 307 |
} |
|---|
| 308 |
|
|---|
| 309 |
return false; |
|---|
| 310 |
} |
|---|
| 311 |
|
|---|
| 312 |
function voicemail_mailbox_add($mbox, $mboxoptsarray) { |
|---|
| 313 |
//check if VM box already exists |
|---|
| 314 |
if ( voicemail_mailbox_get($mbox) != null ) { |
|---|
| 315 |
trigger_error("Voicemail mailbox '$mbox' already exists, call to voicemail_maibox_add failed"); |
|---|
| 316 |
die_freepbx(); |
|---|
| 317 |
} |
|---|
| 318 |
|
|---|
| 319 |
$uservm = voicemail_getVoicemail(); |
|---|
| 320 |
extract($mboxoptsarray); |
|---|
| 321 |
|
|---|
| 322 |
if ($vm != 'disabled') |
|---|
| 323 |
{ |
|---|
| 324 |
// need to check if there are any options entered in the text field |
|---|
| 325 |
if ($options!=''){ |
|---|
| 326 |
$options = explode("|",$options); |
|---|
| 327 |
foreach($options as $option) { |
|---|
| 328 |
$vmoption = explode("=",$option); |
|---|
| 329 |
$vmoptions[$vmoption[0]] = $vmoption[1]; |
|---|
| 330 |
} |
|---|
| 331 |
} |
|---|
| 332 |
$vmoption = explode("=",$attach); |
|---|
| 333 |
$vmoptions[$vmoption[0]] = $vmoption[1]; |
|---|
| 334 |
$vmoption = explode("=",$saycid); |
|---|
| 335 |
$vmoptions[$vmoption[0]] = $vmoption[1]; |
|---|
| 336 |
$vmoption = explode("=",$envelope); |
|---|
| 337 |
$vmoptions[$vmoption[0]] = $vmoption[1]; |
|---|
| 338 |
$vmoption = explode("=",$delete); |
|---|
| 339 |
$vmoptions[$vmoption[0]] = $vmoption[1]; |
|---|
| 340 |
|
|---|
| 341 |
$uservm[$vmcontext][$extension] = array( |
|---|
| 342 |
'mailbox' => $extension, |
|---|
| 343 |
'pwd' => $vmpwd, |
|---|
| 344 |
'name' => $name, |
|---|
| 345 |
'email' => $email, |
|---|
| 346 |
'pager' => $pager, |
|---|
| 347 |
'options' => $vmoptions |
|---|
| 348 |
); |
|---|
| 349 |
// Update $_REQUEST with 'devinfo_mailbox, so MWI works. |
|---|
| 350 |
if (empty($_REQUEST['devinfo_mailbox'])) { |
|---|
| 351 |
$_REQUEST['devinfo_mailbox']="$extension@$vmcontext"; |
|---|
| 352 |
} |
|---|
| 353 |
} |
|---|
| 354 |
voicemail_saveVoicemail($uservm); |
|---|
| 355 |
} |
|---|
| 356 |
|
|---|
| 357 |
function voicemail_saveVoicemail($vmconf) { |
|---|
| 358 |
global $amp_conf; |
|---|
| 359 |
|
|---|
| 360 |
// just in case someone tries to be sneaky and not call getVoicemail() first.. |
|---|
| 361 |
if ($vmconf == null) die_freepbx('Error: Trying to write null voicemail file! I refuse to contiune!'); |
|---|
| 362 |
|
|---|
| 363 |
// yes, this is hardcoded.. is this a bad thing? |
|---|
| 364 |
write_voicemailconf(rtrim($amp_conf["ASTETCDIR"],"/")."/voicemail.conf", $vmconf, $section); |
|---|
| 365 |
} |
|---|
| 366 |
|
|---|
| 367 |
function voicemail_getVoicemail() { |
|---|
| 368 |
global $amp_conf; |
|---|
| 369 |
|
|---|
| 370 |
$vmconf = null; |
|---|
| 371 |
$section = null; |
|---|
| 372 |
|
|---|
| 373 |
// yes, this is hardcoded.. is this a bad thing? |
|---|
| 374 |
parse_voicemailconf(rtrim($amp_conf["ASTETCDIR"],"/")."/voicemail.conf", $vmconf, $section); |
|---|
| 375 |
|
|---|
| 376 |
return $vmconf; |
|---|
| 377 |
} |
|---|
| 378 |
|
|---|
| 379 |
function voicemail_vmxGet($extension) { |
|---|
| 380 |
global $astman; |
|---|
| 381 |
|
|---|
| 382 |
// Retrieve the state |
|---|
| 383 |
$vmx_state=$astman->database_get("AMPUSER",$extension."/vmx/unavail/state"); |
|---|
| 384 |
if (isset($vmx_state) && (trim($vmx_state) == 'enabled' || trim($vmx_state) == 'disabled')) { |
|---|
| 385 |
$vmx_state='checked'; |
|---|
| 386 |
} else { |
|---|
| 387 |
$vmx_state=''; |
|---|
| 388 |
} |
|---|
| 389 |
|
|---|
| 390 |
return $vmx_state; |
|---|
| 391 |
} |
|---|
| 392 |
|
|---|
| 393 |
|
|---|
| 394 |
?> |
|---|