コード例 #1
0
ファイル: functions.inc.php プロジェクト: hardikk/HNH
function callforward_get_config($engine)
{
    $modulename = 'callforward';
    // This generates the dialplan
    global $ext;
    global $amp_conf;
    global $version;
    global $DEVSTATE;
    switch ($engine) {
        case "asterisk":
            // If Using CF then set this so AGI scripts can determine
            //
            if ($amp_conf['USEDEVSTATE']) {
                $ext->addGlobal('CFDEVSTATE', 'TRUE');
            }
            $DEVSTATE = version_compare($version, "1.6", "ge") ? "DEVICE_STATE" : "DEVSTATE";
            if (is_array($featurelist = featurecodes_getModuleFeatures($modulename))) {
                foreach ($featurelist as $item) {
                    $featurename = $item['featurename'];
                    $fname = $modulename . '_' . $featurename;
                    if (function_exists($fname)) {
                        $fcc = new featurecode($modulename, $featurename);
                        $fc = $fcc->getCodeActive();
                        unset($fcc);
                        if ($fc != '') {
                            $fname($fc);
                        }
                    } else {
                        $ext->add('from-internal-additional', 'debug', '', new ext_noop($modulename . ": No func {$fname}"));
                        var_dump($item);
                    }
                }
            }
            // Create hints context for CF codes so a device can subscribe to the DND state
            //
            $fcc = new featurecode($modulename, 'cf_toggle');
            $cf_code = $fcc->getCodeActive();
            unset($fcc);
            if ($amp_conf['USEDEVSTATE'] && $cf_code != '') {
                $ext->addInclude('from-internal-additional', 'ext-cf-hints');
                $contextname = 'ext-cf-hints';
                $device_list = core_devices_list("all", 'full', true);
                $base_offset = strlen($cf_code);
                foreach ($device_list as $device) {
                    if ($device['tech'] == 'sip' || $device['tech'] == 'iax2') {
                        $offset = $base_offset + strlen($device['id']);
                        $ext->add($contextname, $cf_code . $device['id'], '', new ext_goto("1", $cf_code, "app-cf-toggle"));
                        $ext->add($contextname, '_' . $cf_code . $device['id'] . '.', '', new ext_set("toext", '${EXTEN:' . $offset . '}'));
                        $ext->add($contextname, '_' . $cf_code . $device['id'] . '.', '', new ext_goto("setdirect", $cf_code, "app-cf-toggle"));
                        $ext->addHint($contextname, $cf_code . $device['id'], "Custom:DEVCF" . $device['id']);
                    }
                }
            }
            break;
    }
}
コード例 #2
0
function donotdisturb_get_config($engine)
{
    $modulename = 'donotdisturb';
    // This generates the dialplan
    global $ext;
    global $amp_conf;
    switch ($engine) {
        case "asterisk":
            // If Using DND then set this so AGI scripts can determine
            //
            if ($amp_conf['USEDEVSTATE']) {
                $ext->addGlobal('DNDDEVSTATE', 'TRUE');
            }
            if (is_array($featurelist = featurecodes_getModuleFeatures($modulename))) {
                foreach ($featurelist as $item) {
                    $featurename = $item['featurename'];
                    $fname = $modulename . '_' . $featurename;
                    if (function_exists($fname)) {
                        $fcc = new featurecode($modulename, $featurename);
                        $fc = $fcc->getCodeActive();
                        unset($fcc);
                        if ($fc != '') {
                            $fname($fc);
                        }
                    } else {
                        $ext->add('from-internal-additional', 'debug', '', new ext_noop($modulename . ": No func {$fname}"));
                        var_dump($item);
                    }
                }
            }
            $fcc = new featurecode($modulename, 'dnd_toggle');
            $dnd_code = $fcc->getCodeActive();
            unset($fcc);
            // Create hints context for DND codes so a device can subscribe to the DND state
            //
            if ($amp_conf['USEDEVSTATE'] && $dnd_code != '') {
                $ext->addInclude('from-internal-additional', 'ext-dnd-hints');
                $contextname = 'ext-dnd-hints';
                $device_list = core_devices_list("all", 'full', true);
                $dnd_length = strlen($dnd_code);
                $ext->add($contextname, '_' . $dnd_code . 'X.', '', new ext_goto("1", $dnd_code, "app-dnd-toggle"));
                $ext->addHint($contextname, '_' . $dnd_code . 'X.', "Custom:DEVDND" . '${EXTEN:' . $dnd_length . '}');
                /*
                foreach ($device_list as $device) {
                	if ($device['tech'] == 'sip' || $device['tech'] == 'iax2' || $device['tech'] == 'pjsip') {
                			  $ext->add($contextname, $dnd_code.$device['id'], '', new ext_goto("1",$dnd_code,"app-dnd-toggle"));
                			  $ext->addHint($contextname, $dnd_code.$device['id'], "Custom:DEVDND".$device['id']);
                	}
                }
                */
            }
            break;
    }
}
コード例 #3
0
ファイル: functions.inc.php プロジェクト: hardikk/HNH
function findmefollow_get_config($engine)
{
    global $ext;
    // is this the best way to pass this?
    global $amp_conf;
    switch ($engine) {
        case "asterisk":
            if ($amp_conf['USEDEVSTATE']) {
                $ext->addGlobal('FMDEVSTATE', 'TRUE');
            }
            $fcc = new featurecode('findmefollow', 'fmf_toggle');
            $fmf_code = $fcc->getCodeActive();
            unset($fcc);
            if ($fmf_code != '') {
                findmefollow_fmf_toggle($fmf_code);
            }
            $ext->addInclude('from-internal-additional', 'ext-findmefollow');
            $ext->addInclude('from-internal-additional', 'fmgrps');
            $contextname = 'ext-findmefollow';
            // Before creating all the contexts, let's make a list of hints if needed
            //
            if ($amp_conf['USEDEVSTATE'] && $fmf_code != '') {
                $device_list = core_devices_list("all", 'full', true);
                foreach ($device_list as $device) {
                    if ($device['tech'] == 'sip' || $device['tech'] == 'iax2') {
                        $ext->add($contextname, $fmf_code . $device['id'], '', new ext_goto("1", $fmf_code, "app-fmf-toggle"));
                        $ext->addHint($contextname, $fmf_code . $device['id'], "Custom:FOLLOWME" . $device['id']);
                    }
                }
            }
            $ringlist = findmefollow_full_list();
            if (is_array($ringlist)) {
                foreach ($ringlist as $item) {
                    $grpnum = ltrim($item['0']);
                    $grp = findmefollow_get($grpnum);
                    $strategy = $grp['strategy'];
                    $grptime = $grp['grptime'];
                    $grplist = $grp['grplist'];
                    $postdest = $grp['postdest'];
                    $grppre = isset($grp['grppre']) ? $grp['grppre'] : '';
                    $annmsg_id = $grp['annmsg_id'];
                    $dring = $grp['dring'];
                    $needsconf = $grp['needsconf'];
                    $remotealert_id = $grp['remotealert_id'];
                    $toolate_id = $grp['toolate_id'];
                    $ringing = $grp['ringing'];
                    $pre_ring = $grp['pre_ring'];
                    if ($ringing == 'Ring' || empty($ringing)) {
                        $dialopts = '${DIAL_OPTIONS}';
                    } else {
                        // We need the DIAL_OPTIONS variable
                        $sops = sql("SELECT value from globals where variable='DIAL_OPTIONS'", "getRow");
                        $dialopts = "m({$ringing})" . str_replace('r', '', $sops[0]);
                    }
                    // Direct target to Follow-Me come here bypassing the followme/ddial conditional check
                    //
                    $ext->add($contextname, 'FM' . $grpnum, '', new ext_goto("FM{$grpnum}", "{$grpnum}"));
                    //
                    // If the followme is configured for extension dialing to go to the the extension and not followme then
                    // go there. This is often used in VmX Locater functionality when the user does not want the followme
                    // to automatically be called but only if chosen by the caller as an alternative to going to voicemail
                    //
                    $ext->add($contextname, $grpnum, '', new ext_gotoif('$[ "${DB(AMPUSER/' . $grpnum . '/followme/ddial)}" = "EXTENSION" ]', 'ext-local,' . $grpnum . ',1'));
                    $ext->add($contextname, $grpnum, 'FM' . $grpnum, new ext_macro('user-callerid'));
                    $ext->add($contextname, $grpnum, '', new ext_set('__EXTTOCALL', '${EXTEN}'));
                    // block voicemail until phone is answered at which point a macro should be called on the answering
                    // line to clear this flag so that subsequent transfers can occur, if already set by a the caller
                    // then don't change.
                    //
                    $ext->add($contextname, $grpnum, '', new ext_gotoif('$["foo${BLKVM_OVERRIDE}" = "foo"]', 'skipdb'));
                    $ext->add($contextname, $grpnum, '', new ext_gotoif('$["${DB(${BLKVM_OVERRIDE})}" = "TRUE"]', 'skipov'));
                    $ext->add($contextname, $grpnum, 'skipdb', new ext_setvar('__NODEST', ''));
                    $ext->add($contextname, $grpnum, '', new ext_setvar('__BLKVM_OVERRIDE', 'BLKVM/${EXTEN}/${CHANNEL}'));
                    $ext->add($contextname, $grpnum, '', new ext_setvar('__BLKVM_BASE', '${EXTEN}'));
                    $ext->add($contextname, $grpnum, '', new ext_setvar('DB(${BLKVM_OVERRIDE})', 'TRUE'));
                    // Remember if NODEST was set later, but clear it in case the call is answered so that subsequent
                    // transfers work.
                    //
                    $ext->add($contextname, $grpnum, 'skipov', new ext_setvar('RRNODEST', '${NODEST}'));
                    $ext->add($contextname, $grpnum, 'skipvmblk', new ext_setvar('__NODEST', '${EXTEN}'));
                    $ext->add($contextname, $grpnum, '', new ext_gosubif('$[${DB_EXISTS(AMPUSER/' . $grpnum . '/followme/changecid)} = 1 & "${DB(AMPUSER/' . $grpnum . '/followme/changecid)}" != "default" & "${DB(AMPUSER/' . $grpnum . '/followme/changecid)}" != ""]', 'sub-fmsetcid,s,1'));
                    // deal with group CID prefix
                    // but strip only if you plan on setting a new one
                    if ($grppre != '') {
                        $ext->add($contextname, $grpnum, '', new ext_gotoif('$["foo${RGPREFIX}" = "foo"]', 'REPCID'));
                        $ext->add($contextname, $grpnum, '', new ext_gotoif('$["${RGPREFIX}" != "${CALLERID(name):0:${LEN(${RGPREFIX})}}"]', 'REPCID'));
                        $ext->add($contextname, $grpnum, '', new ext_noop('Current RGPREFIX is ${RGPREFIX}....stripping from Caller ID'));
                        $ext->add($contextname, $grpnum, '', new ext_setvar('CALLERID(name)', '${CALLERID(name):${LEN(${RGPREFIX})}}'));
                        $ext->add($contextname, $grpnum, '', new ext_setvar('_RGPREFIX', ''));
                        $ext->add($contextname, $grpnum, 'REPCID', new ext_noop('CALLERID(name) is ${CALLERID(name)}'));
                        $ext->add($contextname, $grpnum, '', new ext_setvar('_RGPREFIX', $grppre));
                        $ext->add($contextname, $grpnum, '', new ext_setvar('CALLERID(name)', '${RGPREFIX}${CALLERID(name)}'));
                    }
                    // recording stuff
                    $ext->add($contextname, $grpnum, '', new ext_setvar('RecordMethod', 'Group'));
                    // append the followme's extension to the grouplist. This may be redundant but will ensure recording if the extension itself is not part of
                    // the list
                    $ext->add($contextname, $grpnum, '', new ext_macro('record-enable', '${DB(AMPUSER/' . "{$grpnum}/followme/grplist)}-{$grpnum}" . ',${RecordMethod}'));
                    // MODIFIED (PL)
                    // Add Alert Info if set but don't override and already set value (could be from ringgroup, directdid, etc.)
                    //
                    if ((isset($dring) ? $dring : '') != '') {
                        // If ALERTINFO is set, then skip to the next set command. This was modified to two lines because the previous
                        // IF() couldn't handle ':' as part of the string. The jump to PRIORITY+2 allows for now destination label
                        // which is needed in the 2.3 version.
                        $ext->add($contextname, $grpnum, '', new ext_gotoif('$["x${ALERT_INFO}"!="x"]', '$[${PRIORITY}+2])}'));
                        $ext->add($contextname, $grpnum, '', new ext_setvar("__ALERT_INFO", str_replace(';', '\\;', $dring)));
                    }
                    // If pre_ring is set, then ring this number of seconds prior to moving on
                    if ((isset($strategy) ? substr($strategy, 0, strlen('ringallv2')) : '') != 'ringallv2') {
                        $ext->add($contextname, $grpnum, '', new ext_gotoif('$[$[ "${DB(AMPUSER/' . $grpnum . '/followme/prering)}" = "0" ] | $[ "${DB(AMPUSER/' . $grpnum . '/followme/prering)}" = "" ]] ', 'skipsimple'));
                        $ext->add($contextname, $grpnum, '', new ext_macro('simple-dial', $grpnum . ',${DB(AMPUSER/' . "{$grpnum}/followme/prering)}"));
                    }
                    // group dial
                    $ext->add($contextname, $grpnum, 'skipsimple', new ext_setvar('RingGroupMethod', $strategy));
                    $ext->add($contextname, $grpnum, '', new ext_setvar('_FMGRP', $grpnum));
                    if (isset($annmsg_id) ? $annmsg_id : '') {
                        $annmsg = recordings_get_file($annmsg_id);
                        // should always answer before playing anything, shouldn't we ?
                        $ext->add($contextname, $grpnum, '', new ext_gotoif('$[$["${DIALSTATUS}" = "ANSWER"] | $["foo${RRNODEST}" != "foo"]]', 'DIALGRP'));
                        $ext->add($contextname, $grpnum, '', new ext_answer(''));
                        $ext->add($contextname, $grpnum, '', new ext_wait(1));
                        $ext->add($contextname, $grpnum, '', new ext_playback($annmsg));
                    }
                    // Create the confirm target
                    $len = strlen($grpnum) + 4;
                    $remotealert = recordings_get_file($remotealert_id);
                    $toolate = recordings_get_file($toolate_id);
                    $ext->add("fmgrps", "_RG-{$grpnum}-.", '', new ext_macro('dial', '${DB(AMPUSER/' . "{$grpnum}/followme/grptime)}," . "M(confirm^{$remotealert}^{$toolate}^{$grpnum}){$dialopts}" . ',${EXTEN:' . $len . '}'));
                    // If grpconf == ENABLED call with confirmation ELSE call normal
                    $ext->add($contextname, $grpnum, 'DIALGRP', new ext_gotoif('$[ "${DB(AMPUSER/' . $grpnum . '/followme/grpconf)}" = "ENABLED" ]', 'doconfirm'));
                    // Normal call
                    if ((isset($strategy) ? substr($strategy, 0, strlen('ringallv2')) : '') != 'ringallv2') {
                        $ext->add($contextname, $grpnum, '', new ext_macro('dial', '${DB(AMPUSER/' . "{$grpnum}/followme/grptime)},{$dialopts}," . '${DB(AMPUSER/' . "{$grpnum}/followme/grplist)}"));
                    } else {
                        $ext->add($contextname, $grpnum, '', new ext_macro('dial', '$[ ${DB(AMPUSER/' . $grpnum . '/followme/grptime)} + ${DB(AMPUSER/' . $grpnum . '/followme/prering)} ],' . $dialopts . ',${DB(AMPUSER/' . $grpnum . '/followme/grplist)}'));
                    }
                    $ext->add($contextname, $grpnum, '', new ext_goto('nextstep'));
                    // Call Confirm call
                    if ((isset($strategy) ? substr($strategy, 0, strlen('ringallv2')) : '') != 'ringallv2') {
                        $ext->add($contextname, $grpnum, 'doconfirm', new ext_macro('dial-confirm', '${DB(AMPUSER/' . "{$grpnum}/followme/grptime)},{$dialopts}," . '${DB(AMPUSER/' . "{$grpnum}/followme/grplist)}," . $grpnum));
                    } else {
                        $ext->add($contextname, $grpnum, 'doconfirm', new ext_macro('dial-confirm', '$[ ${DB(AMPUSER/' . $grpnum . '/followme/grptime)} + ${DB(AMPUSER/' . $grpnum . '/followme/prering)} ],' . $dialopts . ',${DB(AMPUSER/' . $grpnum . '/followme/grplist)},' . $grpnum));
                    }
                    $ext->add($contextname, $grpnum, 'nextstep', new ext_setvar('RingGroupMethod', ''));
                    // Did the call come from a queue or ringgroup, if so, don't go to the destination, just end and let
                    // the queue or ringgroup decide what to do next
                    //
                    $ext->add($contextname, $grpnum, '', new ext_gotoif('$["foo${RRNODEST}" != "foo"]', 'nodest'));
                    $ext->add($contextname, $grpnum, '', new ext_setvar('__NODEST', ''));
                    $ext->add($contextname, $grpnum, '', new ext_dbdel('${BLKVM_OVERRIDE}'));
                    // where next?
                    if ((isset($postdest) ? $postdest : '') != '') {
                        $ext->add($contextname, $grpnum, '', new ext_goto($postdest));
                    } else {
                        $ext->add($contextname, $grpnum, '', new ext_hangup(''));
                    }
                    $ext->add($contextname, $grpnum, 'nodest', new ext_noop('SKIPPING DEST, CALL CAME FROM Q/RG: ${RRNODEST}'));
                }
                /*
                  ASTDB Settings:
                  AMPUSER/nnn/followme/changecid default | did | fixed | extern
                  AMPUSER/nnn/followme/fixedcid XXXXXXXX
                
                  changecid:
                    default   - works as always, same as if not present
                    fixed     - set to the fixedcid
                    extern    - set to the fixedcid if the call is from the outside only
                    did       - set to the DID that the call came in on or leave alone, treated as foreign
                    forcedid  - set to the DID that the call came in on or leave alone, not treated as foreign
                  
                  EXTTOCALL   - has the exten num called, hoaky if that goes away but for now use it
                */
                if (count($ringlist)) {
                    $contextname = 'sub-fmsetcid';
                    $exten = 's';
                    $ext->add($contextname, $exten, '', new ext_goto('1', 's-${DB(AMPUSER/${EXTTOCALL}/followme/changecid)}'));
                    $exten = 's-fixed';
                    $ext->add($contextname, $exten, '', new ext_execif('$["${REGEX("^[\\+]?[0-9]+$" ${DB(AMPUSER/${EXTTOCALL}/followme/fixedcid)})}" = "1"]', 'Set', '__TRUNKCIDOVERRIDE=${DB(AMPUSER/${EXTTOCALL}/followme/fixedcid)}'));
                    $ext->add($contextname, $exten, '', new ext_return(''));
                    $exten = 's-extern';
                    $ext->add($contextname, $exten, '', new ext_execif('$["${REGEX("^[\\+]?[0-9]+$" ${DB(AMPUSER/${EXTTOCALL}/followme/fixedcid)})}" == "1" & "${FROM_DID}" != ""]', 'Set', '__TRUNKCIDOVERRIDE=${DB(AMPUSER/${EXTTOCALL}/followme/fixedcid)}'));
                    $ext->add($contextname, $exten, '', new ext_return(''));
                    $exten = 's-did';
                    $ext->add($contextname, $exten, '', new ext_execif('$["${REGEX("^[\\+]?[0-9]+$" ${FROM_DID})}" = "1"]', 'Set', '__REALCALLERIDNUM=${FROM_DID}'));
                    $ext->add($contextname, $exten, '', new ext_return(''));
                    $exten = 's-forcedid';
                    $ext->add($contextname, $exten, '', new ext_execif('$["${REGEX("^[\\+]?[0-9]+$" ${FROM_DID})}" = "1"]', 'Set', '__TRUNKCIDOVERRIDE=${FROM_DID}'));
                    $ext->add($contextname, $exten, '', new ext_return(''));
                    $exten = '_s-.';
                    $ext->add($contextname, $exten, '', new ext_noop('Unknown value for AMPUSER/${EXTTOCALL}/followme/changecid of ${DB(AMPUSER/${EXTTOCALL}/followme/changecid)} set to "default"'));
                    $ext->add($contextname, $exten, '', new ext_setvar('DB(AMPUSER/${EXTTOCALL}/followme/changecid)', 'default'));
                    $ext->add($contextname, $exten, '', new ext_return(''));
                }
            }
            break;
    }
}
コード例 #4
0
ファイル: functions.inc.php プロジェクト: lidl/core
function core_users_configpageload()
{
    global $currentcomponent;
    global $amp_conf;
    // Ensure variables possibly extracted later exist
    $name = $outboundcid = $sipname = $cid_masquerade = $newdid_name = $newdid = $newdidcid = $call_screen = $pinless = null;
    // Init vars from $_REQUEST[]
    $display = isset($_REQUEST['display']) ? $_REQUEST['display'] : null;
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
    $tech_hardware = isset($_REQUEST['tech_hardware']) ? $_REQUEST['tech_hardware'] : null;
    if (!checkRange($extdisplay)) {
        return;
    }
    if ($action == 'del') {
        // Deleted
        $currentcomponent->addguielem('_top', new gui_subheading('del', $extdisplay . ' ' . _("deleted"), false));
    } elseif ($display == 'extensions' && ($extdisplay == '' && $tech_hardware == '')) {
        // Adding
        // do nothing as you want the Devices to handle this bit
    } else {
        $delURL = '?' . $_SERVER['QUERY_STRING'] . '&action=del';
        if (is_string($extdisplay)) {
            if (!isset($GLOBALS['abort']) || $GLOBALS['abort'] !== true) {
                $extenInfo = \FreePBX::Core()->getUser($extdisplay);
                extract($extenInfo);
            }
            if (isset($deviceInfo) && is_array($deviceInfo)) {
                extract($deviceInfo);
            }
            if ($display == 'extensions') {
                $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Extension") . ": {$extdisplay}", false), 0);
                /*
                		if (!isset($GLOBALS['abort']) || $GLOBALS['abort'] !== true) {
                		$tlabel = sprintf(_("Delete Extension %s"),$extdisplay);
                		$label = '<span><img width="16" height="16" border="0" title="'.$tlabel.'" alt="" src="images/user_delete.png"/>&nbsp;'.$tlabel.'</span>';
                		$currentcomponent->addguielem('_top', new gui_link('del', $label, $delURL, true, false), 0);
                
                		$usage_list = framework_display_destination_usage(core_getdest($extdisplay));
                		if (!empty($usage_list)) {
                		$currentcomponent->addguielem('_top', new gui_link_label('dests', $usage_list['text'], $usage_list['tooltip'], true), 0);
                	}
                }
                */
            } else {
                $currentcomponent->addguielem('_top', new gui_pageheading('title', _("User") . ": {$extdisplay}", false), 0);
                if (!isset($GLOBALS['abort']) || $GLOBALS['abort'] !== true) {
                    /*
                    $tlabel = sprintf(_("Delete User %s"),$extdisplay);
                    $label = '<span><img width="16" height="16" border="0" title="'.$tlabel.'" alt="" src="images/user_delete.png"/>&nbsp;'.$tlabel.'</span>';
                    $currentcomponent->addguielem('_top', new gui_link('del', $label, $delURL, true, false), 0);
                    
                    $usage_list = framework_display_destination_usage(core_getdest($extdisplay));
                    if (!empty($usage_list)) {
                    	$currentcomponent->addguielem('_top', new gui_link_label('dests', $usage_list['text'], $usage_list['tooltip'], true), 0);
                    }
                    */
                }
            }
        } elseif ($display != 'extensions') {
            $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Add User/Extension")), 0);
        }
        // Setup vars for use in the gui later on
        $fc_logon = featurecodes_getFeatureCode('core', 'userlogon');
        $fc_logoff = featurecodes_getFeatureCode('core', 'userlogoff');
        $msgInvalidExtNum = _("Please enter a valid extension number.");
        $msgInvalidCidNum = _("Please enter a valid CID Num Alias (must be a valid number).");
        $msgInvalidExtPwd = _("Please enter valid User Password using numbers only");
        $msgInvalidDispName = _("Please enter a valid Display Name");
        $msgInvalidOutboundCID = _("Please enter a valid Outbound CID");
        $msgInvalidPause = _("Please enter a valid pause time in seconds, using digits only");
        $msgInvalidDIDNum = _("You have entered a non-standard dialpattern for your DID. You can only enter standard dialpatterns. You must use the inbound routing form to enter non-standard patterns");
        $msgInvalidCIDNum = _("Please enter a valid CallerID Number or leave it blank for your Assigned DID/CID pair");
        // This is the actual gui stuff
        $currentcomponent->addguielem('_top', new gui_hidden('action', isset($extdisplay) && trim($extdisplay) !== '' ? 'edit' : 'add'));
        $currentcomponent->addguielem('_top', new gui_hidden('extdisplay', $extdisplay));
        if ($display == 'extensions') {
            $section = $extdisplay ? _("Edit Extension") : _("Add Extension");
        } else {
            $section = $extdisplay ? _("Edit User") : _("Add User");
        }
        $category = "general";
        if (trim($extdisplay) != '') {
            $currentcomponent->addguielem($section, new gui_hidden('extension', $extdisplay), 2, null, $category);
        } else {
            $currentcomponent->addguielem($section, new gui_textbox('extension', $extdisplay, _("User Extension"), _("The extension number to dial to reach this user."), '!isInteger()', $msgInvalidExtNum, false), 3, null, $category);
        }
        if ($display != 'extensions') {
            $currentcomponent->addguielem($section, new gui_password('password', $password, _("User Password"), _("A user will enter this password when logging onto a device.") . ' ' . $fc_logon . ' ' . _("logs into a device.") . ' ' . $fc_logoff . ' ' . _("logs out of a device."), '!isInteger() && !isWhitespace()', $msgInvalidExtPwd, true), $category);
            // extra JS function check required for blank password warning -- call last in the onsubmit() function
            $currentcomponent->addjsfunc('onsubmit()', "\treturn checkBlankUserPwd();\n", 9);
        }
        if ($action == 'add') {
            $currentcomponent->addjsfunc('onsubmit()', "\n\t\t\tvar exten = \$('#extension').val();\n\t\t\tvar ajax_result = true;\n\t\t\t\$('#error').remove();\n\t\t\t\$.ajax({\n\t\t\t\ttype: 'POST',\n\t\t\t\turl: 'config.php',\n\t\t\t\tdata: 'handler=api&function=framework_get_conflict_url_helper&args=' + exten,\n\t\t\t\tdataType: 'json',\n\t\t\t\tcache: false,\n\t\t\t\tasync: false,\n\t\t\t\tsuccess: function(data, textStatus, XMLHttpRequest) {\n\t\t\t\t\tif (data.length !== 0) {\n\t\t\t\t\t\t\$('#title').after('<div id=\"error\"><h5>" . _("Conflicting Extensions") . "</h5>' + data + '</div>');\n\t\t\t\t\t\tajax_result = false;\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\terror: function(data) {\n\t\t\t\t\tconsole.log('an error was recevied: ' + data);\n\t\t\t\t\t// TODO: Should we stop the submital and do something here?\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (!ajax_result) {\n\t\t\t\talert('" . _("Extension number conflict, please choose another.") . "');\n\t\t\t\t\$('#extension').focus();\n\t\t\t\treturn false;\n\t\t\t}", 9);
        }
        $currentcomponent->addguielem($section, new gui_textbox('name', $name, _("Display Name"), _("The CallerID name for calls from this user will be set to this name. Only enter the name, NOT the number."), '(typeof isCorrectLengthExtensions != "undefined") ? !isCorrectLengthExtensions() || !isUnicodeLetter || isWhitespace() : !isUnicodeLetter() || isWhitespace()', $msgInvalidDispName, false), 3, null, $category);
        $cid_masquerade = trim($cid_masquerade) == $extdisplay ? "" : $cid_masquerade;
        $currentcomponent->addguielem($section, new gui_textbox('cid_masquerade', $cid_masquerade, _("CID Num Alias"), _("The CID Number to use for internal calls, if different from the extension number. This is used to masquerade as a different user. A common example is a team of support people who would like their internal CallerID to display the general support number (a ringgroup or queue). There will be no effect on external calls."), '!isWhitespace() && !isInteger()', $msgInvalidCidNum, false), "advanced");
        $currentcomponent->addguielem($section, new gui_textbox('sipname', $sipname, _("SIP Alias"), _("If you want to support direct sip dialing of users internally or through anonymous sip calls, you can supply a friendly name that can be used in addition to the users extension to call them.")), "advanced");
        // If user mode, list devices associated with this user
        //
        if ($display == 'users' && trim($extdisplay != '')) {
            $section = _("User Devices");
            $device_list = core_devices_list('all', 'full');
            $device_list = is_array($device_list) ? $device_list : array();
            usort($device_list, 'dev_grp');
            $link_count = 0;
            foreach ($device_list as $device_item) {
                if ($device_item['user'] == $extdisplay) {
                    $editURL = '?display=devices&skip=0&extdisplay=' . $device_item['id'];
                    $device_icon = $device_item['devicetype'] == 'fixed' ? 'images/telephone_key.png' : 'images/telephone_edit.png';
                    $device_label = '&nbsp;';
                    $device_label .= _("Edit:");
                    $device_label .= '&nbsp;' . $device_item['id'] . '&nbsp;' . $device_item['description'];
                    $device_label = '<span>
					<img width="16" height="16" border="0" title="Edit Device" alt="Edit Device" src="' . $device_icon . '"/>' . $device_label . '</span> ';
                    $currentcomponent->addguielem($section, new gui_link('dev' . $link_count++, $device_label, $editURL, true, false), 2);
                }
            }
        }
        $currentcomponent->addguielem($section, new gui_textbox('outboundcid', $outboundcid, _("Outbound CID"), _("Overrides the CallerID when dialing out a trunk. Any setting here will override the common outbound CallerID set in the Trunks admin.<br><br>Format: <b>\"caller name\" &lt;#######&gt;</b><br><br>Leave this field blank to disable the outbound CallerID feature for this user."), '!isCallerID()', $msgInvalidOutboundCID, true), 3, null, "general");
        $section = _("Extension Options");
        $category = "advanced";
        $ringtimer = isset($ringtimer) ? $ringtimer : '0';
        $dialopts = isset($dialopts) ? $dialopts : false;
        $disable_dialopts = $dialopts === false;
        $currentcomponent->addguielem($section, new gui_textbox_check('dialopts', $dialopts, _("Asterisk Dial Options"), _("Cryptic Asterisk Dial Options, check to customize for this extension or un-check to use system defaults set in Advanced Options. These will not apply to trunk options which are configured with the trunk."), '', '', true, 0, $disable_dialopts, '<small>' . _("Override") . '</small>', $amp_conf['DIAL_OPTIONS'], true), $category);
        $currentcomponent->addguielem($section, new gui_selectbox('ringtimer', $currentcomponent->getoptlist('ringtime'), $ringtimer, _("Ring Time"), _("Number of seconds to ring prior to going to voicemail. Default will use the value set in Advanced Settings. If no voicemail is configured this will be ignored."), false), $category);
        if (!isset($cfringtimer)) {
            if ($amp_conf['CFRINGTIMERDEFAULT'] < 0 || ctype_digit($amp_conf['CFRINGTIMERDEFAULT'])) {
                $cfringtimer = $amp_conf['CFRINGTIMERDEFAULT'] < 0 ? -1 : ($amp_conf['CFRINGTIMERDEFAULT'] > 120 ? 120 : $amp_conf['CFRINGTIMERDEFAULT']);
            } else {
                $cfringtimer = 0;
            }
        }
        $currentcomponent->addguielem($section, new gui_selectbox('cfringtimer', $currentcomponent->getoptlist('cfringtime'), $cfringtimer, _("Call Forward Ring Time"), _("Number of seconds to ring during a Call Forward, Call Forward Busy or Call Forward Unavailable call prior to continuing to voicemail or specified destination. Setting to Always will not return, it will just continue to ring. Default will use the current Ring Time. If voicemail is disabled and their is not destination specified, it will be forced into Always mode"), false), $category);
        if (!isset($callwaiting)) {
            if ($amp_conf['ENABLECW']) {
                $callwaiting = 'enabled';
            } else {
                $callwaiting = 'disabled';
            }
        }
        $concurrency_limit = isset($concurrency_limit) ? $concurrency_limit : $amp_conf['CONCURRENCYLIMITDEFAULT'];
        $currentcomponent->addguielem($section, new gui_selectbox('concurrency_limit', $currentcomponent->getoptlist('concurrency_limit'), $concurrency_limit, _("Outbound Concurrency Limit"), _("Maximum number of outbound simultaneous calls that an extension can make. This is also very useful as a Security Protection against a system that has been compromised. It will limit the number of simultaneous calls that can be made on the compromised extension."), false), $category);
        $currentcomponent->addguielem($section, new gui_radio('callwaiting', $currentcomponent->getoptlist('callwaiting'), $callwaiting, _("Call Waiting"), _("Set the initial/current Call Waiting state for this user's extension"), false, '', '', false), $category);
        $currentcomponent->addguielem($section, new gui_selectbox('call_screen', $currentcomponent->getoptlist('call_screen'), $call_screen, _("Call Screening"), _("Call Screening requires external callers to say their name, which will be played back to the user and allow the user to accept or reject the call.  Screening with memory only verifies a caller for their CallerID once. Screening without memory always requires a caller to say their name. Either mode will always announce the caller based on the last introduction saved with that CallerID. If any user on the system uses the memory option, when that user is called, the caller will be required to re-introduce themselves and all users on the system will have that new introduction associated with the caller's CallerID."), false), $category);
        $pinless = isset($pinless) ? $pinless : "disabled";
        $currentcomponent->addguielem($section, new gui_radio('pinless', $currentcomponent->getoptlist('pinless'), $pinless, _("Pinless Dialing"), _("Enabling Pinless Dialing will allow this extension to bypass any pin codes normally required on outbound calls"), false, '', '', false), $category);
        $section = _("Assigned DID/CID");
        $category = "advanced";
        $currentcomponent->addguielem($section, new gui_textbox('newdid_name', $newdid_name, _("DID Description"), _("A description for this DID, such as \"Fax\"")), 4, null, $category);
        $currentcomponent->addguielem($section, new gui_textbox('newdid', $newdid, _("Add Inbound DID"), _("A direct DID that is associated with this extension. The DID should be in the same format as provided by the provider (e.g. full number, 4 digits for 10x4, etc).<br><br>Format should be: <b>XXXXXXXXXX</b><br><br>.An optional CID can also be associated with this DID by setting the next box"), '!isDialpattern()', $msgInvalidDIDNum, true), 4, null, $category);
        $currentcomponent->addguielem($section, new gui_textbox('newdidcid', $newdidcid, _("Add Inbound CID"), _("Add a CID for more specific DID + CID routing. A DID must be specified in the above Add DID box. In addition to standard dial sequences, you can also put Private, Blocked, Unknown, Restricted, Anonymous, Withheld and Unavailable in order to catch these special cases if the Telco transmits them."), "!frm_{$display}_isValidCID()", $msgInvalidCIDNum, true), 4, null, $category);
        $dids = \FreePBX::Core()->getAllDIDs('extension');
        $did_count = 0;
        foreach ($dids as $did) {
            $did_dest = preg_split('/,/', $did['destination']);
            if (isset($did_dest[1]) && $did_dest[1] === $extdisplay) {
                $did_title = $did['description'] != '' ? $did['description'] : _("DID / CID");
                $addURL = '?display=did&view=form&extdisplay=' . urlencode($did['extension'] . '/' . $did['cidnum']);
                $did_icon = 'images/email_edit.png';
                $did_label = trim($did['extension']) == '' ? ' ' . _("Any DID") : ' ' . $did['extension'];
                if (trim($did['cidnum']) != '') {
                    $did_label .= ' / ' . $did['cidnum'];
                }
                if (trim($did['description']) != '') {
                    $did_label .= ' (' . $did['description'] . ')';
                }
                $did_label = '&nbsp;<span>
				<img width="16" height="16" border="0" title="' . $did_title . '" alt="" src="' . $did_icon . '"/>' . $did_label . '</span> ';
                $currentcomponent->addguielem($section, new gui_link('did_' . $did_count++, $did_label, $addURL, true, false), 4, null, $category);
            }
        }
        $section = _("Recording Options");
        $recording_in_external = isset($recording_in_external) ? $recording_in_external : 'dontcare';
        $recording_out_external = isset($recording_out_external) ? $recording_out_external : 'dontcare';
        $recording_in_internal = isset($recording_in_internal) ? $recording_in_internal : 'dontcare';
        $recording_out_internal = isset($recording_out_internal) ? $recording_out_internal : 'dontcare';
        $recording_ondemand = isset($recording_ondemand) ? $recording_ondemand : 'disabled';
        $recording_priority = isset($recording_priority) ? $recording_priority : '10';
        $currentcomponent->addguielem($section, new gui_radio('recording_in_external', $currentcomponent->getoptlist('recording_options'), $recording_in_external, _('Inbound External Calls'), _("Recording of inbound calls from external sources.")), $category);
        $currentcomponent->addguielem($section, new gui_radio('recording_out_external', $currentcomponent->getoptlist('recording_options'), $recording_out_external, _('Outbound External Calls'), _("Recording of outbound calls to external sources.")), $category);
        $currentcomponent->addguielem($section, new gui_radio('recording_in_internal', $currentcomponent->getoptlist('recording_options'), $recording_in_internal, _('Inbound Internal Calls'), _("Recording of calls received from other extensions on the system.")), $category);
        $currentcomponent->addguielem($section, new gui_radio('recording_out_internal', $currentcomponent->getoptlist('recording_options'), $recording_out_internal, _('Outbound Internal Calls'), _("Recording of calls made to other extensions on the system.")), $category);
        $currentcomponent->addguielem($section, new gui_radio('recording_ondemand', $currentcomponent->getoptlist('recording_ondemand_options'), $recording_ondemand, _('On Demand Recording'), _("Enable or disable the ability to do on demand (one-touch) recording. The overall calling policy rules still apply and if calls are already being recorded by 'Force' or 'Never', the can not be paused unless 'Override' is selected..")), $category);
        $currentcomponent->addguielem($section, new gui_selectbox('recording_priority', $currentcomponent->getoptlist('recording_priority_options'), $recording_priority, _("Record Priority Policy"), _("Call recording policy priority relative to other extensions when there is a conflict between an extension wanting recording and the other not wanting it. The higher of the two determines the policy, on a tie the global policy (caller or callee) determines the policy."), false), $category);
        $section = _("Optional Destinations");
        $noanswer_dest = isset($noanswer_dest) ? $noanswer_dest : '';
        $busy_dest = isset($busy_dest) ? $busy_dest : '';
        $chanunavail_dest = isset($chanunavail_dest) ? $chanunavail_dest : '';
        $noanswer_cid = isset($noanswer_cid) ? $noanswer_cid : '';
        $busy_cid = isset($busy_cid) ? $busy_cid : '';
        $chanunavail_cid = isset($chanunavail_cid) ? $chanunavail_cid : '';
        if ($amp_conf['CWINUSEBUSY']) {
            $helptext = _('Optional destination call is routed to when the call is not answered on an otherwise idle phone. If the phone is in use and the call is simply ignored, then the busy destination will be used.');
        } else {
            $helptext = _('Optional destination call is routed to when the call is not answered.');
        }
        $nodest_msg = _('Unavail Voicemail if Enabled');
        $currentcomponent->addguielem($section, new gui_drawselects('noanswer_dest', '0', $noanswer_dest, _('No Answer'), $helptext, false, '', $nodest_msg), 5, 9, $category);
        $currentcomponent->addguielem($section, new gui_textbox('noanswer_cid', $noanswer_cid, '&nbsp;&nbsp;' . _("CID Prefix"), _("Optional CID Prefix to add before sending to this no answer destination.")), 5, 9, $category);
        if ($amp_conf['CWINUSEBUSY']) {
            $helptext = _('Optional destination the call is routed to when the phone is busy or the call is rejected by the user. This destination is also used on an unanswered call if the phone is in use and the user chooses not to pickup the second call.');
        } else {
            $helptext = _('Optional destination the call is routed to when the phone is busy or the call is rejected by the user.');
        }
        $nodest_msg = _('Busy Voicemail if Enabled');
        $currentcomponent->addguielem($section, new gui_drawselects('busy_dest', '1', $busy_dest, _('Busy'), $helptext, false, '', $nodest_msg), 5, 9, $category);
        $currentcomponent->addguielem($section, new gui_textbox('busy_cid', $busy_cid, '&nbsp;&nbsp;' . _("CID Prefix"), _("Optional CID Prefix to add before sending to this busy destination.")), 5, 9, $category);
        $helptext = _('Optional destination the call is routed to when the phone is offline, such as a softphone currently off or a phone unplugged.');
        $nodest_msg = _('Unavail Voicemail if Enabled');
        $currentcomponent->addguielem($section, new gui_drawselects('chanunavail_dest', '2', $chanunavail_dest, _('Not Reachable'), $helptext, false, '', $nodest_msg), 5, 9, $category);
        $currentcomponent->addguielem($section, new gui_textbox('chanunavail_cid', $chanunavail_cid, '&nbsp;&nbsp;' . _("CID Prefix"), _("Optional CID Prefix to add before sending to this not reachable destination.")), 5, 9, $category);
    }
}
コード例 #5
0
ファイル: page.devices.php プロジェクト: umjinsun12/dngshin
<?php

/* $Id$ */
if (!defined('FREEPBX_IS_AUTH')) {
    die('No direct script access allowed');
}
?>
<div class="rnav">
<?php 
$devices = core_devices_list();
$description = $_SESSION["AMP_user"]->checkSection('999') ? _("Device") : false;
drawListMenu($devices, $skip, $type, $display, $extdisplay, $description);
?>
</div>​
コード例 #6
0
 function generate_queues_additional($ast_version)
 {
     global $db;
     global $amp_conf;
     $additional = "";
     $output = "";
     // Asterisk 1.4 does not like blank assignments so just don't put them there
     //
     $ver12 = version_compare($ast_version, '1.4', 'lt');
     $ver16 = version_compare($ast_version, '1.6', 'ge');
     $ast_ge_14_25 = version_compare($ast_version, '1.4.25', 'ge');
     $ast_ge_18 = version_compare($ast_version, '1.8', 'ge');
     $ast_ge_120 = version_compare($ast_version, '12', 'ge');
     // legacy but in case someone was using this we will leave it
     //TODO: abstract getters/setters from business logic
     $sql = "SELECT keyword,data FROM queues_details WHERE id='-1' AND keyword <> 'account'";
     $results = $db->getAll($sql, DB_FETCHMODE_ASSOC);
     if ($db->IsError($results)) {
         die($results->getMessage());
     }
     foreach ($results as $result) {
         if (!$ver12 && trim($result['data']) == '') {
             continue;
         }
         $additional .= $result['keyword'] . "=" . $result['data'] . "\n";
     }
     if ($ast_ge_14_25) {
         $devices = array();
         $device_results = core_devices_list('all', 'full', true);
         if (is_array($device_results)) {
             foreach ($device_results as $device) {
                 if (!isset($devices[$device['user']]) && $device['devicetype'] == 'fixed') {
                     $devices[$device['user']] = $device['dial'];
                 }
             }
             unset($device_results);
         }
     }
     if ($amp_conf['USEQUEUESTATE'] || $ast_ge_14_25) {
         $users = array();
         $user_results = core_users_list();
         if (is_array($user_results)) {
             foreach ($user_results as $user) {
                 $users[$user[0]] = $user[1];
             }
             unset($user_results);
         }
     }
     $results = queues_list(true);
     foreach ($results as $result) {
         $output .= "[" . $result[0] . "]\n";
         // passing 2nd param 'true' tells queues_get to send back only queue_conf required params
         // and nothing else
         //
         $results2 = queues_get($result[0], true);
         if (empty($results2['context'])) {
             $results2['context'] = "";
         }
         // memebers is an array of members so we set it asside and remove it
         // and then generate each later
         //
         $members = $results2['member'];
         unset($results2['member']);
         // Queues cannot control their own recordings, it must now be
         // done through sub-record-check
         unset($results2['monitor-format']);
         unset($results2['recording']);
         //Unset Old commands Resolves FREEPBX-8610.
         unset($results2['monitor-join']);
         unset($results2['answered_elsewhere']);
         unset($results2['skip_joinannounce']);
         //These items still exist for backwards compatibility but are useless in 12+
         if ($ast_ge_120) {
             unset($results2['eventwhencalled']);
             unset($results2['eventmemberstatus']);
         }
         foreach ($results2 as $keyword => $data) {
             if (trim($data) == '' && $keyword != "context" || substr($keyword, 0, 4) == "cron") {
                 // Skip anything that's empty or not required
                 continue;
             }
             // Some old commands have been removed. Make sure we
             // don't add them.
             switch ($keyword) {
                 case 'monitor-join':
                 case 'answered_elsewhere':
                 case 'skip_joinannounce':
                     continue;
                     break;
                 case 'music':
                     $keyword = 'musicclass';
                     break;
             }
             if ($keyword == "retry" && $data == "none") {
                 $data = 0;
             }
             $output .= $keyword . "=" . $data . "\n";
         }
         // Now pull out all the memebers, one line for each
         //
         if ($ast_ge_18 || $amp_conf['USEQUEUESTATE']) {
             foreach ($members as $member) {
                 preg_match("/^Local\\/([\\d]+)\\@*/", $member, $matches);
                 if (isset($matches[1]) && isset($users[$matches[1]])) {
                     $name = sprintf('"%s"', $users[$matches[1]]);
                     //str_replace(',','\,',$name);
                     $qnostate = queues_get_qnostate($matches[1]);
                     if ($qnostate == 'ignorestate') {
                         freepbx_log(FPBX_LOG_NOTICE, "Ignoring State information for Queue Member: " . $matches[1]);
                         $output .= "member={$member},{$name}\n";
                     } else {
                         $output .= "member={$member},{$name},hint:" . $matches[1] . "@ext-local\n";
                     }
                 } else {
                     $output .= "member=" . $member . "\n";
                 }
             }
         } else {
             if ($ast_ge_14_25) {
                 foreach ($members as $member) {
                     preg_match("/^Local\\/([\\d]+)\\@*/", $member, $matches);
                     if (isset($matches[1]) && isset($devices[$matches[1]])) {
                         $name = sprintf('"%s"', $users[$matches[1]]);
                         //str_replace(',','\,',$name);
                         $qnostate = queues_get_qnostate($matches[1]);
                         if ($qnostate == 'ignorestate') {
                             freepbx_log(FPBX_LOG_NOTICE, "Ignoring State information for Queue Member: " . $matches[1]);
                             $output .= "member={$member},{$name}\n";
                         } else {
                             $output .= "member={$member},{$name}," . $devices[$matches[1]] . "\n";
                         }
                     } else {
                         $output .= "member=" . $member . "\n";
                     }
                 }
             } else {
                 foreach ($members as $member) {
                     $output .= "member=" . $member . "\n";
                 }
             }
         }
         if (isset($this->_queues_additional[$result[0]])) {
             foreach ($this->_queues_additional[$result[0]] as $qsetting) {
                 $output .= $qsetting['key'] . "=" . $qsetting['value'] . "\n";
             }
         }
         $output .= $additional . "\n";
     }
     // Before returning the results, do an integrity check to see
     // if there are any truncated compound recrodings and if so
     // crate a noticication.
     //
     $nt = notifications::create($db);
     $compound_recordings = queues_check_compoundrecordings();
     if (empty($compound_recordings)) {
         $nt->delete('queues', 'COMPOUNDREC');
     } else {
         $str = _('Warning, there are compound recordings configured in ' . 'one or more Queue configurations. Queues can not play these ' . 'so they have been truncated to the first sound file. You ' . 'should correct this problem.<br />Details:<br /><br />');
         foreach ($compound_recordings as $item) {
             $str .= sprintf(_("Queue - %s (%s): %s<br />"), $item['extension'], $item['descr'], $item['error']);
         }
         $nt->add_error('queues', 'COMPOUNDREC', _("Compound Recordings in Queues Detected"), $str);
     }
     return $output;
 }
コード例 #7
0
        if (is_array($restartlist) && sizeof($restartlist)) {
            foreach ($restartlist as $device) {
                restart_device($device);
            }
            $restarted = true;
        }
        break;
}
if (isset($restarted)) {
    if ($restarted) {
        $txtinfo = '<div class="well well-info">' . _("Restart requests sent!") . '</div>';
    } else {
        $txtinfo = '<div class="well well-warning">' . _("Warning: The restart mechanism behavior is vendor specific.  Some vendors only restart the phone if there is a change to the phone configuration or if an updated firmware is available via tftp/ftp/http") . "</div>";
    }
}
$device_list = core_devices_list();
$device_list = is_array($device_list) ? $device_list : array();
$txtinfo = isset($txtinfo) ? $txtinfo : '<div class="well well-info">' . _("Currently, only Aastra, Snom, Polycom, Grandstream and Cisco devices are supported.") . '</div>';
?>
<div class="container-fluid">
	<h1><?php 
echo _('Restart Phones');
?>
</h1>
	<?php 
echo $txtinfo;
?>
	<div class = "display full-border">
		<div class="row">
			<div class="col-sm-12">
				<div class="fpbx-container">
コード例 #8
0
ファイル: functions.inc.php プロジェクト: hardikk/HNH
function core_users_configpageload()
{
    global $currentcomponent;
    global $amp_conf;
    // Ensure variables possibly extracted later exist
    $name = $outboundcid = $record_in = $record_out = $sipname = $cid_masquerade = $newdid_name = $newdid = $newdidcid = $call_screen = $pinless = null;
    // Init vars from $_REQUEST[]
    $display = isset($_REQUEST['display']) ? $_REQUEST['display'] : null;
    $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null;
    $extdisplay = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] : null;
    $tech_hardware = isset($_REQUEST['tech_hardware']) ? $_REQUEST['tech_hardware'] : null;
    if ($action == 'del') {
        // Deleted
        $currentcomponent->addguielem('_top', new gui_subheading('del', $extdisplay . ' ' . _("deleted"), false));
    } elseif ($display == 'extensions' && ($extdisplay == '' && $tech_hardware == '')) {
        // Adding
        // do nothing as you want the Devices to handle this bit
    } else {
        $delURL = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'] . '&action=del';
        if (is_string($extdisplay)) {
            if (!isset($GLOBALS['abort']) || $GLOBALS['abort'] !== true) {
                $extenInfo = core_users_get($extdisplay);
                extract($extenInfo);
            }
            if (isset($deviceInfo) && is_array($deviceInfo)) {
                extract($deviceInfo);
            }
            if ($display == 'extensions') {
                $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Extension") . ": {$extdisplay}", false), 0);
                if (!isset($GLOBALS['abort']) || $GLOBALS['abort'] !== true) {
                    $tlabel = sprintf(_("Delete Extension %s"), $extdisplay);
                    $label = '<span><img width="16" height="16" border="0" title="' . $tlabel . '" alt="" src="images/user_delete.png"/>&nbsp;' . $tlabel . '</span>';
                    $currentcomponent->addguielem('_top', new gui_link('del', $label, $delURL, true, false), 0);
                    $usage_list = framework_display_destination_usage(core_getdest($extdisplay));
                    if (!empty($usage_list)) {
                        $currentcomponent->addguielem('_top', new gui_link_label('dests', $usage_list['text'], $usage_list['tooltip'], true), 0);
                    }
                }
            } else {
                $currentcomponent->addguielem('_top', new gui_pageheading('title', _("User") . ": {$extdisplay}", false), 0);
                if (!isset($GLOBALS['abort']) || $GLOBALS['abort'] !== true) {
                    $tlabel = sprintf(_("Delete User %s"), $extdisplay);
                    $label = '<span><img width="16" height="16" border="0" title="' . $tlabel . '" alt="" src="images/user_delete.png"/>&nbsp;' . $tlabel . '</span>';
                    $currentcomponent->addguielem('_top', new gui_link('del', $label, $delURL, true, false), 0);
                    $usage_list = framework_display_destination_usage(core_getdest($extdisplay));
                    if (!empty($usage_list)) {
                        $currentcomponent->addguielem('_top', new gui_link_label('dests', $usage_list['text'], $usage_list['tooltip'], true), 0);
                    }
                }
            }
        } elseif ($display != 'extensions') {
            $currentcomponent->addguielem('_top', new gui_pageheading('title', _("Add User/Extension")), 0);
        }
        // Setup vars for use in the gui later on
        $fc_logon = featurecodes_getFeatureCode('core', 'userlogon');
        $fc_logoff = featurecodes_getFeatureCode('core', 'userlogoff');
        $msgInvalidExtNum = _("Please enter a valid extension number.");
        $msgInvalidCidNum = _("Please enter a valid CID Num Alias (must be a valid number).");
        $msgInvalidExtPwd = _("Please enter valid User Password using numbers only");
        $msgInvalidDispName = _("Please enter a valid Display Name");
        $msgInvalidOutboundCID = _("Please enter a valid Outbound CID");
        $msgInvalidPause = _("Please enter a valid pause time in seconds, using digits only");
        $msgInvalidDIDNum = _("You have entered a non-standard dialpattern for your DID. You can only enter standard dialpatterns. You must use the inbound routing form to enter non-standard patterns");
        $msgInvalidCIDNum = _("Please enter a valid Caller ID Number or leave it blank for your Assigned DID/CID pair");
        // This is the actual gui stuff
        $currentcomponent->addguielem('_top', new gui_hidden('action', $extdisplay ? 'edit' : 'add'));
        $currentcomponent->addguielem('_top', new gui_hidden('extdisplay', $extdisplay));
        if ($display == 'extensions') {
            $section = $extdisplay ? _("Edit Extension") : _("Add Extension");
        } else {
            $section = $extdisplay ? _("Edit User") : _("Add User");
        }
        if (trim($extdisplay) != '') {
            $currentcomponent->addguielem($section, new gui_hidden('extension', $extdisplay), 2);
        } else {
            $currentcomponent->addguielem($section, new gui_textbox('extension', $extdisplay, _("User Extension"), _("The extension number to dial to reach this user."), '!isInteger()', $msgInvalidExtNum, false), 3);
        }
        if ($display != 'extensions') {
            $currentcomponent->addguielem($section, new gui_password('password', $password, _("User Password"), _("A user will enter this password when logging onto a device.") . ' ' . $fc_logon . ' ' . _("logs into a device.") . ' ' . $fc_logoff . ' ' . _("logs out of a device."), '!isInteger() && !isWhitespace()', $msgInvalidExtPwd, true));
            // extra JS function check required for blank password warning -- call last in the onsubmit() function
            $currentcomponent->addjsfunc('onsubmit()', "\treturn checkBlankUserPwd();\n", 9);
        }
        $currentcomponent->addguielem($section, new gui_textbox('name', $name, _("Display Name"), _("The caller id name for calls from this user will be set to this name. Only enter the name, NOT the number."), '!isAlphanumeric() || isWhitespace()', $msgInvalidDispName, false));
        $cid_masquerade = trim($cid_masquerade) == $extdisplay ? "" : $cid_masquerade;
        $currentcomponent->addguielem($section, new gui_textbox('cid_masquerade', $cid_masquerade, _("CID Num Alias"), _("The CID Number to use for internal calls, if different from the extension number. This is used to masquerade as a different user. A common example is a team of support people who would like their internal callerid to display the general support number (a ringgroup or queue). There will be no effect on external calls."), '!isWhitespace() && !isInteger()', $msgInvalidCidNum, false));
        $currentcomponent->addguielem($section, new gui_textbox('sipname', $sipname, _("SIP Alias"), _("If you want to support direct sip dialing of users internally or through anonymous sip calls, you can supply a friendly name that can be used in addition to the users extension to call them.")));
        // If user mode, list devices associated with this user
        //
        if ($display == 'users' && trim($extdisplay != '')) {
            $section = _("User Devices");
            $device_list = core_devices_list('all', 'full');
            usort($device_list, 'dev_grp');
            $link_count = 0;
            foreach ($device_list as $device_item) {
                if ($device_item['user'] == $extdisplay) {
                    $editURL = $_SERVER['PHP_SELF'] . '?type=setup&display=devices&skip=0&extdisplay=' . $device_item['id'];
                    $device_icon = $device_item['devicetype'] == 'fixed' ? 'images/telephone_key.png' : 'images/telephone_edit.png';
                    $device_label = '&nbsp;';
                    $device_label .= _("Edit:");
                    $device_label .= '&nbsp;' . $device_item['id'] . '&nbsp;' . $device_item['description'];
                    $device_label = '<span>
						<img width="16" height="16" border="0" title="Edit Device" alt="Edit Device" src="' . $device_icon . '"/>' . $device_label . '</span> ';
                    $currentcomponent->addguielem($section, new gui_link('dev' . $link_count++, $device_label, $editURL, true, false), 2);
                }
            }
        }
        $section = _("Extension Options");
        $currentcomponent->addguielem($section, new gui_textbox('outboundcid', $outboundcid, _("Outbound CID"), _("Overrides the caller id when dialing out a trunk. Any setting here will override the common outbound caller id set in the Trunks admin.<br><br>Format: <b>\"caller name\" &lt;#######&gt;</b><br><br>Leave this field blank to disable the outbound callerid feature for this user."), '!isCallerID()', $msgInvalidOutboundCID, true), 3);
        $ringtimer = isset($ringtimer) ? $ringtimer : '0';
        $currentcomponent->addguielem($section, new gui_selectbox('ringtimer', $currentcomponent->getoptlist('ringtime'), $ringtimer, _("Ring Time"), _("Number of seconds to ring prior to going to voicemail. Default will use the value set in the General Tab. If no voicemail is configured this will be ignored."), false));
        if (!isset($callwaiting)) {
            if ($amp_conf['ENABLECW']) {
                $callwaiting = 'enabled';
            } else {
                $callwaiting = 'disabled';
            }
        }
        $currentcomponent->addguielem($section, new gui_selectbox('callwaiting', $currentcomponent->getoptlist('callwaiting'), $callwaiting, _("Call Waiting"), _("Set the initial/current Call Waiting state for this user's extension"), false));
        $currentcomponent->addguielem($section, new gui_selectbox('call_screen', $currentcomponent->getoptlist('call_screen'), $call_screen, _("Call Screening"), _("Call Screening requires external callers to say their name, which will be played back to the user and allow the user to accept or reject the call.  Screening with memory only verifies a caller for their caller-id once. Screening without memory always requires a caller to say their name. Either mode will always announce the caller based on the last introduction saved with that callerid. If any user on the system uses the memory option, when that user is called, the caller will be required to re-introduce themselves and all users on the system will have that new introduction associated with the caller's CallerId."), false));
        $currentcomponent->addguielem($section, new gui_selectbox('pinless', $currentcomponent->getoptlist('pinless'), $pinless, _("Pinless Dialing"), _("Enabling Pinless Dialing will allow this extension to bypass any pin codes normally required on outbound calls"), false));
        $section = _("Assigned DID/CID");
        $currentcomponent->addguielem($section, new gui_textbox('newdid_name', $newdid_name, _("DID Description"), _("A description for this DID, such as \"Fax\"")), 4);
        $currentcomponent->addguielem($section, new gui_textbox('newdid', $newdid, _("Add Inbound DID"), _("A direct DID that is associated with this extension. The DID should be in the same format as provided by the provider (e.g. full number, 4 digits for 10x4, etc).<br><br>Format should be: <b>XXXXXXXXXX</b><br><br>.An optional CID can also be associated with this DID by setting the next box"), '!isDialpattern()', $msgInvalidDIDNum, true), 4);
        $currentcomponent->addguielem($section, new gui_textbox('newdidcid', $newdidcid, _("Add Inbound CID"), _("Add a CID for more specific DID + CID routing. A DID must be specified in the above Add DID box. In addition to standard dial sequences, you can also put Private, Blocked, Unknown, Restricted, Anonymous and Unavailable in order to catch these special cases if the Telco transmits them."), "!frm_{$display}_isValidCID()", $msgInvalidCIDNum, true), 4);
        $dids = core_did_list('extension');
        $did_count = 0;
        foreach ($dids as $did) {
            $did_dest = split(',', $did['destination']);
            if (isset($did_dest[1]) && $did_dest[1] == $extdisplay) {
                $did_title = $did['description'] != '' ? $did['description'] : _("DID / CID");
                $addURL = $_SERVER['PHP_SELF'] . '?type=setup&display=did&&extdisplay=' . $did['extension'] . '/' . $did['cidnum'];
                $did_icon = 'images/email_edit.png';
                $did_label = trim($did['extension']) == '' ? ' ' . _("Any DID") : ' ' . $did['extension'];
                if (trim($did['cidnum']) != '') {
                    $did_label .= ' / ' . $did['cidnum'];
                }
                if (trim($did['description']) != '') {
                    $did_label .= ' (' . $did['description'] . ')';
                }
                $did_label = '&nbsp;<span>
					<img width="16" height="16" border="0" title="' . $did_title . '" alt="" src="' . $did_icon . '"/>' . $did_label . '</span> ';
                $currentcomponent->addguielem($section, new gui_link('did_' . $did_count++, $did_label, $addURL, true, false), 4);
            }
        }
        $section = _("Recording Options");
        $currentcomponent->addguielem($section, new gui_selectbox('record_in', $currentcomponent->getoptlist('recordoptions'), $record_in, _("Record Incoming"), _("Record all inbound calls received at this extension."), false));
        $currentcomponent->addguielem($section, new gui_selectbox('record_out', $currentcomponent->getoptlist('recordoptions'), $record_out, _("Record Outgoing"), _("Record all outbound calls received at this extension."), false));
    }
}
コード例 #9
0
ファイル: page.restart.php プロジェクト: hardikk/HNH
echo _("Device List:") . "<span><br>" . _("Select Device(s) to restart.  Currently, only Aastra, Snom, Polycom, Grandstream and Cisco devices are supported.  All other devices will not show up in this list.  Click the \"Select All\" button to restart all supported devices. ");
?>
 
	<br><br></span></a></td>
	<tr>
	<td valign="top"> 
	
	<select multiple="multiple" name="restartlist[]" id="xtnlist"  tabindex="<?php 
echo ++$tabindex;
?>
">
	<?php 
if (is_null($selected)) {
    $selected = array();
}
foreach (core_devices_list() as $device) {
    if ($ua = get_device_useragent($device[0])) {
        echo '<option value="' . $device[0] . '" ';
        if (array_search($device[0], $selected) !== false) {
            echo ' selected="selected" ';
        }
        echo '>' . $device[0] . ' - ' . $device[1] . ' - ' . ucfirst($ua) . ' Device</option>';
    }
}
?>
	</select>		
	</td></tr>
	<tr><td><input type="button" name="Button" value="Select All" onclick="selectAll('xtnlist',true)" /></td></tr>

<?php 
// implementation of module hook
コード例 #10
0
function callforward_get_config($engine)
{
    $modulename = 'callforward';
    // This generates the dialplan
    global $ext;
    global $amp_conf;
    switch ($engine) {
        case "asterisk":
            // If Using CF then set this so AGI scripts can determine
            //
            if ($amp_conf['USEDEVSTATE']) {
                $ext->addGlobal('CFDEVSTATE', 'TRUE');
            }
            if (is_array($featurelist = featurecodes_getModuleFeatures($modulename))) {
                foreach ($featurelist as $item) {
                    $featurename = $item['featurename'];
                    $fname = $modulename . '_' . $featurename;
                    if (function_exists($fname)) {
                        $fcc = new featurecode($modulename, $featurename);
                        $fc = $fcc->getCodeActive();
                        unset($fcc);
                        if ($fc != '') {
                            $fname($fc);
                        }
                    } else {
                        $ext->add('from-internal-additional', 'debug', '', new ext_noop($modulename . ": No func {$fname}"));
                        var_dump($item);
                    }
                }
            }
            // Create hints context for CF codes so a device can subscribe to the DND state
            //
            $fcc = new featurecode($modulename, 'cf_toggle');
            $cf_code = $fcc->getCodeActive();
            unset($fcc);
            if ($amp_conf['USEDEVSTATE'] && $cf_code != '') {
                $ext->addInclude('from-internal-additional', 'ext-cf-hints');
                $contextname = 'ext-cf-hints';
                $device_list = core_devices_list("all", 'full', true);
                $base_offset = strlen($cf_code);
                if (!empty($device_list) && is_array($device_list)) {
                    foreach ($device_list as $device) {
                        if ($device['tech'] == 'pjsip' || $device['tech'] == 'sip' || $device['tech'] == 'iax2') {
                            $offset = $base_offset + strlen($device['id']);
                            $ext->add($contextname, '_' . $cf_code . $device['id'] . '.', '', new ext_set("toext", '${EXTEN:' . $offset . '}'));
                            $ext->add($contextname, '_' . $cf_code . $device['id'] . '.', '', new ext_goto("setdirect", $cf_code, "app-cf-toggle"));
                        }
                    }
                }
                $sql = "SELECT LENGTH(id) as len FROM devices GROUP BY len";
                $sth = FreePBX::Database()->prepare($sql);
                $sth->execute();
                $rows = $sth->fetchAll(\PDO::FETCH_ASSOC);
                foreach ($rows as $row) {
                    $offset = $base_offset + $row['len'];
                    $ext->add($contextname, '_' . $cf_code . str_repeat('X', $row['len']), '', new ext_goto("1", $cf_code, "app-cf-toggle"));
                }
                $ext->addHint($contextname, "_{$cf_code}" . 'X.', "Custom:DEVCF" . '${EXTEN:' . strlen($cf_code) . '}');
            }
            break;
    }
}
コード例 #11
0
ファイル: functions.inc.php プロジェクト: hardikk/HNH
 function generate_queues_additional($ast_version)
 {
     global $db;
     global $amp_conf;
     $additional = "";
     $output = "";
     // Asterisk 1.4 does not like blank assignments so just don't put them there
     //
     $ver12 = version_compare($ast_version, '1.4', 'lt');
     $ver16 = version_compare($ast_version, '1.6', 'ge');
     $ast_ge_14_25 = version_compare($ast_version, '1.4.25', 'ge');
     // legacy but in case someone was using this we will leave it
     //
     $sql = "SELECT keyword,data FROM queues_details WHERE id='-1' AND keyword <> 'account'";
     $results = $db->getAll($sql, DB_FETCHMODE_ASSOC);
     if (DB::IsError($results)) {
         die($results->getMessage());
     }
     foreach ($results as $result) {
         if (!$ver12 && trim($result['data']) == '') {
             continue;
         }
         $additional .= $result['keyword'] . "=" . $result['data'] . "\n";
     }
     if ($ast_ge_14_25) {
         $devices = array();
         $device_results = core_devices_list('all', 'full', true);
         if (is_array($device_results)) {
             foreach ($device_results as $device) {
                 if (!isset($devices[$device['user']]) && $device['devicetype'] == 'fixed') {
                     $devices[$device['user']] = $device['dial'];
                 }
             }
             unset($device_results);
         }
     }
     if ($amp_conf['USEQUEUESTATE'] || $ast_ge_14_25) {
         $users = array();
         $user_results = core_users_list();
         if (is_array($user_results)) {
             foreach ($user_results as $user) {
                 $users[$user[0]] = $user[1];
             }
             unset($user_results);
         }
     }
     $results = queues_list(true);
     foreach ($results as $result) {
         $output .= "[" . $result[0] . "]\n";
         // passing 2nd param 'true' tells queues_get to send back only queue_conf required params
         // and nothing else
         //
         $results2 = queues_get($result[0], true);
         // memebers is an array of members so we set it asside and remove it
         // and then generate each later
         //
         $members = $results2['member'];
         unset($results2['member']);
         foreach ($results2 as $keyword => $data) {
             if ($ver12) {
                 switch ($keyword) {
                     case 'ringinuse':
                     case 'autofill':
                         break;
                     case 'retry':
                         if ($data == 'none') {
                             $data = 0;
                         }
                         // no break, fallthrough to default
                     // no break, fallthrough to default
                     default:
                         $output .= $keyword . "=" . $data . "\n";
                         break;
                 }
             } else {
                 switch ($keyword) {
                     case trim($data) == '':
                     case 'monitor-join':
                         break;
                     case 'monitor-format':
                         if (strtolower($data) != 'no') {
                             $output .= "monitor-type=mixmonitor\n";
                             $output .= $keyword . "=" . $data . "\n";
                         }
                         break;
                     case 'announce-position':
                         if ($ver16) {
                             $output .= $keyword . "=" . $data . "\n";
                         }
                         break;
                     case 'retry':
                         if ($data == 'none') {
                             $data = 0;
                         }
                         // no break, fallthrough to default
                     // no break, fallthrough to default
                     default:
                         $output .= $keyword . "=" . $data . "\n";
                         break;
                 }
             }
         }
         // Now pull out all the memebers, one line for each
         //
         if ($amp_conf['USEQUEUESTATE']) {
             foreach ($members as $member) {
                 preg_match("/^Local\\/([\\d]+)\\@*/", $member, $matches);
                 if (isset($matches[1]) && isset($users[$matches[1]])) {
                     $name = $users[$matches[1]];
                     str_replace(',', '\\,', $name);
                     $output .= "member={$member},{$name},hint:" . $matches[1] . "@ext-local\n";
                 } else {
                     $output .= "member=" . $member . "\n";
                 }
             }
         } else {
             if ($ast_ge_14_25) {
                 foreach ($members as $member) {
                     preg_match("/^Local\\/([\\d]+)\\@*/", $member, $matches);
                     if (isset($matches[1]) && isset($devices[$matches[1]])) {
                         $name = $users[$matches[1]];
                         str_replace(',', '\\,', $name);
                         $output .= "member={$member},{$name}," . $devices[$matches[1]] . "\n";
                     } else {
                         $output .= "member=" . $member . "\n";
                     }
                 }
             } else {
                 foreach ($members as $member) {
                     $output .= "member=" . $member . "\n";
                 }
             }
         }
         $output .= $additional . "\n";
     }
     // Before returning the results, do an integrity check to see
     // if there are any truncated compound recrodings and if so
     // crate a noticication.
     //
     $nt = notifications::create($db);
     $compound_recordings = queues_check_compoundrecordings();
     if (empty($compound_recordings)) {
         $nt->delete('queues', 'COMPOUNDREC');
     } else {
         $str = _("Warning, there are compound recordings configured in one or more Queue configurations. Queues can not play these so they have been truncated to the first sound file. You should correct this problem.<br />Details:<br /><br />");
         foreach ($compound_recordings as $item) {
             $str .= sprintf(_("Queue - %s (%s): %s<br />"), $item['extension'], $item['descr'], $item['error']);
         }
         $nt->add_error('queues', 'COMPOUNDREC', _("Compound Recordings in Queues Detected"), $str);
     }
     return $output;
 }
コード例 #12
0
function queues_get_config($engine)
{
    global $ext;
    // is this the best way to pass this?
    global $amp_conf;
    global $version;
    $queues_conf = queues_conf::create();
    switch ($engine) {
        case "asterisk":
            global $astman;
            //set our reset cron
            queues_set_backup_cron();
            $ast_ge_14 = version_compare($version, '1.4', 'ge');
            $ast_ge_16 = version_compare($version, '1.6', 'ge');
            $ast_ge_14_25 = version_compare($version, '1.4.25', 'ge');
            $ast_ge_18 = version_compare($version, '1.8', 'ge');
            $ast_ge_11 = version_compare($version, '11', 'ge');
            $ast_ge_12 = version_compare($version, '12', 'ge');
            $has_extension_state = $ast_ge_16;
            if ($ast_ge_14 && !$ast_ge_16) {
                $response = $astman->send_request('Command', array('Command' => 'module show like func_extstate'));
                if (preg_match('/1 modules loaded/', $response['data'])) {
                    $has_extension_state = true;
                }
            }
            if (isset($queues_conf) && is_a($queues_conf, "queues_conf")) {
                $queues_conf->addQueuesGeneral('persistentmembers', $amp_conf['QUEUES_PESISTENTMEMBERS'] ? 'yes' : 'no');
                if ($ast_ge_16) {
                    $queues_conf->addQueuesGeneral('shared_lastcall', $amp_conf['QUEUES_SHARED_LASTCALL'] ? 'yes' : 'no');
                    $queues_conf->addQueuesGeneral('updatecdr', $amp_conf['QUEUES_UPDATECDR'] ? 'yes' : 'no');
                }
                if ($amp_conf['QUEUES_MIX_MONITOR']) {
                    $queues_conf->addQueuesGeneral('monitor-type', 'MixMonitor');
                }
            }
            /* queue extensions */
            $ext->addInclude('from-internal-additional', 'ext-queues');
            /* Trial DEVSTATE */
            $ext->addGlobal('QUEDEVSTATE', 'TRUE');
            $qlist = queues_list(true);
            if (empty($qlist)) {
                return;
                //nothing to do if we dont have any queues
            }
            // $que_code = '*45';
            $fcc = new featurecode('queues', 'que_toggle');
            $que_code = $fcc->getCodeActive();
            unset($fcc);
            if ($que_code != '') {
                queue_app_toggle();
                queue_app_all_toggle();
                queue_agent_del_toggle();
                queue_agent_add_toggle();
                $ext->addGlobal('QUEUETOGGLE', $que_code);
            }
            // $que_pause_code = '*46';
            $fcc = new featurecode('queues', 'que_pause_toggle');
            $que_pause_code = $fcc->getCodeActive();
            unset($fcc);
            if ($que_pause_code != '') {
                app_queue_pause_toggle();
                app_all_queue_pause_toggle();
                $ext->addGlobal('QUEUEPAUSETOGGLE', $que_pause_code);
            }
            // $que_callers_code = '*47';
            $fcc = new featurecode('queues', 'que_callers');
            $que_callers_code = $fcc->getCodeActive();
            unset($fcc);
            $from_queue_exten_only = 'from-queue-exten-only';
            $from_queue_exten_internal = 'from-queue-exten-internal';
            $qmembers = array();
            $hint_hash = array();
            $qlist = is_array($qlist) ? $qlist : array();
            foreach ($qlist as $item) {
                $exten = $item[0];
                $q = queues_get($exten);
                $c = 'ext-queues';
                $grppre = isset($q['prefix']) ? $q['prefix'] : '';
                $alertinfo = isset($q['alertinfo']) ? $q['alertinfo'] : '';
                // Not sure why someone would ever have a ; in the regex, but since Asterisk has problems with them
                // it would need to be escaped
                $qregex = isset($q['qregex']) ? $q['qregex'] : '';
                str_replace(';', '\\;', $qregex);
                $ext->add($c, $exten, '', new ext_macro('user-callerid'));
                if (isset($q['qnoanswer']) && $q['qnoanswer'] == FALSE) {
                    $ext->add($c, $exten, '', new ext_answer(''));
                } else {
                    // TODO: should this only be set if noanswer + (!ringtones || joinannounce)???
                    $ext->add($c, $exten, '', new ext_progress());
                }
                // block voicemail until phone is answered at which point a macro should be called on the answering
                // line to clear this flag so that subsequent transfers can occur.
                if ($q['queuewait']) {
                    $ext->add($c, $exten, '', new ext_execif('$["${QUEUEWAIT}" = ""]', 'Set', '__QUEUEWAIT=${EPOCH}'));
                }
                // If extension_only don't do this and CFIGNORE
                if ($q['use_queue_context'] != '2') {
                    $ext->add($c, $exten, '', new ext_macro('blkvm-set', 'reset'));
                    $ext->add($c, $exten, '', new ext_execif('$["${REGEX("(M[(]auto-blkvm[)])" ${DIAL_OPTIONS})}" != "1"]', 'Set', '_DIAL_OPTIONS=${DIAL_OPTIONS}M(auto-blkvm)'));
                }
                // Inform all the children NOT to send calls to destinations or voicemail
                //
                $ext->add($c, $exten, '', new ext_setvar('__NODEST', '${EXTEN}'));
                /*
                 * Virtual Queue Settings, dialplan designed so these can be changed by other modules and those changes
                 * will override the configured changes here.
                 */
                // deal with group CID prefix
                $ext->add($c, $exten, '', new ext_set('QCIDPP', '${IF($[${LEN(${VQ_CIDPP})}>0]?${VQ_CIDPP}' . ':' . ($grppre == '' ? ' ' : $grppre) . ')}'));
                $ext->add($c, $exten, '', new ext_set('VQ_CIDPP', ''));
                $ext->add($c, $exten, '', new ext_execif('$["${QCIDPP}"!=""]', 'Macro', 'prepend-cid,${QCIDPP}'));
                // Set Alert_Info
                $ainfo = $alertinfo != '' ? str_replace(';', '\\;', $alertinfo) : ' ';
                $ext->add($c, $exten, '', new ext_set('QAINFO', '${IF($[${LEN(${VQ_AINFO})}>0]?${VQ_AINFO}:' . $ainfo . ')}'));
                $ext->add($c, $exten, '', new ext_set('VQ_AINFO', ''));
                $ext->add($c, $exten, '', new ext_execif('$["${QAINFO}"!=""]', 'Set', '__ALERT_INFO=${QAINFO}'));
                $joinannounce_id = isset($q['joinannounce_id']) ? $q['joinannounce_id'] : '';
                $joinannounce = $joinannounce_id ? recordings_get_file($joinannounce_id) : ' ';
                $joinansw = isset($q['qnoanswer']) && $q['qnoanswer'] == TRUE ? 'noanswer' : '';
                $cplay = $q['skip_joinannounce'] ? ' && ${QUEUE_MEMBER(' . $exten . ',' . $q['skip_joinannounce'] . ')}<1' : '';
                $ext->add($c, $exten, '', new ext_set('QJOINMSG', '${IF($[${LEN(${VQ_JOINMSG})}>0]?${IF($["${VQ_JOINMSG}"!="0"]?${VQ_JOINMSG}: )}:' . $joinannounce . ')}'));
                $ext->add($c, $exten, '', new ext_set('VQ_JOINMSG', ''));
                $options = 't';
                if (isset($q['answered_elsewhere']) && $q['answered_elsewhere'] == '1') {
                    $ext->add($c, $exten, '', new ext_set('QCANCELMISSED', 'C'));
                }
                if ($q['rtone'] == 1) {
                    $qringopts = 'r';
                } else {
                    if ($q['rtone'] == 2) {
                        $qringopts = 'R';
                    } else {
                        $qringopts = '';
                    }
                }
                if ($qringopts) {
                    $ext->add($c, $exten, '', new ext_set('QRINGOPTS', $qringopts));
                }
                $qretry = $q['retry'] == 'none' ? 'n' : ' ';
                $ext->add($c, $exten, '', new ext_set('QRETRY', '${IF($[${LEN(${VQ_RETRY})}>0]?${VQ_RETRY}:' . $qretry . ')}'));
                $ext->add($c, $exten, '', new ext_set('VQ_RETRY', ''));
                $ext->add($c, $exten, 'qoptions', new ext_set('QOPTIONS', '${IF($[${LEN(${VQ_OPTIONS})}>0]?${VQ_OPTIONS}:' . ($options != '' ? $options : ' ') . ')}${QCANCELMISSED}${QRINGOPTS}${QRETRY}'));
                $ext->add($c, $exten, '', new ext_set('VQ_OPTIONS', ''));
                // Set these up to be easily spliced into if we want to configure ability in queue modules
                //
                $ext->add($c, $exten, 'qgosub', new ext_set('QGOSUB', '${IF($[${LEN(${VQ_GOSUB})}>0]?${VQ_GOSUB}:${QGOSUB})}'));
                $ext->add($c, $exten, '', new ext_set('VQ_GOSUB', ''));
                $ext->add($c, $exten, 'qagi', new ext_set('QAGI', '${IF($[${LEN(${VQ_AGI})}>0]?${VQ_AGI}:${QAGI})}'));
                $ext->add($c, $exten, '', new ext_set('VQ_AGI', ''));
                $ext->add($c, $exten, 'qrule', new ext_set('QRULE', '${IF($[${LEN(${VQ_RULE})}>0]?${IF($["${VQ_RULE}"!="0"]?${VQ_RULE}: )}:${QRULE})}'));
                $ext->add($c, $exten, '', new ext_set('VQ_RULE', ''));
                $ext->add($c, $exten, 'qposition', new ext_set('QPOSITION', '${IF($[${LEN(${VQ_POSITION})}>0]?${VQ_POSITION}:${QPOSITION})}'));
                $ext->add($c, $exten, '', new ext_set('VQ_POSITION', ''));
                if (!isset($q['recording']) || empty($q['recording'])) {
                    $record_mode = 'dontcare';
                } else {
                    $record_mode = $q['recording'];
                }
                if ($amp_conf['QUEUES_MIX_MONITOR']) {
                    $monitor_options = '';
                    if (isset($q['monitor_type']) && $q['monitor_type'] != '') {
                        $monitor_options .= 'b';
                    }
                    if (isset($q['monitor_spoken']) && $q['monitor_spoken'] != 0) {
                        $monitor_options .= 'V(' . $q['monitor_spoken'] . ')';
                    }
                    if (isset($q['monitor_heard']) && $q['monitor_heard'] != 0) {
                        $monitor_options .= 'v(' . $q['monitor_heard'] . ')';
                    }
                    if ($monitor_options != '') {
                        $ext->add($c, $exten, '', new ext_setvar('MONITOR_OPTIONS', $monitor_options));
                    }
                }
                $ext->add($c, $exten, '', new ext_gosub('1', 's', 'sub-record-check', "q,{$exten},{$record_mode}"));
                // Set CWIGNORE  if enabled so that busy agents don't have another line key ringing and
                // stalling the ACD.
                if ($q['cwignore'] == 1 || $q['cwignore'] == 2) {
                    $ext->add($c, $exten, '', new ext_setvar('__CWIGNORE', 'TRUE'));
                }
                if ($q['use_queue_context']) {
                    $ext->add($c, $exten, '', new ext_setvar('__CFIGNORE', 'TRUE'));
                    $ext->add($c, $exten, '', new ext_setvar('__FORWARD_CONTEXT', 'block-cf'));
                }
                $agentannounce_id = isset($q['agentannounce_id']) ? $q['agentannounce_id'] : '';
                if ($agentannounce_id) {
                    $agentannounce = recordings_get_file($agentannounce_id);
                } else {
                    $agentannounce = ' ';
                }
                if ($q['callconfirm'] == 1) {
                    $ext->add($c, $exten, '', new ext_setvar('__FORCE_CONFIRM', '${CHANNEL}'));
                    if ($amp_conf['AST_FUNC_SHARED']) {
                        $ext->add($c, $exten, '', new ext_setvar('SHARED(ANSWER_STATUS)', 'NOANSWER'));
                    }
                    $ext->add($c, $exten, '', new ext_setvar('__CALLCONFIRMCID', '${CALLERID(number)}'));
                    $callconfirm_id = isset($q['callconfirm_id']) ? $q['callconfirm_id'] : '';
                    if ($callconfirm_id) {
                        $callconfirm = recordings_get_file($callconfirm_id);
                    } else {
                        $callconfirm = ' ';
                    }
                    $ext->add($c, $exten, '', new ext_set('__ALT_CONFIRM_MSG', '${IF($[${LEN(${VQ_CONFIRMMSG})}>0]?${IF($["${VQ_CONFIRMMSG}"!="0"]?${VQ_CONFIRMMSG}: )}:' . $callconfirm . ')}'));
                    $ext->add($c, $exten, '', new ext_set('VQ_CONFIRMMSG', ''));
                }
                $ext->add($c, $exten, '', new ext_execif('$["${QJOINMSG}"!=""' . $cplay . ']', 'Playback', '${QJOINMSG}, ' . $joinansw));
                $ext->add($c, $exten, '', new ext_queuelog($exten, '${UNIQUEID}', 'NONE', 'DID', '${FROM_DID}'));
                $ext->add($c, $exten, '', new ext_set('QAANNOUNCE', '${IF($[${LEN(${VQ_AANNOUNCE})}>0]?${IF($["${VQ_AANNOUNCE}"!="0"]?${VQ_AANNOUNCE}: )}:' . $agentannounce . ')}'));
                $ext->add($c, $exten, '', new ext_set('VQ_AANNOUNCE', ''));
                $agnc = '${QAANNOUNCE}';
                $qmoh = isset($q['music']) && $q['music'] != '' ? $q['music'] : ' ';
                $ext->add($c, $exten, '', new ext_set('QMOH', '${IF($["${VQ_MOH}"!=""]?${VQ_MOH}:' . $qmoh . ')}'));
                $ext->add($c, $exten, '', new ext_set('VQ_MOH', ''));
                $ext->add($c, $exten, '', new ext_execif('$["${QMOH}"!=""]', 'Set', '__MOHCLASS=${QMOH}'));
                $ext->add($c, $exten, '', new ext_execif('$["${MOHCLASS}"!=""]', 'Set', 'CHANNEL(musicclass)=${MOHCLASS}'));
                $ext->add($c, $exten, '', new ext_set('QMAXWAIT', '${IF($[${LEN(${VQ_MAXWAIT})}>0]?${VQ_MAXWAIT}:' . ($q['maxwait'] != '' ? $q['maxwait'] : ' ') . ')}'));
                $ext->add($c, $exten, '', new ext_set('VQ_MAXWAIT', ''));
                $ext->add($c, $exten, '', new ext_set('QUEUENUM', $exten));
                $ext->add($c, $exten, '', new ext_set('QUEUEJOINTIME', '${EPOCH}'));
                $qmaxwait = '${QMAXWAIT}';
                $options = '${QOPTIONS}';
                $qagi = '${QAGI}';
                $qmacro = '';
                $qgosub = '${QGOSUB}';
                $qrule = '${QRULE}';
                $qposition = '${QPOSITION}';
                // Queue(queuename[,options[,URL[,announceoverride[,timeout[,AGI[,macro[,gosub[,rule[,position]]]]]]]]])
                //
                $ext->add($c, $exten, 'qcall', new ext_queue($exten, $options, '', $agnc, $qmaxwait, $qagi, $qmacro, $qgosub, $qrule, $qposition));
                if ($q['use_queue_context'] != '2') {
                    $ext->add($c, $exten, '', new ext_macro('blkvm-clr'));
                }
                // cancel any recording previously requested
                $ext->add($c, $exten, '', new ext_gosub('1', 's', 'sub-record-cancel'));
                // If we are here, disable the NODEST as we want things to resume as normal
                $ext->add($c, $exten, '', new ext_setvar('__NODEST', ''));
                $ext->add($c, $exten, '', new ext_setvar('_QUEUE_PRIO', '0'));
                if ($q['callconfirm'] == 1) {
                    if ($amp_conf['AST_FUNC_SHARED']) {
                        $ext->add($c, $exten, '', new ext_setvar('SHARED(ANSWER_STATUS)', ''));
                    }
                    $ext->add($c, $exten, '', new ext_setvar('__FORCE_CONFIRM', ''));
                    $ext->add($c, $exten, '', new ext_setvar('__ALT_CONFIRM_MSG', ''));
                }
                if ($monitor_options != '') {
                    $ext->add($c, $exten, '', new ext_setvar('MONITOR_OPTIONS', ''));
                }
                if ($q['cwignore'] == 1 || $q['cwignore'] == 2) {
                    $ext->add($c, $exten, '', new ext_setvar('__CWIGNORE', ''));
                }
                if ($q['use_queue_context']) {
                    $ext->add($c, $exten, '', new ext_setvar('__CFIGNORE', ''));
                    $ext->add($c, $exten, '', new ext_setvar('__FORWARD_CONTEXT', 'from-internal'));
                }
                if ($qringopts) {
                    $ext->add($c, $exten, '', new ext_set('QRINGOPTS', ''));
                }
                //VQ_DEST = str_replace(',','^',$vq['goto'])
                $ext->add($c, $exten, '', new ext_set('QDEST', '${VQ_DEST}'));
                $ext->add($c, $exten, '', new ext_set('VQ_DEST', ''));
                $ext->add($c, $exten, 'gotodest', new ext_gotoif('$["${QDEST}"=""]', $q['goto'], '${CUT(QDEST,^,1)},${CUT(QDEST,^,2)},${CUT(QDEST,^,3)}'));
                //dynamic agent login/logout
                if (trim($qregex) != '') {
                    $ext->add($c, $exten . "*", '', new ext_setvar('QREGEX', $qregex));
                }
                if ($amp_conf['GENERATE_LEGACY_QUEUE_CODES']) {
                    if ($q['use_queue_context'] == '2') {
                        $ext->add($c, $exten . "*", '', new ext_macro('agent-add', $exten . "," . $q['password'] . ",EXTEN"));
                    } else {
                        $ext->add($c, $exten . "*", '', new ext_macro('agent-add', $exten . "," . $q['password']));
                    }
                    $ext->add($c, $exten . "**", '', new ext_macro('agent-del', "{$exten}"));
                }
                if ($que_code != '') {
                    $ext->add($c, $que_code . $exten, '', new ext_setvar('QUEUENO', $exten));
                    $ext->add($c, $que_code . $exten, '', new ext_goto('start', 's', 'app-queue-toggle'));
                }
                if ($que_pause_code != '') {
                    $ext->add($c, $que_pause_code . $exten, '', new ext_gosub('1', 's', 'app-queue-pause-toggle', $exten));
                }
                /* Trial Devstate */
                // Create Hints for Devices and Add Astentries for Users
                // Clean up the Members array
                if ($q['togglehint'] && $que_code != '') {
                    if (!isset($device_list)) {
                        $device_list = core_devices_list("all", 'full', true);
                        $device_list = is_array($device_list) ? $device_list : array();
                    }
                    if ($astman) {
                        if (($dynmemberonly = strtolower($astman->database_get('QPENALTY/' . $exten, 'dynmemberonly')) == 'yes') == true) {
                            $get = $astman->database_show('QPENALTY/' . $exten . '/agents');
                            if (is_array($get)) {
                                $mem = array();
                                foreach ($get as $key => $value) {
                                    $key = explode('/', $key);
                                    $mem[$key[4]] = $value;
                                }
                            }
                        }
                    } else {
                        fatal("Cannot connect to Asterisk Manager with " . $amp_conf["AMPMGRUSER"] . "/" . $amp_conf["AMPMGRPASS"]);
                    }
                    $exten_str_len = strlen($exten);
                    $exten_str_tmp = str_repeat('X', $exten_str_len);
                    $que_code_len = strlen($que_code);
                    $device_list = !empty($device_list) ? $device_list : array();
                    foreach ($device_list as $device) {
                        if ((!$dynmemberonly || $device['devicetype'] == 'adhoc' || isset($mem[$device['user']])) && ($device['tech'] == 'sip' || $device['tech'] == 'iax2' || $device['tech'] == 'pjsip')) {
                            $dev_len = strlen($device['id']);
                            $dev_len_tmp = str_repeat('X', $dev_len);
                            $exten_pat = '_' . $que_code . $dev_len_tmp . '*' . $exten_str_tmp;
                            if (!in_array($exten_pat, $hint_hash)) {
                                $hint_hash[] = $exten_pat;
                                $ext->add($c, $exten_pat, '', new ext_setvar('QUEUENO', '${EXTEN:' . ($que_code_len + $dev_len + 1) . ":{$exten_str_len}}"));
                                $ext->add($c, $exten_pat, '', new ext_setvar('QUEUEUSER', '${EXTEN:' . "{$que_code_len}:{$dev_len}" . '}'));
                                $ext->add($c, $exten_pat, '', new ext_goto('start', 's', 'app-queue-toggle'));
                                $ext->addHint($c, $exten_pat, "Custom:QUEUE" . '${EXTEN:' . "{$que_code_len}}");
                                //TODO: dynamic hints
                            }
                        }
                    }
                }
                // Add routing vector to direct which context call should go
                //
                $agent_context = isset($q['use_queue_context']) && $q['use_queue_context'] && isset($queue_context) ? $queue_context : 'from-internal';
                switch ($q['use_queue_context']) {
                    case 1:
                        $agent_context = $from_queue_exten_internal;
                        break;
                    case 2:
                        $agent_context = $from_queue_exten_only;
                        break;
                    case 0:
                    default:
                        $agent_context = 'from-internal';
                        break;
                }
                $ext->add('from-queue', $exten, '', new ext_goto('1', '${QAGENT}', $agent_context));
                $q['member'] = is_array($q['member']) ? $q['member'] : array();
                foreach ($q['member'] as $qm) {
                    if (strtoupper(substr($qm, 0, 1)) == 'L') {
                        $tm = preg_replace("/[^0-9#\\,*]/", "", $qm);
                        $tma = explode(',', $tm);
                        $qmembers[$exten][] = $tma[0];
                    }
                }
            }
            if (!$amp_conf['DYNAMICHINTS'] && ($que_code != '' || $que_pause_code != '' || $que_callers_code != '')) {
                $qpenalty = $astman->database_show('QPENALTY');
                $qc = array();
                foreach (array_keys($qpenalty) as $key) {
                    $key = explode('/', $key);
                    if ($key[3] == 'agents') {
                        $qc[$key[4]][] = $key[2];
                    }
                }
                // Make sure we have all the devices
                //
                if (!isset($device_list)) {
                    $device_list = core_devices_list("all", 'full', true);
                    $device_list = is_array($device_list) ? $device_list : array();
                }
            }
            // Create *45 all queue toggle
            //
            if ($que_code != '') {
                $ext->add($c, $que_code, '', new ext_goto('start', 's', 'app-all-queue-toggle'));
                // create a generic one for any phones that don't get a specific one created since we only
                // create them for phones we know have queues but who knows what is provisioned on the phones
                //
                $ext->add($c, '_' . $que_code . '*X.', '', new ext_goto('start', 's', 'app-all-queue-toggle'));
                // generate with #exec if we are using dynamic hints
                //
                if ($amp_conf['DYNAMICHINTS']) {
                    $ext->addExec($c, $amp_conf['AMPBIN'] . '/generate_queue_hints.php ' . $que_code);
                } else {
                    $que_code_len = strlen($que_code);
                    $hlist = '';
                    foreach ($device_list as $device) {
                        $astman->database_del("AMPUSER/" . $device['id'], "queuehint");
                        //cleanup
                        if ($device['tech'] == 'sip' || $device['tech'] == 'iax2' || $device['tech'] == 'pjsip') {
                            if ($device['user'] != '' && isset($qc[$device['user']])) {
                                $hlist = 'Custom:QUEUE' . $device['id'] . '*' . implode('&Custom:QUEUE' . $device['id'] . '*', $qc[$device['user']]);
                                $astman->database_put("AMPUSER/" . $device['id'], "queuehint", $hlist);
                            }
                        }
                    }
                    $ext->addHint($c, '_' . $que_code . '*' . 'X.', '${DB(AMPUSER/${EXTEN:' . strlen($que_code . '*') . '}/queuehint)}');
                }
            }
            // Add the static members now since so far it only has dynamic members
            foreach ($qmembers as $q => $mems) {
                $mems = is_array($mems) ? $mems : array();
                foreach ($mems as $m) {
                    // If $m is not in qc already then add them, thus avoiding duplicates
                    if (!isset($qc[$m]) || !in_array($q, $qc[$m])) {
                        $qc[$m][] = (string) $q;
                    }
                }
            }
            // Create *46 codes/hints
            //
            if ($que_pause_code != '') {
                $ext->add($c, $que_pause_code, '', new ext_goto('1', 's', 'app-all-queue-pause-toggle'));
                // create a generic one for any phones that don't get a specific one created since we only
                // create them for phones we know have queues but who knows what is provisioned on the phones
                //
                $ext->add($c, '_' . $que_pause_code . '*X.', '', new ext_goto('1', 's', 'app-all-queue-pause-toggle'));
                // TODO: There's a bug here $q_pause_Local isn't initialized and shoudl be something.
                //       Currently this can't be made into a pattern since it's the $device['user'] but the hint has the device
                //
                $q_pause_len = strlen($que_pause_code);
                $device_list = isset($device_list) && is_array($device_list) ? $device_list : array();
                foreach ($device_list as $device) {
                    $astman->database_del("AMPUSER/" . $device['id'], "pausequeuehint");
                    if ($device['user'] != '') {
                        $pause_all_hints = array();
                        if (isset($qc[$device['user']])) {
                            foreach ($qc[$device['user']] as $q) {
                                if (!$amp_conf['DYNAMICHINTS'] && ($device['tech'] == 'pjsip' || $device['tech'] == 'sip' || $device['tech'] == 'iax2')) {
                                    // Do the real hints for below
                                    //
                                    if ($ast_ge_12) {
                                        $hint = "Queue:{$q}_pause_Local/{$device['user']}@from-queue/n";
                                    } else {
                                        $hint = "qpause:{$q}:Local/{$device['user']}@from-queue/n";
                                    }
                                    $pause_all_hints[] = $hint;
                                    $dev_len = strlen($device['id']);
                                    $dev_len_tmp = str_repeat('X', $dev_len);
                                    $exten_pat = "_{$que_pause_code}*{$dev_len_tmp}*{$q}";
                                    if (!in_array($exten_pat, $hint_hash)) {
                                        $hint_hash[] = $exten_pat;
                                        /*
                                        									exten => *46*1999*90000,1,Gosub(app-queue-pause-toggle,s,1(90000,1999))
                                        									exten => *46*1999*90000,hint,Queue:90000_pause_Local/1999@from-queue/n
                                        									${DB(DEVICE/${EXTEN:4:4}/user)}
                                        */
                                        $q_tmp = '${EXTEN:' . ($q_pause_len + $dev_len + 2) . '}';
                                        $d_tmp = '${DB(DEVICE/${EXTEN:' . ($q_pause_len + 1) . ":{$dev_len}}/user)}";
                                        if ($ast_ge_12) {
                                            $hint = "Queue:{$q_tmp}_pause_Local/{$d_tmp}@from-queue/n";
                                        } else {
                                            $hint = "qpause:{$q_tmp}:Local/{$d_tmp}@from-queue/n";
                                        }
                                        $ext->add($c, $exten_pat, '', new ext_gosub('1', 's', 'app-queue-pause-toggle', $q . ',' . $device['id']));
                                        $ext->addHint($c, $exten_pat, $hint);
                                    }
                                } else {
                                    $ext->add($c, $que_pause_code . '*' . $device['id'] . '*' . $q, '', new ext_gosub('1', 's', 'app-queue-pause-toggle', $q . ',' . $device['id']));
                                }
                            }
                        }
                        //$ext->add($c, $que_pause_code . '*' . $device['id'], '', new ext_goto('1','s','app-all-queue-pause-toggle'));
                        if (!empty($pause_all_hints)) {
                            $astman->database_put("AMPUSER/" . $device['id'], "pausequeuehint", implode('&', $pause_all_hints));
                        }
                    }
                }
                $ext->addHint($c, '_' . $que_pause_code . '*X.', '${DB(AMPUSER/${EXTEN:' . strlen($que_pause_code . '*') . '}/pausequeuehint)}');
            }
            // Create *47 codes/hints
            //
            if ($que_callers_code != '') {
                $id = "app-queue-caller-count";
                $ext->addInclude('from-internal-additional', $id);
                // Add the include from from-internal
                $ext->add($id, 's', '', new ext_answer());
                $ext->add($id, 's', '', new ext_wait(1));
                $ext->add($id, 's', '', new ext_setvar('QUEUES', '${ARG1}'));
                $ext->add($id, 's', '', new ext_setvar('COUNT', '0'));
                $ext->add($id, 's', '', new ext_setvar('LOOPCNT', '${FIELDQTY(QUEUES,&)}'));
                $ext->add($id, 's', '', new ext_setvar('ITER', '1'));
                $ext->add($id, 's', 'begin1', new ext_setvar('QUEUE', '${CUT(QUEUES,&,${ITER})}'));
                $ext->add($id, 's', '', new ext_setvar('COUNT', '$[${COUNT} + ${QUEUE_WAITING_COUNT(${QUEUE})}]'));
                $ext->add($id, 's', 'end1', new ext_setvar('ITER', '$[${ITER} + 1]'));
                $ext->add($id, 's', '', new ext_gotoif('$[${ITER} <= ${LOOPCNT}]', 'begin1'));
                $ext->add($id, 's', '', new ext_saynumber('${COUNT}'));
                $ext->add($id, 's', '', new ext_playback('queue-quantity2'));
                $ext->add($id, 's', '', new ext_return());
            }
            // We need to have a hangup here, if call is ended by the caller during Playback it will end in the
            // h context and do a proper hangup and clean the blkvm if set, see #4671
            $ext->add($c, 'h', '', new ext_macro('hangupcall'));
            // NODEST will be the queue that this came from, so we will vector though an entry to determine the context the
            // agent should be delivered to. All queue calls come here, this decides if the should go direct to from-internal
            // or indirectly through from-queue-exten-only to trap extension calls and avoid their follow-me, etc.
            //
            $ext->add('from-queue', '_.', '', new ext_setvar('QAGENT', '${EXTEN}'));
            $ext->add('from-queue', '_.', '', new ext_setvar('__FROMQ', 'true'));
            //see below comments
            $ext->add('from-queue', '_.', '', new ext_goto('1', '${NODEST}'));
            //http://issues.freepbx.org/browse/FREEPBX-11871
            //Because of local channel changes in Asterisk 12+ we end up losing track of our recording file
            //This effectively "gives" back the recording file to the channel that answered the queue
            if ($ast_ge_12) {
                $ext->splice('macro-auto-blkvm', 's', 1, new ext_execif('$["${FROMQ}" = "true" & "${CALLFILENAME}" != "" & "${CDR(recordingfile)}" = ""]', 'Set', 'CDR(recordingfile)=${CALLFILENAME}.${MON_FMT}'));
            }
            $ext->addInclude($from_queue_exten_only . '-x', 'from-internal');
            $ext->add($from_queue_exten_only . '-x', 'foo', '', new ext_noop('bar'));
            $ext->addInclude($from_queue_exten_internal, $from_queue_exten_only);
            $ext->addInclude($from_queue_exten_internal, $from_queue_exten_only . '-x');
            $ext->addInclude($from_queue_exten_internal, 'from-internal');
            $ext->add($from_queue_exten_internal, 'foo', '', new ext_noop('bar'));
            /* create a context, from-queue-exten-only, that can be used for queues that want behavir similar to
             * ringgroup where only the agent's phone will be rung, no follow-me will be pursued.
             */
            $sql = "SELECT LENGTH(extension) as len FROM users GROUP BY len";
            $sth = FreePBX::Database()->prepare($sql);
            $sth->execute();
            $rows = $sth->fetchAll(\PDO::FETCH_ASSOC);
            foreach ($rows as $row) {
                //make sure exten exists
                $ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), '', new ext_gotoif('$[${DB_EXISTS(AMPUSER/${EXTEN}/cidnum)} = 0]', $from_queue_exten_only . '-x,${EXTEN},1'));
                $ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), '', new ext_set('RingGroupMethod', 'none'));
                $ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), '', new ext_set('QDOPTS', '${IF($["${CALLER_DEST}"!=""]?g)}${IF($["${AGENT_DEST}"!=""]?F(${AGENT_DEST}))}'));
                $ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), 'checkrecord', new ext_set('CALLTYPE_OVERRIDE', 'external'));
                // Make sure the call is tagged as external
                // This means:
                // If (!$fromexten) { if (!$nodest) { $fromexten = 'external' } else { $fromexten = $nodest } }
                $ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), '', new ext_execif('$[!${LEN(${FROMEXTEN})}]', 'Set', 'FROMEXTEN=${IF(${LEN(${NODEST})}?${NODEST}:external)}'));
                // Make sure the call is tagged as external
                $ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), '', new ext_gosub('1', 's', 'sub-record-check', 'exten,${EXTEN},'));
                if ($has_extension_state) {
                    $ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), '', new ext_macro('dial-one', ',${DIAL_OPTIONS}${QDOPTS},${EXTEN}'));
                } else {
                    $ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), '', new ext_macro('dial', ',${DIAL_OPTIONS}${QDOPTS},${EXTEN}'));
                }
                $ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), '', new ext_gotoif('$["${CALLER_DEST}"!=""&&"${DIALSTATUS}"="ANSWER"]', '${CUT(CALLER_DEST,^,1)},${CUT(CALLER_DEST,^,2)},${CUT(CALLER_DEST,^,3)}'));
                $ext->add($from_queue_exten_only, '_' . str_repeat('X', $row['len']), '', new ext_hangup());
            }
            if (!empty($rows)) {
                $ext->add($from_queue_exten_only, 'h', '', new ext_macro('hangupcall'));
            }
            /*
             * Adds a dynamic agent/member to a Queue
             * Prompts for call-back number - in not entered, uses CIDNum
             */
            if ($amp_conf['GENERATE_LEGACY_QUEUE_CODES']) {
                $c = 'macro-agent-add';
                // for i18n playback in multiple languages
                $ext->add($c, 'lang-playback', '', new ext_gosubif('$[${DIALPLAN_EXISTS(' . $c . ',${CHANNEL(language)})}]', $c . ',${CHANNEL(language)},${ARG1}', $c . ',en,${ARG1}'));
                $ext->add($c, 'lang-playback', '', new ext_return());
                $exten = 's';
                $ext->add($c, $exten, '', new ext_wait(1));
                $ext->add($c, $exten, '', new ext_set('QUEUENO', '${ARG1}'));
                $ext->add($c, $exten, '', new ext_macro('user-callerid', 'SKIPTTL'));
                $ext->add($c, $exten, 'a3', new ext_read('CALLBACKNUM', 'agent-login'));
                // get callback number from user
                $ext->add($c, $exten, '', new ext_gotoif('$[${LEN(${CALLBACKNUM})}=0]', 'a5', 'a7'));
                // if user just pressed # or timed out, use cidnum
                $ext->add($c, $exten, 'a5', new ext_set('CALLBACKNUM', '${IF($[${LEN(${AMPUSER})}=0]?${CALLERID(number)}:${AMPUSER})}'));
                $ext->add($c, $exten, '', new ext_set('THISDEVICE', '${DB(DEVICE/${REALCALLERIDNUM}/dial)}'));
                $ext->add($c, $exten, '', new ext_gotoif('$["${CALLBACKNUM}" = ""]', 'a3'));
                // if still no number, start over
                $ext->add($c, $exten, 'a7', new ext_gotoif('$["${CALLBACKNUM}" = "${QUEUENO}"]', 'invalid'));
                // Error, they put in the queue number
                // If this is an extension only queue then EXTEN is passed as ARG3 and we make sure this is a valid extension being entered
                $ext->add($c, $exten, '', new ext_gotoif('$["${ARG3}" = "EXTEN" & ${DB_EXISTS(AMPUSER/${CALLBACKNUM}/cidname)} = 0]', 'invalid'));
                // If this is a restricted dynamic agent queue then check to make sure they are allowed
                $ext->add($c, $exten, '', new ext_gotoif('$["${DB(QPENALTY/${QUEUENO}/dynmemberonly)}" = "yes" & ${DB_EXISTS(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})} != 1]', 'invalid'));
                $ext->add($c, $exten, '', new ext_execif('$["${QREGEX}" != ""]', 'GotoIf', '$["${REGEX("${QREGEX}" ${CALLBACKNUM})}" = "0"]?invalid'));
                $ext->add($c, $exten, '', new ext_execif('$["${ARG2}" != ""]', 'Authenticate', '${ARG2}'));
                $ext->add($c, $exten, '', new ext_set('STATE', 'INUSE'));
                $ext->add($c, $exten, '', new ext_gosub('1', 'sstate', 'app-queue-toggle'));
                $ext->add($c, $exten, '', new ext_execif('$[${DB_EXISTS(AMPUSER/${CALLBACKNUM}/cidname)} = 1 & "${DB(AMPUSER/${CALLBACKNUM}/queues/qnostate)}" != "ignorestate"]', 'AddQueueMember', '${QUEUENO},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})},,${DB(AMPUSER/${CALLBACKNUM}/cidname)},hint:${CALLBACKNUM}@ext-local'));
                $ext->add($c, $exten, '', new ext_execif('$[${DB_EXISTS(AMPUSER/${CALLBACKNUM}/cidname)} = 1 & "${DB(AMPUSER/${CALLBACKNUM}/queues/qnostate)}" = "ignorestate"]', 'AddQueueMember', '${QUEUENO},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})},,${DB(AMPUSER/${CALLBACKNUM}/cidname)}'));
                $ext->add($c, $exten, '', new ext_execif('$[${DB_EXISTS(AMPUSER/${CALLBACKNUM}/cidname)} = 0]', 'AddQueueMember', '${QUEUENO},Local/${CALLBACKNUM}@from-queue/n,${DB(QPENALTY/${QUEUENO}/agents/${CALLBACKNUM})}'));
                $ext->add($c, $exten, '', new ext_userevent('Agentlogin', 'Agent: ${CALLBACKNUM}'));
                $ext->add($c, $exten, '', new ext_wait(1));
                $ext->add($c, $exten, '', new ext_gosub('1', 'lang-playback', $c, 'hook_0'));
                $ext->add($c, $exten, '', new ext_hangup());
                $ext->add($c, $exten, '', new ext_macroexit());
                $ext->add($c, $exten, 'invalid', new ext_playback('pbx-invalid'));
                $ext->add($c, $exten, '', new ext_goto('a3'));
                $lang = 'en';
                // English
                $ext->add($c, $lang, 'hook_0', new ext_playback('agent-loginok&with&extension'));
                $ext->add($c, $lang, '', new ext_saydigits('${CALLBACKNUM}'));
                $ext->add($c, $lang, '', new ext_return());
                $lang = 'ja';
                // Japanese
                $ext->add($c, $lang, 'hook_0', new ext_playback('extension'));
                $ext->add($c, $lang, '', new ext_saydigits('${CALLBACKNUM}'));
                $ext->add($c, $lang, '', new ext_playback('jp-kara&agent-loginok'));
                $ext->add($c, $lang, '', new ext_return());
                /*
                 * Removes a dynamic agent/member from a Queue
                 * Prompts for call-back number - in not entered, uses CIDNum
                 */
                $c = 'macro-agent-del';
                $ext->add($c, $exten, '', new ext_wait(1));
                $ext->add($c, $exten, '', new ext_set('QUEUENO', '${ARG1}'));
                $ext->add($c, $exten, '', new ext_macro('user-callerid', 'SKIPTTL'));
                $ext->add($c, $exten, 'a3', new ext_read('CALLBACKNUM', 'agent-logoff'));
                // get callback number from user
                $ext->add($c, $exten, '', new ext_gotoif('$[${LEN(${CALLBACKNUM})}=0]', 'a5', 'a7'));
                // if user just pressed # or timed out, use cidnum
                $ext->add($c, $exten, 'a5', new ext_set('CALLBACKNUM', '${IF($[${LEN(${AMPUSER})}=0]?${CALLERID(number)}:${AMPUSER})}'));
                $ext->add($c, $exten, '', new ext_gotoif('$["${CALLBACKNUM}" = ""]', 'a3'));
                // if still no number, start over
                $ext->add($c, $exten, '', new ext_set('STATE', 'NOT_INUSE'));
                $ext->add($c, $exten, '', new ext_gosub('1', 'sstate', 'app-queue-toggle'));
                // remove from both contexts in case left over dynamic agents after an upgrade
                $ext->add($c, $exten, 'a7', new ext_removequeuemember('${QUEUENO}', 'Local/${CALLBACKNUM}@from-queue/n'));
                $ext->add($c, $exten, '', new ext_removequeuemember('${QUEUENO}', 'Local/${CALLBACKNUM}@from-internal/n'));
                $ext->add($c, $exten, '', new ext_userevent('RefreshQueue'));
                $ext->add($c, $exten, '', new ext_wait(1));
                $ext->add($c, $exten, '', new ext_playback('agent-loggedoff'));
                $ext->add($c, $exten, '', new ext_hangup());
            }
            // GENERATE_LEGACY_QUEUE_CODES
            break;
    }
}
コード例 #13
0
ファイル: page.paging.php プロジェクト: hardikk/HNH
function paging_show($xtn, $display, $type, $conflict_url = array())
{
    global $module_hook;
    if ($xtn) {
        $selected = paging_get_devs($xtn);
        $rows = count($selected) + 1;
        if ($rows < 5) {
            $rows = 5;
        }
        if ($rows > 20) {
            $rows = 20;
        }
        $delURL = $_SERVER['PHP_SELF'] . "?type={$type}&amp;display={$display}&amp;action=delete&amp;selection={$xtn}";
        $tlabel = sprintf(_("Delete Group %s"), $xtn);
        $label = '<span><img width="16" height="16" border="0" title="' . $tlabel . '" alt="" src="images/core_delete.png"/>&nbsp;' . $tlabel . '</span>';
        echo "<a href=" . $delURL . ">" . $label . "</a>";
    } else {
        $rows = 5;
    }
    if (!empty($conflict_url)) {
        echo "<h5>" . _("Conflicting Extensions") . "</h5>";
        echo implode('<br />', $conflict_url);
    }
    $config = paging_get_pagingconfig($xtn);
    $force_page = $config['force_page'];
    $duplex = $config['duplex'];
    $default_group = $config['default_group'];
    $description = $config['description'];
    echo "<form name='page_edit' action='" . $_SERVER['PHP_SELF'] . "' method='post' onsubmit='return page_edit_onsubmit();'>\n";
    echo "<input type='hidden' name='display' value='{$display}'>\n";
    echo "<input type='hidden' name='type' value='{$type}'>\n";
    echo "<input type='hidden' name='pagegrp' value='{$xtn}'>\n";
    echo "<input type='hidden' name='action' value='submit'>\n";
    echo "<table><tr><td colspan=2><h5>";
    echo $xtn ? _("Modify Paging Group") : _("Add Paging Group") . "</h5></td></tr>\n";
    ?>
	<tr>
		<td><a href='#' class='info'><?php 
    echo _("Paging Extension");
    ?>
<span><?php 
    echo _("The number users will dial to page this group");
    ?>
</span></a></td>
		<td><input size='5' type='text' name='pagenbr' value='<?php 
    echo $xtn;
    ?>
' tabindex="<?php 
    echo ++$tabindex;
    ?>
"></td>
	</tr>
	<tr>
    <td> <a href="#" class="info"><?php 
    echo _("Group Description");
    ?>
:<span><?php 
    echo _("Provide a descriptive title for this Page Group.");
    ?>
</span></a></td>
		<td><input size="24" maxlength="24" type="text" name="description" id="description" value="<?php 
    echo htmlspecialchars($description);
    ?>
" tabindex="<?php 
    echo ++$tabindex;
    ?>
"></td>
	</tr>
	<tr><td valign='top'><a href='#' class='info'><?php 
    echo _("Device List:") . "<span><br>" . _("Select Device(s) to page. This is the phone that should be paged. In most installations, this is the same as the Extension. If you are configured to use \"Users & Devices\" this is the actual Device and not the User.  Use Ctrl key to select multiple..");
    ?>
 
	<br><br></span></a></td>
	<td valign="top"> 
	
	<select multiple="multiple" name="pagelist[]" id="xtnlist"  tabindex="<?php 
    echo ++$tabindex;
    ?>
">
	<?php 
    if (!isset($selected)) {
        $selected = paging_get_devs($xtn);
    }
    if (is_null($selected)) {
        $selected = array();
    }
    foreach (core_devices_list() as $device) {
        echo '<option value="' . $device[0] . '" ';
        if (array_search($device[0], $selected) !== false) {
            echo ' selected="selected" ';
        }
        echo '>' . $device[0] . ' - ' . $device[1] . '</option>';
    }
    ?>
	</select>
		
		<br>
	</td></tr>

	<tr><td><label for="force_page"><a href='#' class='info'><?php 
    echo _("Force if busy");
    ?>
<span>
	<?php 
    echo _("If selected, will not check if the device is in use before paging it. This means conversations can be interrupted by a page (depending on how the device handles it). This is useful for \"emergency\" paging groups ");
    ?>
</span></a></label></td>
	<td><input type='checkbox' name='force_page' id="force_page" value='1' <?php 
    if ($force_page) {
        echo 'CHECKED';
    }
    ?>
 tabindex="<?php 
    echo ++$tabindex;
    ?>
"></td></tr>

	<tr><td><label for="duplex"><a href='#' class='info'><?php 
    echo _("Duplex");
    ?>
<span>
	<?php 
    echo _("Paging is typically one way for announcements only. Checking this will make the paging duplex, allowing all phones in the paging group to be able to talk and be heard by all. This makes it like an \"instant conference\"");
    ?>
</span></a></label></td>
	<td><input type='checkbox' name='duplex' id="duplex" value='1' <?php 
    if ($duplex) {
        echo 'CHECKED';
    }
    ?>
 tabindex="<?php 
    echo ++$tabindex;
    ?>
"></td></tr>

	<tr><td><label for="default_group"><a href='#' class='info'><?php 
    echo _("Default Page Group");
    ?>
<span>
	<?php 
    echo _("Each PBX system can have a single Default Page Group. If specified, extensions can be automatically added (or removed) from this group in the Extensions (or Devices) tab.<br />Making this group the default will uncheck the option from the current default group if specified.");
    ?>
</span></a></label></td>
	<td><input type='checkbox' name='default_group' id="default_group" value='1' <?php 
    if ($default_group) {
        echo 'CHECKED';
    }
    ?>
 tabindex="<?php 
    echo ++$tabindex;
    ?>
"></td></tr>

<?php 
    // implementation of module hook
    // object was initialized in config.php
    echo $module_hook->hookHtml;
    ?>
	
	<tr>
	<td colspan="2"><br><h6><input type="submit" name="Submit" type="button" value="<?php 
    echo _("Submit Changes");
    ?>
" tabindex="<?php 
    echo ++$tabindex;
    ?>
"></h6></td>
	</tr>
	</table>
<script language="javascript">
<!--
var theForm = document.page_edit;
theForm.pagenbr.focus();

function page_edit_onsubmit() {
	var msgInvalidPageExt = "<?php 
    echo _('Please enter a valid Paging Extension');
    ?>
";
	var msgInvalidExtList = "<?php 
    echo _('Please select at least one extension');
    ?>
";

	defaultEmptyOK = false;
	if (!isInteger(theForm.pagenbr.value))
		return warnInvalid(theForm.pagenbr, msgInvalidPageExt);
	
	var selected = 0;
	for (var i=0; i < theForm.xtnlist.options.length; i++) {
		if (theForm.xtnlist.options[i].selected) selected += 1;
	}
	if (selected < 1) {
    theForm.xtnlist.focus();
		alert(msgInvalidExtList);
		return false;
	}
		
	return true;
}

-->
</script>
	</form>
<?php 
}