Here is a quick fix for anyone wanting to test a solution that will block transferring when a party dials externally into the system. You can leave your defaults as is in “Advanced Settings”. This just removes the “T” option when a call is processed through any inbound route
diff --git a/agi-bin/dialparties.agi b/agi-bin/dialparties.agi
index 38782fd..6d9341b 100644
--- a/agi-bin/dialparties.agi
+++ b/agi-bin/dialparties.agi
@@ -705,6 +705,9 @@ if (!strlen($ds)) {
$ds .= $timer;
}
$ds .= $ds_seperator . $dialopts; // pound to transfer, provide ringing
+ $dir = get_var( $AGI, "DIRECTION" );
+ //dont allow inbound callers to transfer around inside the system
+ $ds = ($dir == "INBOUND") ? str_replace("T","",$ds) : $ds;
$AGI->set_variable('ds',$ds);
$AGI->set_variable("HuntMembers",$loops);
$AGI->set_priority("huntdial"); // dial command was at priority 20 where dialplan handles calling a ringgroup with strategy of "hunt" or "MemoryHunt"
@@ -728,6 +731,9 @@ if (!strlen($ds)) {
$AGI->set_variable('__CALLCONFIRMCID',"999");
}
}
+ $dir = get_var( $AGI, "DIRECTION" );
+ //dont allow inbound callers to transfer around inside the system
+ $ds = ($dir == "INBOUND") ? str_replace("T","",$ds) : $ds;
$AGI->set_variable('ds',$ds);
$AGI->set_priority("normdial"); // dial command was at priority 10
}
diff --git a/functions.inc.php b/functions.inc.php
index 13a3872..1db5f27 100644
--- a/functions.inc.php
+++ b/functions.inc.php
@@ -1227,6 +1227,8 @@ function core_do_get_config($engine) {
$ext->addInclude('from-internal-additional', $context); // Add the include from from-internal
$exten = '_LC-.';
$ext->add($context, $exten, '', new ext_noop_trace('IN '.$context.' with - RT: ${RT}, RG_IDX: ${RG_IDX}'));
+ //dont allow inbound callers to transfer around inside the system
+ $ext->add($context, $exten, '', new ext_execif('$["${DIRECTION}" = "INBOUND"]', 'Set', 'DIAL_OPTIONS=${STRREPLACE(DIAL_OPTIONS,T)}I'));
$ext->add($context, $exten, '', new ext_dial('${DB(DEVICE/${EXTEN:3}/dial)}', '${RT},${DIAL_OPTIONS}M(auto-confirm^${RG_IDX})b(func-apply-sipheaders^s^1)'));
/* This needs to be before outbound-routes since they can have a wild-card in them
@@ -1507,6 +1509,7 @@ function core_do_get_config($engine) {
$exten = (($exten == "")?"s":$exten);
$exten = $exten.(($cidnum == "")?"":"/".$cidnum); //if a CID num is defined, add it
+ $ext->add($context, $exten, '', new ext_setvar('__DIRECTION','INBOUND'));
if ($cidroute) {
$ext->add($context, $exten, '', new ext_setvar('__FROM_DID','${EXTEN}'));
$ext->add($context, $exten, '', new ext_goto('1','s'));
diff --git a/functions.inc/macro-dial-one.php b/functions.inc/macro-dial-one.php
index 3a716d3..85912f9 100644
--- a/functions.inc/macro-dial-one.php
+++ b/functions.inc/macro-dial-one.php
@@ -90,6 +90,9 @@ if ($amp_conf['AST_FUNC_CONNECTEDLINE']) {
//Purpose is to have the option to add sip-headers as with the trunk pre dial out hook.
//We need to have this as we have mobile extensions connected directly to the pbx as sip extensions.
$ext->add($mcontext,$exten,'godial', new ext_macro('dialout-one-predial-hook'));
+
+//dont allow inbound callers to transfer around inside the system
+$ext->add($mcontext,$exten,'', new ext_execif('$["${DIRECTION}" = "INBOUND"]', 'Set', 'D_OPTIONS=${STRREPLACE(D_OPTIONS,T)}I'));
$ext->add($mcontext,$exten,'', new ext_dial('${DSTRING}', '${ARG1},${D_OPTIONS}b(func-apply-sipheaders^s^1)'));
$ext->add($mcontext,$exten,'', new ext_execif('$["${DIALSTATUS}"="ANSWER" & "${CALLER_DEST}"!=""]', 'MacroExit'));