示例#1
0
function voicemail_configpageload()
{
    global $currentcomponent;
    // Init vars from $_REQUEST[]
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $ext = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
    $extn = isset($_REQUEST['extension']) ? $_REQUEST['extension'] : null;
    $display = isset($_REQUEST['display']) ? $_REQUEST['display'] : null;
    if ($ext === '') {
        $extdisplay = $extn;
    } else {
        $extdisplay = $ext;
    }
    if ($action != 'del') {
        $vmbox = voicemail_mailbox_get($extdisplay);
        if ($vmbox == null) {
            $vm = false;
            $incontext = 'default';
            $vmpwd = null;
            $name = null;
            $email = null;
            $pager = null;
            $vmoptions = null;
            $vmx_state = '';
        } else {
            $incontext = isset($vmbox['vmcontext']) ? $vmbox['vmcontext'] : 'default';
            $vmpwd = $vmbox['pwd'];
            $name = $vmbox['name'];
            $email = $vmbox['email'];
            $pager = $vmbox['pager'];
            $vmoptions = $vmbox['options'];
            $vm = true;
            $vmxobj = new vmxObject($extdisplay);
            $vmx_state = $vmxobj->isEnabled() ? 'checked' : '';
            unset($vmxobj);
        }
        //loop through all options
        $options = "";
        if (isset($vmoptions) && is_array($vmoptions)) {
            $alloptions = array_keys($vmoptions);
            if (isset($alloptions)) {
                foreach ($alloptions as $option) {
                    if ($option != "attach" && $option != "envelope" && $option != "saycid" && $option != "delete" && $option != "imapuser" && $option != "imappassword" && $option != '') {
                        $options .= $option . '=' . $vmoptions[$option] . '|';
                    }
                }
                $options = rtrim($options, '|');
                // remove the = sign if there are no options set
                $options = rtrim($options, '=');
            }
            extract($vmoptions, EXTR_PREFIX_ALL, "vmops");
        } else {
            $vmops_attach = 'no';
            $vmops_saycid = 'no';
            $vmops_envelope = 'no';
            $vmops_delete = 'no';
            $vmops_imapuser = null;
            $vmops_imappassword = null;
        }
        if (empty($vmcontext)) {
            $vmcontext = isset($_REQUEST['vmcontext']) ? $_REQUEST['vmcontext'] : $incontext;
        }
        if (empty($vmcontext)) {
            $vmcontext = 'default';
        }
        if ($vm == true) {
            $vmselect = "enabled";
        } else {
            $vmselect = "disabled";
        }
        $fc_vm = featurecodes_getFeatureCode('voicemail', 'dialvoicemail');
        $msgInvalidVmPwd = _("Please enter a valid Voicemail Password, using digits only");
        $msgInvalidEmail = _("Please enter a valid Email Address");
        $msgInvalidPager = _("Please enter a valid Pager Email Address");
        $msgInvalidVMContext = _("VM Context cannot be blank");
        $vmops_imapuser = '';
        $vmops_imappassword = '';
        $section = _("Voicemail & Directory");
        $currentcomponent->addguielem($section, new gui_selectbox('vm', $currentcomponent->getoptlist('vmena'), $vmselect, _('Status'), '', false, "frm_{$display}_voicemailEnabled() && frm_{$display}_vmx_disable_fields()"));
        $disable = $vmselect == 'disabled';
        $currentcomponent->addguielem($section, new gui_textbox('vmpwd', $vmpwd, _('Voicemail Password'), sprintf(_("This is the password used to access the voicemail system.%sThis password can only contain numbers.%sA user can change the password you enter here after logging into the voicemail system (%s) with a phone."), "<br /><br />", "<br /><br />", $fc_vm), "frm_{$display}_isVoiceMailEnabled() && !frm_{$display}_verifyEmptyVoiceMailPassword() && !isInteger()", $msgInvalidVmPwd, false, 0, $disable));
        $currentcomponent->addguielem($section, new gui_textbox('email', $email, _('Email Address'), _("The email address that voicemails are sent to."), "frm_{$display}_isVoiceMailEnabled() && !isEmail()", $msgInvalidEmail, true, 0, $disable));
        $currentcomponent->addguielem($section, new gui_textbox('pager', $pager, _('Pager Email Address'), _("Pager/mobile email address that short voicemail notifications are sent to."), "frm_{$display}_isVoiceMailEnabled() && !isEmail()", $msgInvalidEmail, true, 0, $disable));
        $currentcomponent->addguielem($section, new gui_radio('attach', $currentcomponent->getoptlist('vmyn'), $vmops_attach, _('Email Attachment'), _("Option to attach voicemails to email."), $disable));
        $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."), $disable));
        $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 setting does not affect the operation of the envelope option in the advanced voicemail menu."), $disable));
        $currentcomponent->addguielem($section, new gui_radio('delete', $currentcomponent->getoptlist('vmyn'), $vmops_delete, _('Delete Voicemail'), _("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."), $disable));
        $currentcomponent->addguielem($section, new gui_textbox('imapuser', $vmops_imapuser, _('IMAP Username'), sprintf(_("This is the IMAP username, if using IMAP storage"), "<br /><br />"), '', '', true, 0, $disable));
        $currentcomponent->addguielem($section, new gui_textbox('imappassword', $vmops_imappassword, _('IMAP Password'), sprintf(_("This is the IMAP password, if using IMAP storage"), "<br /><br />"), '', '', true, 0, $disable));
        $currentcomponent->addguielem($section, new gui_textbox('options', $options, _('VM Options'), sprintf(_("Separate options with pipe ( | )%sie: review=yes|maxmessage=60"), "<br /><br />"), '', '', true, 0, $disable));
        $currentcomponent->addguielem($section, new gui_textbox('vmcontext', $vmcontext, _('VM Context'), _("This is the Voicemail Context which is normally set to default. Do not change unless you understand the implications."), "frm_{$display}_isVoiceMailEnabled() && isEmpty()", $msgInvalidVMContext, false, 0, $disable));
        $section = _("VmX Locater");
        $currentcomponent->addguielem($section, new gui_selectbox('vmx_state', $currentcomponent->getoptlist('vmxena'), $vmx_state, _('VmX Locater&trade;'), _("Enable/Disable the VmX Locater feature for this user. When enabled all settings are controlled by the user in the User Portal (ARI). Disabling will not delete any existing user settings but will disable access to the feature"), false, "frm_{$display}_vmx_disable_fields()", $disable), 5, 6);
        $vmxhtml = voicemail_draw_vmxgui($extdisplay, $disable);
        $vmxhtml = '<tr><td colspan="2"><table>' . $vmxhtml . '</table></td></tr>';
        $msgValidNumber = _("Please enter a valid phone number using number digits only");
        $vmxcustom_validate = "\n\t\tdefaultEmptyOK = true;\n\t\tif (!theForm.vmx_option_0_system_default.checked && !isInteger(theForm.vmx_option_0_number.value)) \n\t\t\treturn warnInvalid(theForm.vmx_option_0_number, '{$msgValidNumber}');\n\t\tif (theForm.vmx_option_1_system_default != undefined && !theForm.vmx_option_1_system_default.checked && !isInteger(theForm.vmx_option_1_number.value)) \n\t\t\treturn warnInvalid(theForm.vmx_option_1_number, '{$msgValidNumber}');\n\t\tif (!isInteger(theForm.vmx_option_2_number.value)) \n\t\t\treturn warnInvalid(theForm.vmx_option_2_number, '{$msgValidNumber}');\n\t\t";
        $currentcomponent->addguielem($section, new guielement('vmxcustom', $vmxhtml, "{$vmxcustom_validate}"), 6, 6);
    }
}
function voicemail_configpageload()
{
    global $currentcomponent;
    global $amp_conf;
    global $astman;
    // Init vars from $_REQUEST[]
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $ext = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
    $extn = isset($_REQUEST['extension']) ? $_REQUEST['extension'] : null;
    $display = isset($_REQUEST['display']) ? $_REQUEST['display'] : null;
    if ($ext === '') {
        $extdisplay = $extn;
    } else {
        $extdisplay = $ext;
    }
    if ($action != 'del') {
        $vmbox = voicemail_mailbox_get($extdisplay);
        if ($vmbox == null) {
            $vm = false;
            $incontext = 'default';
            $vmpwd = null;
            $name = null;
            $email = null;
            $pager = null;
            $vmoptions = null;
        } else {
            $incontext = isset($vmbox['vmcontext']) ? $vmbox['vmcontext'] : 'default';
            $vmpwd = $vmbox['pwd'];
            $name = $vmbox['name'];
            $email = $vmbox['email'];
            $pager = $vmbox['pager'];
            $vmoptions = $vmbox['options'];
            $vm = true;
        }
        //loop through all options
        $options = "";
        if (isset($vmoptions) && is_array($vmoptions)) {
            $alloptions = array_keys($vmoptions);
            if (isset($alloptions)) {
                foreach ($alloptions as $option) {
                    if ($option != "attach" && $option != "envelope" && $option != "passlogin" && $option != "novmstar" && $option != "saycid" && $option != "delete" && $option != "imapuser" && $option != "imappassword" && $option != '') {
                        $options .= $option . '=' . $vmoptions[$option] . '|';
                    }
                }
                $options = rtrim($options, '|');
                // remove the = sign if there are no options set
                $options = rtrim($options, '=');
            }
            extract($vmoptions, EXTR_PREFIX_ALL, "vmops");
        } else {
            $vmops_novmstar = 'no';
            $vmops_passlogin = '******';
            $vmops_attach = 'no';
            $vmops_saycid = 'no';
            $vmops_envelope = 'no';
            $vmops_delete = 'no';
            $vmops_imapuser = null;
            $vmops_imappassword = null;
        }
        if (empty($vmcontext)) {
            $vmcontext = isset($_REQUEST['vmcontext']) ? $_REQUEST['vmcontext'] : $incontext;
        }
        if (empty($vmcontext)) {
            $vmcontext = 'default';
        }
        if ($vm == true) {
            $vmselect = "enabled";
        } else {
            $vmselect = "disabled";
        }
        $fc_vm = featurecodes_getFeatureCode('voicemail', 'dialvoicemail');
        $msgInvalidVmPwd = _("Please enter a valid Voicemail Password, using digits only");
        $msgInvalidEmail = _("Please enter a valid Email Address");
        $msgInvalidPager = _("Please enter a valid Pager Email Address");
        $msgInvalidVMContext = _("VM Context cannot be blank");
        $vmops_imapuser = isset($vmops_imapuser) ? $vmops_imapuser : '';
        $vmops_imappassword = isset($vmops_imappassword) ? $vmops_imappassword : '';
        $section = _("Voicemail");
        $class = "fpbx-voicemail";
        $category = "voicemail";
        $guidefaults = array("elemname" => "", "prompttext" => "", "helptext" => "", "currentvalue" => "", "valarray" => array(), "jsonclick" => '', "jsvalidation" => "", "failvalidationmsg" => "", "canbeempty" => true, "maxchars" => 0, "disable" => false, "inputgroup" => false, "class" => "");
        $el = array("elemname" => "vm", "prompttext" => _('Enabled'), "currentvalue" => $vmselect, "valarray" => $currentcomponent->getoptlist('vmena'), "jsonclick" => "frm_{$display}_voicemailEnabled() && frm_{$display}_vmxEnabled()", "pairedvalues" => false);
        $currentcomponent->addguielem($section, new gui_radio(array_merge($guidefaults, $el)), $category);
        $disable = $vmselect == 'disabled';
        $el = array("elemname" => "vmpwd", "prompttext" => _('Voicemail Password'), "helptext" => sprintf(_("This is the password used to access the Voicemail system.%sThis password can only contain numbers.%sA user can change the password you enter here after logging into the Voicemail system (%s) with a phone."), "<br /><br />", "<br /><br />", $fc_vm), "currentvalue" => $vmpwd, "jsvalidation" => "frm_{$display}_isVoiceMailEnabled() && !frm_{$display}_isValidVoicemailPass()", "failvalidationmsg" => $msgInvalidVmPwd, "canbeempty" => false, "class" => $class, "disable" => $disable, "passwordToggle" => true);
        $currentcomponent->addguielem($section, new gui_password(array_merge($guidefaults, $el)), $category);
        //for passwordless voicemail we need to check some settings
        //first lets see if there is an entry in the asteriskDB for this device
        //no entry in the db is the same as yes, meaning we need a voicemail password
        $passlogin = !empty($extdisplay) ? $astman->connected() && $astman->database_get("AMPUSER", $extdisplay . "/novmpw") : 'yes';
        $passlogin = !empty($passlogin) ? 'no' : 'yes';
        //now lets get our featurecodes for helptext display niceties
        $mvm = new featurecode('voicemail', 'myvoicemail');
        $dvm = new featurecode('voicemail', 'dialvoicemail');
        $extword = $display == 'extensions' ? _('Extension') : _('Device');
        $display_mode = "advanced";
        $mode = \FreePBX::Config()->get("FPBXOPMODE");
        if (!empty($mode)) {
            $display_mode = $mode;
        }
        if ($display_mode == "basic") {
            $tb = $rb = "gui_hidden";
        } else {
            $tb = "gui_textbox";
            $rb = "gui_radio";
        }
        $el = array("elemname" => "passlogin", "prompttext" => sprintf(_('Require From Same %s'), $extword), "helptext" => sprintf(_("If set to \"no\" then when the user dials %s to access their own voicemail, they will not be asked to enter a password. This does not apply to %s calls, which will always prompt for a password. For security reasons, this should probably be set to \"yes\" in an environment where other users will have physical access to this extension."), $mvm->getCode(), $dvm->getCode()), "currentvalue" => $passlogin, "valarray" => $currentcomponent->getoptlist('vmyn'), "disable" => $disable, "class" => $class);
        $currentcomponent->addguielem($section, new $rb(array_merge($guidefaults, $el)), $category);
        $novmstar = !empty($extdisplay) ? $astman->connected() && $astman->database_get("AMPUSER", $extdisplay . "/novmstar") : 'yes';
        $novmstar = !empty($novmstar) ? 'yes' : 'no';
        $el = array("elemname" => "novmstar", "prompttext" => _("Disable (*) in Voicemail Menu"), "helptext" => sprintf(_("If set to \"yes\" then when someone dials this voicemail box they will not be able to access the voicemail menu by pressing (*). If you have no plans to access your mailbox remotely set this to \"yes\""), $mvm->getCode(), $dvm->getCode()), "currentvalue" => $novmstar, "valarray" => $currentcomponent->getoptlist('vmyn'), "disable" => $disable, "class" => $class);
        $currentcomponent->addguielem($section, new $rb(array_merge($guidefaults, $el)), $category);
        $el = array("elemname" => "email", "prompttext" => _('Email Address'), "helptext" => _("The email address that Voicemails are sent to."), "currentvalue" => $email, "jsvalidation" => "frm_{$display}_isVoiceMailEnabled() && frm_{$display}_isEmailAttachment() && !isEmail()", "failvalidationmsg" => $msgInvalidEmail, "canbeempty" => false, "class" => $class, "disable" => $disable);
        $currentcomponent->addguielem($section, new gui_textbox(array_merge($guidefaults, $el)), $category);
        $el = array("elemname" => "pager", "prompttext" => _('Pager Email Address'), "helptext" => _("Pager/mobile email address that short Voicemail notifications are sent to."), "currentvalue" => $pager, "jsvalidation" => "frm_{$display}_isVoiceMailEnabled() && !isEmpty() && !isEmail()", "failvalidationmsg" => $msgInvalidEmail, "canbeempty" => false, "class" => $class, "disable" => $disable);
        $currentcomponent->addguielem($section, new $tb(array_merge($guidefaults, $el)), $category);
        $el = array("elemname" => "attach", "prompttext" => _('Email Attachment'), "helptext" => _("Option to attach Voicemails to email."), "currentvalue" => $vmops_attach, "valarray" => $currentcomponent->getoptlist('vmyn'), "disable" => $disable, "class" => $class);
        $currentcomponent->addguielem($section, new $rb(array_merge($guidefaults, $el)), $category);
        $el = array("elemname" => "saycid", "prompttext" => _('Play CID'), "helptext" => _("Read back caller's telephone number prior to playing the incoming message, and just after announcing the date and time the message was left."), "currentvalue" => $vmops_saycid, "valarray" => $currentcomponent->getoptlist('vmyn'), "disable" => $disable, "class" => $class);
        $currentcomponent->addguielem($section, new $rb(array_merge($guidefaults, $el)), $category);
        $el = array("elemname" => "envelope", "prompttext" => _('Play Envelope'), "helptext" => _("Envelope controls whether or not the Voicemail system will play the message envelope (date/time) before playing the Voicemail message. This setting does not affect the operation of the envelope option in the advanced Voicemail menu."), "currentvalue" => $vmops_envelope, "valarray" => $currentcomponent->getoptlist('vmyn'), "disable" => $disable, "class" => $class);
        $currentcomponent->addguielem($section, new $rb(array_merge($guidefaults, $el)), $category);
        $el = array("elemname" => "vmdelete", "prompttext" => _('Delete Voicemail'), "helptext" => _("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."), "currentvalue" => $vmops_delete, "valarray" => $currentcomponent->getoptlist('vmyn'), "disable" => $disable, "class" => $class);
        $currentcomponent->addguielem($section, new $rb(array_merge($guidefaults, $el)), $category);
        if ($amp_conf['VM_SHOW_IMAP'] || $vmops_imapuser || $vmops_imappassword) {
            $el = array("elemname" => "imapuser", "prompttext" => _('IMAP Username'), "helptext" => sprintf(_("This is the IMAP username, if using IMAP storage"), "<br /><br />"), "currentvalue" => $vmops_imapuser, "class" => $class, "disable" => $disable);
            $currentcomponent->addguielem($section, new $tb(array_merge($guidefaults, $el)), $category);
            $el = array("elemname" => "imappassword", "prompttext" => _('IMAP Password'), "helptext" => sprintf(_("This is the IMAP password, if using IMAP storage"), "<br /><br />"), "currentvalue" => $vmops_imapuser, "class" => $class, "disable" => $disable);
            $currentcomponent->addguielem($section, new $tb(array_merge($guidefaults, $el)), $category);
        }
        $el = array("elemname" => "options", "prompttext" => _('VM Options'), "helptext" => sprintf(_("Separate options with pipe ( | )%sie: review=yes|maxmessage=60"), "<br /><br />"), "currentvalue" => $options, "class" => $class, "disable" => $disable);
        $currentcomponent->addguielem($section, new $tb(array_merge($guidefaults, $el)), $category);
        $el = array("elemname" => "vmcontext", "prompttext" => _('VM Context'), "helptext" => _("This is the Voicemail Context which is normally set to default. Do not change unless you understand the implications."), "currentvalue" => $incontext, "class" => $class, "disable" => $disable, "jsvalidation" => "frm_{$display}_isVoiceMailEnabled() && isEmpty()", "failvalidationmsg" => $msgInvalidVMContext);
        $currentcomponent->addguielem($section, new $tb(array_merge($guidefaults, $el)), $category);
        voicemail_draw_vmxgui($extdisplay, $disable);
    }
}