示例#1
0
function voicemail_configpageinit($pagename)
{
    global $currentcomponent;
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
    $extension = isset($_REQUEST['extension']) ? $_REQUEST['extension'] : null;
    $tech_hardware = isset($_REQUEST['tech_hardware']) ? $_REQUEST['tech_hardware'] : null;
    // We only want to hook 'users' or 'extensions' pages.
    if ($pagename != 'users' && $pagename != 'extensions') {
        return true;
    }
    if ($tech_hardware != null || $extdisplay != '' || $pagename == 'users') {
        // JS function needed for checking voicemail = Enabled
        $js = 'return (theForm.vm.value == "enabled");';
        $currentcomponent->addjsfunc('isVoiceMailEnabled(notused)', $js);
        // JS for verifying an empty password is OK
        $msg = _('Voicemail is enabled but the Voicemail Password field is empty.  Are you sure you wish to continue?');
        $js = 'if (theForm.vmpwd.value == "") { if(confirm("' . $msg . '")) { return true; } else { return false; }  };';
        $currentcomponent->addjsfunc('verifyEmptyVoiceMailPassword(notused)', $js);
        $js = "\n\t\tif (document.getElementById('vm').value == 'disabled') {\n\t\t\tvar dval=true;\n\t\t\tdocument.getElementById('vmx_state').value='';\n\t\t} else {\n\t\t\tvar dval=false;\n\t\t}\n\t\tdocument.getElementById('vmpwd').disabled=dval;\n\t\tdocument.getElementById('email').disabled=dval;\n\t\tdocument.getElementById('pager').disabled=dval;\n\t\tdocument.getElementById('attach0').disabled=dval;\n\t\tdocument.getElementById('attach1').disabled=dval;\n\t\tdocument.getElementById('saycid0').disabled=dval;\n\t\tdocument.getElementById('saycid1').disabled=dval;\n\t\tdocument.getElementById('envelope0').disabled=dval;\n\t\tdocument.getElementById('envelope1').disabled=dval;\n\t\tdocument.getElementById('delete0').disabled=dval;\n\t\tdocument.getElementById('delete1').disabled=dval;\n\t\tdocument.getElementById('imapuser').disabled=dval; \n\t\tdocument.getElementById('imappassword').disabled=dval; \n\t\tdocument.getElementById('options').disabled=dval;\n\t\tdocument.getElementById('vmcontext').disabled=dval;\n\t\tdocument.getElementById('vmx_state').disabled=dval;\n\t\treturn true;\n\t\t";
        $currentcomponent->addjsfunc('voicemailEnabled(notused)', $js);
        $js = "\n\t\t\tif (document.getElementById('vmx_state').value == 'checked') {\n\t\t\t\tvar dval=false;\n\t\t\t} else {\n\t\t\t\tvar dval=true;\n\t\t\t}\n\t\t\tdocument.getElementById('vmx_unavail_enabled').disabled=dval;\n\t\t\tdocument.getElementById('vmx_busy_enabled').disabled=dval;\n\t\t\tdocument.getElementById('vmx_play_instructions').disabled=dval;\n\t\t";
        $vmxobj = new vmxObject($extdisplay);
        $follow_me_disabled = !$vmxobj->hasFollowMe();
        if (!$follow_me_disabled) {
            $js .= "\n\t\t\tdocument.getElementById('vmx_option_1_system_default').disabled=dval;\n\t\t";
        }
        $js .= "\n\t\t\tdocument.getElementById('vmx_option_1_number').disabled=dval;\n\t\t\tdocument.getElementById('vmx_option_2_number').disabled=dval;\n\t\n\t\t\tif (document.getElementById('vm').value == 'disabled') {\n\t\t\t\tdocument.getElementById('vmx_option_0_number').disabled = true;\n\t\t\t\tdocument.getElementById('vmx_option_0_system_default').disabled=true;\n\t\t\t} else {\n\t\t\t\tdocument.getElementById('vmx_option_0_system_default').disabled=false;\n\t\t\t\tif (document.getElementById('vmx_option_0_system_default').checked) {\n\t\t\t\t\tdocument.getElementById('vmx_option_0_number').disabled = true;\n\t\t\t\t} else {\n\t\t\t\t\tdocument.getElementById('vmx_option_0_number').disabled = false;\n\t\t\t\t}\n\t\t\t}\n\t\t";
        if (!$follow_me_disabled) {
            $js .= "\n\t\t\tif (document.getElementById('vmx_state').value == 'checked') {\n\t\t\t\tif (document.getElementById('vmx_option_1_system_default').checked) {\n\t\t\t\t\tdocument.getElementById('vmx_option_1_number').disabled = true;\n\t\t\t\t} else {\n\t\t\t\t\tdocument.getElementById('vmx_option_1_number').disabled = false;\n\t\t\t\t}\n\t\t\t}\n\t\t\t";
        }
        $js .= "\n\t\t\treturn true;\n\t\t";
        $currentcomponent->addjsfunc('vmx_disable_fields(notused)', $js);
    }
    // On a 'new' user, 'tech_hardware' is set, and there's no extension. Hook into the page.
    if ($tech_hardware != null) {
        voicemail_applyhooks();
    } elseif ($action == "add") {
        // We don't need to display anything on an 'add', but we do need to handle returned data.
        // ** WARNING **
        // Mailbox must be processed before adding / deleting users, therefore $sortorder = 1
        //
        // More hacky-ness from components, since this is called first, we need to determine if
        // it there is a conclict indpenendent from the user component so we know if we should
        // redisplay the or not. While we are at it, we won't add the process function if there
        // is a conflict
        //
        if ($_REQUEST['display'] == 'users') {
            $usage_arr = framework_check_extension_usage($_REQUEST['extension']);
            if (empty($usage_arr)) {
                $currentcomponent->addprocessfunc('voicemail_configprocess', 1);
            } else {
                voicemail_applyhooks();
            }
        } else {
            $currentcomponent->addprocessfunc('voicemail_configprocess', 1);
        }
    } elseif ($extdisplay != '' || $pagename == 'users') {
        // We're now viewing an extension, so we need to display _and_ process.
        voicemail_applyhooks();
        $currentcomponent->addprocessfunc('voicemail_configprocess', 1);
    }
}
function voicemail_configpageinit($pagename)
{
    global $currentcomponent;
    global $amp_conf;
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
    $extension = isset($_REQUEST['extension']) ? $_REQUEST['extension'] : null;
    $tech_hardware = isset($_REQUEST['tech_hardware']) ? $_REQUEST['tech_hardware'] : null;
    // We only want to hook 'users' or 'extensions' pages.
    if ($pagename != 'users' && $pagename != 'extensions') {
        return true;
    }
    if ($tech_hardware != null || $extdisplay != '' || $pagename == 'users') {
        // JS function needed for checking voicemail = Enabled
        $js = 'return (theForm.vm.value == "enabled");';
        $currentcomponent->addjsfunc('isVoiceMailEnabled(notused)', $js);
        $js = 'return (theForm.attach.value == "attach=yes");';
        $currentcomponent->addjsfunc('isEmailAttachment(notused)', $js);
        // JS for verifying an empty password is OK
        $msg = _('Voicemail is enabled but the Voicemail Password field is empty.  Are you sure you wish to continue?');
        $js = 'if(theForm.vmpwd.value.match(/^[0-9A-D\\*#]*$/i)) {return true;}else{return false;}';
        $js = 'if (theForm.vmpwd.value == "") { if(confirm("' . $msg . '")) { return true } else { return false; }} else { ' . $js . ' };';
        $currentcomponent->addjsfunc('isValidVoicemailPass(notused)', $js);
        $js = "\n\t\tvar dval = \$('#vm0').prop('checked') ? false : true;\n\t\t\$('.fpbx-voicemail').prop('disabled',dval);\n\t\tif(!\$('html').hasClass('firsttypeofselector')) {\n\t\t\t\$('.radioset').buttonset('refresh');\n\t\t}\n\t\treturn true;\n\t\t";
        $currentcomponent->addjsfunc('voicemailEnabled(notused)', $js);
        $vmxobj = new vmxObject($extdisplay);
        $follow_me_disabled = !$vmxobj->hasFollowMe();
        $js = "\n\t\tvar dval = (\$('#vmx_state0').prop('checked') && !\$('#vmx_state0').is(':disabled')) ? false : true;\n\t\t\$('.vmxgroup').prop('disabled',dval);\n\t\tif(!\$('html').hasClass('firsttypeofselector')) {\n\t\t\t\$('.radioset').buttonset('refresh');\n\t\t}\n\t\treturn true;\n\t\t";
        $currentcomponent->addjsfunc('vmxEnabled(notused)', $js);
    }
    // On a 'new' user, 'tech_hardware' is set, and there's no extension. Hook into the page.
    if ($tech_hardware != null) {
        voicemail_applyhooks();
    } elseif ($action == "add") {
        // We don't need to display anything on an 'add', but we do need to handle returned data.
        // ** WARNING **
        // Mailbox must be processed before adding / deleting users, therefore $sortorder = 1
        //
        // More hacky-ness from components, since this is called first, we need to determine if
        // it there is a conclict indpenendent from the user component so we know if we should
        // redisplay the or not. While we are at it, we won't add the process function if there
        // is a conflict
        //
        if ($_REQUEST['display'] == 'users') {
            $usage_arr = framework_check_extension_usage($_REQUEST['extension']);
            if (empty($usage_arr)) {
                $currentcomponent->addprocessfunc('voicemail_configprocess', 1);
            } else {
                voicemail_applyhooks();
            }
        } else {
            $currentcomponent->addprocessfunc('voicemail_configprocess', 1);
        }
    } elseif ($extdisplay != '' || $pagename == 'users') {
        // We're now viewing an extension, so we need to display _and_ process.
        voicemail_applyhooks();
        $currentcomponent->addprocessfunc('voicemail_configprocess', 1);
    }
}