function verifyvoice_get_config($engine)
{
    $modulename = 'verifyvoice';
    # This will actually put our extn in the dialplan;
    global $ext;
    global $asterisk_conf;
    switch ($engine) {
        case "asterisk":
            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}"));
                    }
                }
            }
            break;
    }
}
Пример #2
0
function callwaiting_get_config($engine)
{
    $modulename = 'callwaiting';
    // This generates the dialplan
    global $ext;
    switch ($engine) {
        case "asterisk":
            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);
                    }
                }
            }
            break;
    }
}
Пример #3
0
function blacklist_get_config($engine)
{
    global $ext;
    global $version;
    global $astman;
    switch ($engine) {
        case "asterisk":
            $id = "app-blacklist";
            $ext->addInclude('from-internal-additional', $id);
            // Add the include from from-internal
            $id = "app-blacklist-check";
            $c = "s";
            // LookupBlackList doesn't seem to match empty astdb entry for "blacklist/", so we
            // need to check for the setting and if set, send to the blacklisted area
            // The gotoif below is not a typo.  For some reason, we've seen the CID number set to Unknown or Unavailable
            // don't generate the dialplan if they are not using the function
            //
            if ($astman->database_get("blacklist", "blocked") == '1') {
                $ext->add($id, $c, '', new ext_gotoif('$["${CALLERID(number)}" = "Unknown"]', 'check-blocked'));
                $ext->add($id, $c, '', new ext_gotoif('$["${CALLERID(number)}" = "Unavailable"]', 'check-blocked'));
                $ext->add($id, $c, '', new ext_gotoif('$["foo${CALLERID(number)}" = "foo"]', 'check-blocked', 'check'));
                $ext->add($id, $c, 'check-blocked', new ext_gotoif('$["${DB(blacklist/blocked)}" = "1"]', 'blacklisted'));
            }
            if (version_compare($version, "1.6", "ge")) {
                $ext->add($id, $c, 'check', new ext_gotoif('$["${BLACKLIST()}"="1"]', 'blacklisted'));
            } else {
                $ext->add($id, $c, 'check', new ext_lookupblacklist(''));
                $ext->add($id, $c, '', new ext_gotoif('$["${LOOKUPBLSTATUS}"="FOUND"]', 'blacklisted'));
            }
            $ext->add($id, $c, '', new ext_setvar('CALLED_BLACKLIST', '1'));
            $ext->add($id, $c, '', new ext_return(''));
            $ext->add($id, $c, 'blacklisted', new ext_answer(''));
            $ext->add($id, $c, '', new ext_wait(1));
            $ext->add($id, $c, '', new ext_zapateller(''));
            $ext->add($id, $c, '', new ext_playback('ss-noservice'));
            $ext->add($id, $c, '', new ext_hangup(''));
            $modulename = 'blacklist';
            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);
                    }
                }
            }
            break;
    }
}
Пример #4
0
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;
    }
}
Пример #5
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;
    }
}
Пример #6
0
function gabcast_get_config($engine)
{
    $modulename = 'gabcast';
    // This generates the dialplan
    global $ext;
    switch ($engine) {
        case "asterisk":
            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);
                    }
                }
            } else {
                $ext->add('from-internal-additional', 'debug', new ext_noop($modulename . ": No modules??"));
            }
            $context = "gabcast";
            $ext->add($context, '_X.', '', new ext_dial('IAX2/iax.gabcast.com/422,120'));
            $ext->add($context, 's', '', new ext_dial('IAX2/iax.gabcast.com/422,120'));
            $gablist = gabcast_list();
            if ($gablist) {
                foreach ($gablist as $gab) {
                    $extension = $gab[0];
                    $channbr = $gab[1];
                    $pin = $gab[2];
                    $ext->add($context, $extension, '', new ext_dial('IAX2/iax.gabcast.com/' . $channbr . '*' . $pin . ',120'));
                }
            }
            break;
    }
}
Пример #7
0
function voicemail_get_config($engine)
{
    $modulename = 'voicemail';
    // This generates the dialplan
    global $ext;
    switch ($engine) {
        case "asterisk":
            /*
             * vm-callme context plays voicemail over telephone for web click-to-call
             * MSG and MBOX are channel variables that must be set when originating the call
             */
            $context = 'vm-callme';
            $ext->add($context, 's', '', new ext_answer());
            $ext->add($context, 's', '', new ext_wait(1));
            $ext->add($context, 's', 'repeat', new ext_background('${MSG}&silence/2&vm-repeat&vm-starmain'));
            $ext->add($context, 's', '', new ext_waitexten(15));
            $ext->add($context, '5', '', new ext_goto('repeat', 's'));
            $ext->add($context, '#', '', new ext_playback('vm-goodbye'));
            $ext->add($context, '#', '', new ext_hangup());
            $ext->add($context, '*', '', new ext_macro('get-vmcontext', '${MBOX}'));
            $ext->add($context, '*', '', new ext_vmmain('${MBOX}@${VMCONTEXT},s'));
            $ext->add($context, 'i', '', new ext_playback('pm-invalid-option'));
            $ext->add($context, 'i', '', new ext_goto('repeat', 's'));
            $ext->add($context, 't', '', new ext_playback('vm-goodbye'));
            $ext->add($context, 't', '', new ext_hangup());
            $ext->add($context, 'h', '', new ext_hangup());
            /* end vm-callme context  */
            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}"));
                    }
                }
            }
            // Temporary Kludge Until we remove these as globals out of VMX Locater and Other Places
            // However, if we remove these, we MUST make some changes to the dialplan currently commented
            // in the vmx locater code in core
            $settings = voicemail_admin_get();
            foreach ($settings as $k => $v) {
                $ext->addGlobal($k, $v);
            }
            break;
    }
}
Пример #8
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;
    }
}
Пример #9
0
function campon_get_config($engine)
{
    $modulename = 'campon';
    // This generates the dialplan
    global $ext;
    global $amp_conf;
    global $campon_conf;
    if (!$amp_conf['CC_ENABLE']) {
        return true;
    }
    switch ($engine) {
        case "asterisk":
            $campon_conf->addGeneralSetting('cc_max_requests', $amp_conf['CC_MAX_REQUESTS_GLOBAL']);
            $campon_conf->addGeneralSetting('cc_available_devstate', $amp_conf['CC_BLF_OFFERED']);
            $campon_conf->addGeneralSetting('cc_offered_devstate', $amp_conf['CC_BLF_OFFERED']);
            $campon_conf->addGeneralSetting('cc_caller_requested_devstate', $amp_conf['CC_BLF_OFFERED']);
            $campon_conf->addGeneralSetting('cc_active_devstate', $amp_conf['CC_BLF_PENDING']);
            $campon_conf->addGeneralSetting('cc_callee_ready_devstate', $amp_conf['CC_BLF_PENDING']);
            $campon_conf->addGeneralSetting('cc_caller_busy_devstate', $amp_conf['CC_BLF_CALLER_BUSY']);
            $campon_conf->addGeneralSetting('cc_recalling_devstate', $amp_conf['CC_BLF_RECALL']);
            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}"));
                    }
                }
            }
            $mcontext = 'sub-ccss';
            $exten = 's';
            $ext->add($mcontext, $exten, '', new ext_execif('$[${LEN(${CCSS_SETUP})}]', 'Return'));
            $ext->add($mcontext, $exten, '', new ext_set('CCSS_SETUP', 'TRUE'));
            $ext->add($mcontext, $exten, '', new ext_noop_trace('AMPUSER: ${AMPUSER} Calling ${ARG2}:${ARG1} checking if all happy'));
            $ext->add($mcontext, $exten, 'monitor', new ext_gosubif('$[${LEN(${DB(AMPUSER/${ARG2}/ccss/cc_monitor_policy)})}]', 'monitor_config,1', 'monitor_default,1', '${ARG1},${ARG2}', '${ARG1},${ARG2}'));
            $ext->add($mcontext, $exten, 'agent', new ext_gosubif('$[${LEN(${DB(AMPUSER/${AMPUSER}/ccss/cc_agent_policy)})}]', 'agent_config,1', 'agent_default,1'));
            // If we got this far (vs. an early StackPop) then we save the number we are calling to play back as the callback
            //
            $ext->add($mcontext, $exten, '', new ext_set('DB(AMPUSER/${AMPUSER}/ccss/last_number)', '${ARG2}'));
            $ext->add($mcontext, $exten, '', new ext_return('${GOSUB_RETVAL}'));
            /**
             * If we are in this subroutine, it has been confirmed user doesn't have 'never' as a policy, but they could
             * have it empty, just need to TODO: double check that this couldn't be called if they are not a user, check spot
             * in the macro-user-callerid
             *
             * if the called party does not allow monitoring, then we 'StackPop' and don't end up setting any agent settings
             **/
            // subroutine(monitor_config)
            $exten = 'monitor_config';
            $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(cc_monitor_policy)', '${DB(AMPUSER/${ARG2}/ccss/cc_monitor_policy)}'));
            $ext->add($mcontext, $exten, '', new ext_gotoif('$["CALLCOMPLETION(cc_monitor_policy)" != "never"]', 'set_monitor'));
            $ext->add($mcontext, $exten, '', new ext_noop_trace('Callee has no settings and default disabled, returning'));
            $ext->add($mcontext, $exten, '', new ext_stackpop(''));
            $ext->add($mcontext, $exten, '', new ext_return('FALSE'));
            $ext->add($mcontext, $exten, 'set_monitor', new ext_set('CALLCOMPLETION(cc_max_monitors)', '${DB(AMPUSER/${ARG2}/ccss/max_monitors)}'));
            $ext->add($mcontext, $exten, '', new ext_return('TRUE'));
            /**
             * if we are here, there is either no monitor policy set for the destination extension, or it may not be an extension
             * determing which one and what rules are. Either set defaults or abort at this point
             **/
            // subroutine(monitor_default)
            $exten = 'monitor_default';
            $ext->add($mcontext, $exten, '', new ext_gotoif('$["${DB(AMPUSER/${ARG2}/cidname)}" != ""]', 'is_exten'));
            if ($amp_conf['CC_NON_EXTENSION_POLICY'] == 'never') {
                $ext->add($mcontext, $exten, '', new ext_noop_trace('calling a non-extension: [${ARG2} / ${DB(AMPUSER/${ARG2}/cidname)}], policy enabled , continuing', 6));
                $ext->add($mcontext, $exten, '', new ext_stackpop(''));
                $ext->add($mcontext, $exten, '', new ext_return('FALSE'));
            } else {
                $ext->add($mcontext, $exten, '', new ext_noop_trace('calling a non-extension: [${ARG2} / ${DB(AMPUSER/${ARG2}/cidname)}], policy enabled , continuing', 6));
                $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(cc_monitor_policy)', $amp_conf['CC_NON_EXTENSION_POLICY']));
                $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(cc_max_monitors)', $amp_conf['CC_MAX_MONITORS_DEFAULT']));
                $ext->add($mcontext, $exten, '', new ext_return('TRUE'));
            }
            if ($amp_conf['CC_MONITOR_POLICY_DEFAULT'] == 'never') {
                $ext->add($mcontext, $exten, 'is_exten', new ext_noop_trace('Callee has no settings and default is never so disabling'));
                $ext->add($mcontext, $exten, 'is_exten', new ext_stackpop(''));
                $ext->add($mcontext, $exten, '', new ext_return('FALSE'));
            } else {
                $ext->add($mcontext, $exten, 'is_exten', new ext_noop_trace('Callee has no settings and default enabled, continuing'));
                $ext->add($mcontext, $exten, 'is_exten', new ext_set('CALLCOMPLETION(cc_monitor_policy)', $amp_conf['CC_MONITOR_POLICY_DEFAULT']));
                $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(cc_max_monitors)', $amp_conf['CC_MAX_MONITORS_DEFAULT']));
                $ext->add($mcontext, $exten, '', new ext_return('TRUE'));
            }
            // subroutine(agent_config)
            $exten = 'agent_config';
            $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(cc_agent_policy)', '${DB(AMPUSER/${AMPUSER}/ccss/cc_agent_policy)}'));
            $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(cc_offer_timer)', '${DB(AMPUSER/${AMPUSER}/ccss/cc_offer_timer)}'));
            $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(ccbs_available_timer)', '${DB(AMPUSER/${AMPUSER}/ccss/ccbs_available_timer)}'));
            $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(ccnr_available_timer)', '${DB(AMPUSER/${AMPUSER}/ccss/ccnr_available_timer)}'));
            $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(cc_callback_macro)', 'ccss-default'));
            $ext->add($mcontext, $exten, '', new ext_execif('$["${CALLCOMPLETION(cc_agent_policy)}" = "generic"]', 'Set', 'CALLCOMPLETION(cc_recall_timer)=${DB(AMPUSER/${AMPUSER}/ccss/cc_recall_timer)}'));
            $ext->add($mcontext, $exten, '', new ext_execif('$["${CALLCOMPLETION(cc_agent_policy)}" = "generic"]', 'Set', 'CALLCOMPLETION(cc_max_agents)=${DB(AMPUSER/${AMPUSER}/ccss/cc_max_agents)}'));
            $ext->add($mcontext, $exten, '', new ext_execif('$["${DB(AMPUSER/${AMPUSER}/ccss/cc_agent_dialstring)}" != ""]', 'Set', 'CALLCOMPLETION(cc_agent_dialstring)=Local/${AMPUSER}_${CALLERID(dnid)}@from-ccss-${DB(AMPUSER/${AMPUSER}/ccss/cc_agent_dialstring)}'));
            $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(cc_callback_macro)', 'ccss-default'));
            $ext->add($mcontext, $exten, '', new ext_return(''));
            // subroutine(agent_default)
            $exten = 'agent_default';
            if ($amp_conf['CC_AGENT_POLICY_DEFAULT'] == 'never') {
                $ext->add($mcontext, $exten, '', new ext_noop_trace('Caller has no settings and default is never so disabling'));
                $ext->add($mcontext, $exten, '', new ext_stackpop(''));
                $ext->add($mcontext, $exten, '', new ext_return('FALSE'));
            } else {
                // TODO: is it possible we are not an extension calling here and we need more logic to safeguard?
                $ext->add($mcontext, $exten, '', new ext_noop_trace('Caller has no settings using default values since policy is enabled'));
                $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(cc_agent_policy)', $amp_conf['CC_AGENT_POLICY_DEFAULT']));
                $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(cc_offer_timer)', $amp_conf['CC_OFFER_TIMER_DEFAULT']));
                $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(ccbs_available_timer)', $amp_conf['CCBS_AVAILABLE_TIMER_DEFAULT']));
                $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(ccnr_available_timer)', $amp_conf['CCNR_AVAILABLE_TIMER_DEFAULT']));
                $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(cc_callback_macro)', 'ccss-default'));
                if ($amp_conf['CC_AGENT_POLICY_DEFAULT'] == 'generic') {
                    $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(cc_recall_timer)', $amp_conf['CC_RECALL_TIMER_DEFAULT']));
                } else {
                    $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(cc_max_agents)', $amp_conf['CC_MAX_AGENTS_DEFAULT']));
                }
                if ($amp_conf['CC_AGENT_DIALSTRING_DEFAULT'] == 'extension') {
                    $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(cc_agent_dialstring)', 'Local/${AMPUSER}_${CALLERID(dnid)}@from-ccss-extension'));
                } else {
                    if ($amp_conf['CC_AGENT_DIALSTRING_DEFAULT'] == 'internal') {
                        $ext->add($mcontext, $exten, '', new ext_set('CALLCOMPLETION(cc_agent_dialstring)', 'Local/${AMPUSER}_${CALLERID(dnid)}@from-ccss-internal'));
                    }
                }
                $ext->add($mcontext, $exten, '', new ext_return('TRUE'));
            }
            $mcontext = 'macro-ccss-default';
            $exten = 's';
            $cpp = $amp_conf['CC_FORCE_DEFAULTS'] ? $amp_conf['CC_MONITOR_CID_PREPEND_DEFAULT'] : '${DB(AMPUSER/${CC_EXTEN}/ccss/cc_monitor_cid_prepend)}';
            if ($amp_conf['CC_FORCE_DEFAULTS'] && $amp_conf['CC_ANNOUNCE_MONITOR_DEFAULT']) {
                $ext->add($mcontext, $exten, '', new ext_playback('beep&calling&extension'));
                $ext->add($mcontext, $exten, '', new ext_saydigits('${CC_EXTEN}'));
            } elseif ($amp_conf['CC_FORCE_DEFAULTS']) {
                $ext->add($mcontext, $exten, '', new ext_answer(''));
            } else {
                $ext->add($mcontext, $exten, '', new ext_gotoif('$["${DB(AMPUSER/${AMPUSER}/ccss/cc_announce_monitor)}" = "silent"]', 'siprm'));
                $ext->add($mcontext, $exten, '', new ext_playback('beep&calling&extension'));
                $ext->add($mcontext, $exten, '', new ext_saydigits('${CC_EXTEN}'));
            }
            //TODO: should this be conditional if CC_HEADER is set??? - if not, it will remove all headers if not
            //
            $ext->add($mcontext, $exten, 'siprm', new ext_sipremoveheader('${CC_HEADER}'));
            $ext->add($mcontext, $exten, '', new ext_noop_trace('In ccmacro with: ${CC_INTERFACES} Header: ${CC_HEADER} Callback: ${CC_EXTEN}'));
            $ext->add($mcontext, $exten, '', new ext_set('CALLERID(dnid)', '${CC_EXTEN}'));
            // TODO: this is technically a bug fix
            $ext->add($mcontext, $exten, '', new ext_set('CALLERID(name)', $cpp . '${CALLERID(name)}'));
            if ($amp_conf['CC_FORCE_DEFAULTS'] && $amp_conf['CC_MONITOR_ALERT_INFO_DEFAULT']) {
                $ext->add($mcontext, $exten, '', new ext_alertinfo($amp_conf['CC_MONITOR_ALERT_INFO_DEFAULT']));
            } elseif (!$amp_conf['CC_FORCE_DEFAULTS']) {
                $ext->add($mcontext, $exten, '', new ext_execif('$[!${LEN(${DB(AMPUSER/${AMPUSER}/ccss/cc_monitor_alert_info)})}]', 'MacroExit'));
                $ext->add($mcontext, $exten, '', new ext_alertinfo('${DB(AMPUSER/${CC_EXTEN}/ccss/cc_monitor_alert_info)}'));
            }
            $ext->add($mcontext, $exten, '', new ext_macroexit(''));
            $context = 'from-ccss-internal';
            $exten = '_X._X.';
            $ext->add($context, $exten, '', new ext_gosub(1, 's', 'sub-from-ccss', '${CUT(EXTEN,_,2)}'));
            $ext->add($context, $exten, 'no_alert', new ext_goto('1', '${CUT(EXTEN,_,1)}', 'from-internal'));
            $context = 'from-ccss-extension';
            $exten = '_X._X.';
            $ext->add($context, $exten, '', new ext_gosub(1, 's', 'sub-from-ccss', '${CUT(EXTEN,_,2)}'));
            $ext->add($context, $exten, '', new ext_goto('1', '${CUT(EXTEN,_,1)}', 'ext-local'));
            $mcontext = 'sub-from-ccss';
            $exten = 's';
            $cpp = $amp_conf['CC_FORCE_DEFAULTS'] ? $amp_conf['CC_AGENT_CID_PREPEND_DEFAULT'] : '${DB(AMPUSER/${AMPUSER}/ccss/cc_agent_cid_prepend)}';
            $ext->add($mcontext, $exten, '', new ext_macro('blkvm-set'));
            $ext->add($mcontext, $exten, '', new ext_set('__CC_RECALL', '1'));
            $ext->add($mcontext, $exten, '', new ext_set('CALLERID(name)', '${IF($[${LEN(${DB(AMPUSER/${ARG1}/cidname)})}]?' . $cpp . '${DB(AMPUSER/${ARG1}/cidname)}:CALLBACK)}'));
            //TODO: Make this configurable
            $ext->add($mcontext, $exten, '', new ext_set('CALLERID(number)', '${ARG1}'));
            $ext->add($mcontext, $exten, '', new ext_noop_trace('CID INFO: ${CALLERID(name)} ${CALLERID(num)} EXTEN: ${ARG1}', 5));
            if ($amp_conf['CC_FORCE_DEFAULTS'] && $amp_conf['CC_AGENT_ALERT_INFO_DEFAULT']) {
                $ext->add($mcontext, $exten, '', new ext_set('__CC_HEADER', $amp_conf['CC_AGENT_ALERT_INFO_DEFAULT']));
            } elseif ($amp_conf['CC_FORCE_DEFAULTS']) {
                $ext->add($mcontext, $exten, '', new ext_return(''));
            } else {
                $ext->add($mcontext, $exten, '', new ext_execif('$[!${LEN(${DB(AMPUSER/${AMPUSER}/ccss/cc_agent_alert_info)})}]', 'Return'));
                $ext->add($mcontext, $exten, '', new ext_set('__CC_HEADER', '${DB(AMPUSER/${AMPUSER}/ccss/cc_agent_alert_info)}'));
            }
            $ext->add($mcontext, $exten, '', new ext_alertinfo('${CC_HEADER}'));
            $ext->add($mcontext, $exten, '', new ext_return(''));
            break;
    }
}