Index: /freepbx/branches/2.2/amp_conf/astetc/extensions.conf =================================================================== --- /freepbx/branches/2.2/amp_conf/astetc/extensions.conf (revision 3371) +++ /freepbx/branches/2.2/amp_conf/astetc/extensions.conf (revision 3400) @@ -93,10 +93,4 @@ exten => s,1,Macro(user-callerid) -; Don't go to destinations like vm if NODEST is set -; -exten => s,n,Noop(CAME FROM: ${NODEST}) -exten => s,n,Set(RRNODEST=${NODEST}) -exten => s,n,Set(_NODEST=) - exten => s,n,Set(FROMCONTEXT=exten-vm) exten => s,n,Set(VMBOX=${ARG1}) @@ -106,10 +100,4 @@ exten => s,n,Macro(record-enable,${EXTTOCALL},IN) - -; If NODEST then bypass voicemail regardless -; -;exten => s,n,GotoIf($["${CHANNEL:0:5}" = "Local"]?dolocaldial,1) ; if the channel is Local -exten => s,n,GotoIf($["foo${RRNODEST}" != "foo"]?dolocaldial,1) ; don't do voicemail - exten => s,n,Macro(dial,${RT},${DIAL_OPTIONS},${EXTTOCALL}) exten => s,n,GosubIf($[$["${DIALSTATUS}"="NOANSWER"] & $["foo${CFUEXT}"!="foo"]]?docfu,1) ; check for CFU in use on no answer @@ -119,10 +107,4 @@ exten => s,n,Macro(vm,${VMBOX},${DIALSTATUS}) -; Local channel should try to ring the phone only then come back out -; i.e. it's wrong for it to Answer the call in any way (including Congestion -; and stop the initiating dialplan from being returned to) -exten => dolocaldial,1,Macro(dial,,${DIAL_OPTIONS},${EXTTOCALL}) -exten => dolocaldial,n,NoOp(Returned to dolocaldial with DIALSTATUS '${DIALSTATUS}') - ; Try the Call Forward on No Answer / Unavailable number exten => docfu,1,Set(RTCFU=${IF($["${VMBOX}"!="novm"]?${RINGTIMER}:"")}) @@ -142,5 +124,14 @@ exten => s,1,Macro(user-callerid,SKIPTTL) exten => s,n,Set(VMGAIN=${IF($["foo${VM_GAIN}"!="foo"]?"g(${VM_GAIN})":"")}) -exten => s,n,Goto(s-${ARG2},1) +; +; If BLKVM_OVERRIDE is set, then someone told us to block calls from going to +; voicemail. This variable is reset by the answering channel so subsequent +; transfers will properly function. +; +exten => s,n,GotoIf($["foo${DB(${BLKVM_OVERRIDE})}" != "fooTRUE"]?s-${ARG2},1) +; +; we didn't branch so block this from voicemail +; +exten => s,n,Noop(CAME FROM: ${NODEST} - Blocking VM cause of key: ${DB(BLKVM_OVERRIDE)}) exten => s-BUSY,1,NoOp(BUSY voicemail) @@ -203,12 +194,12 @@ ; and this macro has to masquerade as exten-vm. ; -exten => s,n,Set(FROMCONTEXT=exten-vm) ; exten => s,n,Set(EXTTOCALL=${ARG1}) exten => s,n,Set(RT=${ARG2}) exten => s,n,Set(CFUEXT=${DB(CFU/${EXTTOCALL})}) exten => s,n,Macro(record-enable,${EXTTOCALL},IN) -exten => s,n,GotoIf($["${CHANNEL:0:5}" = "Local"]?dolocaldial,1) ; if the channel is Local exten => s,n,Macro(dial,${RT},${DIAL_OPTIONS},${EXTTOCALL}) + +exten => s,n,Set(PR_DIALSTATUS=${DIALSTATUS}) ; if we return, thus no answer, and they have a CFU setting, then we try that next @@ -219,16 +210,5 @@ ; return situations, this is left in. ; -exten => s,n,Set(PR_DIALSTATUS=${DIALSTATUS}) exten => s,n,Goto(s-${DIALSTATUS},1) - -; Local channel should try to ring the phone only then come back out -; i.e. it's wrong for it to Answer the call in any way (including Congestion -; and stop the initiating dialplan from being returned to) -; -; NOTE: this had no RT set, I think in our case it should have RT set so we will give it -; a try here and see how it goes. -; -exten => dolocaldial,1,Macro(dial,${RT},${DIAL_OPTIONS},${EXTTOCALL}) -exten => dolocaldial,n,NoOp(Returned to dolocaldial with DIALSTATUS '${DIALSTATUS}') ; Try the Call Forward on No Answer / Unavailable number. @@ -299,9 +279,16 @@ exten => s,n,NoCDR() -; Cleanup any remaining RG flags -; -exten => s,n,GotoIf($["foo${USE_CONFIRMATION}" = "foo" | "foo${RINGGROUP_INDEX}" = "foo" | "${CHANNEL}" != "${UNIQCHAN}"]?theend) +; Cleanup any remaining RG flag +; +exten => s,n,GotoIf($[ "foo${USE_CONFIRMATION}" = "foo" | "foo${RINGGROUP_INDEX}" = "foo" | "${CHANNEL}" != "${UNIQCHAN}"]?skiprg) exten => s,n,Noop(Cleaning Up Confirmation Flag: RG/${RINGGROUP_INDEX}/${CHANNEL}) exten => s,n,DBDel(RG/${RINGGROUP_INDEX}/${CHANNEL}) + +; Cleanup any remaining BLKVM flag +; +exten => s,n(skiprg),GotoIf($[ "foo${BLKVM_BASE}" = "foo" | "BLKVM/${BLKVM_BASE}/${CHANNEL}" != "${BLKVM_OVERRIDE}" ]?theend) +exten => s,n,Noop(Cleaning Up Block VM Flag: ${BLKVM_OVERRIDE}) +exten => s,n,DBDel(${BLKVM_OVERRIDE}) + exten => s,n(theend),Wait(5) exten => s,n,Hangup @@ -700,5 +687,6 @@ ;sets the callerid of the device to that of the logged in user [macro-user-callerid] -exten => s,1,GotoIf($["${CHANNEL:0:5}" = "Local"]?report) +exten => s,1,Noop(user-callerid: ${CALLERID(name)} ${CALLERID(number)}) +exten => s,n,GotoIf($["${CHANNEL:0:5}" = "Local"]?report) exten => s,n,GotoIf($["${REALCALLERIDNUM:1:2}" != ""]?start) exten => s,n,Set(REALCALLERIDNUM=${CALLERID(number)}) @@ -827,4 +815,5 @@ ; include => from-internal-additional +include => ext-local-confirm ; This causes grief with '#' transfers, commenting out for the moment. ; include => bad-number @@ -915,5 +904,7 @@ exten => s,n,Set(RINGGROUP_INDEX=${ARG4}) exten => s,n,Set(ARG4=) ; otherwise it gets passed to dialparties.agi which processes it (prob bug) + exten => s,n,Macro(dial,${ARG1},${ARG2},${ARG3}) + exten => s,n,Set(USE_CONFIRMATION=) exten => s,n,Set(RINGGROUP_INDEX=) @@ -933,6 +924,18 @@ [macro-auto-confirm] exten => s,1,Set(__MACRO_RESULT=) +exten => s,n,DBDel(${BLKVM_OVERRIDE}) exten => s,n,DBDel(RG/${ARG1}/${UNIQCHAN}) -exten => s,n(fin),NoOp(Finished) + +;------------------------------------------------------------------------ +; [macro-auto-blkvm] +;------------------------------------------------------------------------ +; This macro is called for any extension dialed form a queue, ringgroup +; or followme, so that the answering extension can clear the voicemail block +; override allow subsequent transfers to properly operate. +; +;------------------------------------------------------------------------ +[macro-auto-blkvm] +exten => s,1,Set(__MACRO_RESULT=) +exten => s,n,DBDel(${BLKVM_OVERRIDE}) ;------------------------------------------------------------------------ @@ -948,8 +951,6 @@ ;------------------------------------------------------------------------ [ext-local-confirm] -exten => _X.,1,Noop(IN ext-local-confirm with - RT: ${RT}, RG_IDX: ${RG_IDX}) -exten => _X.,n,dial(${DB(DEVICE/${EXTEN}/dial)},${RT},M(auto-confirm^${RG_IDX})${DIAL_OPTIONS}) -exten => _X.,n,Macro(hangupcall) -exten => h,n,Macro(hangupcall) +exten => _LC-.,1,Noop(IN ext-local-confirm with - RT: ${RT}, RG_IDX: ${RG_IDX}) +exten => _LC-.,n,dial(${DB(DEVICE/${EXTEN:3}/dial)},${RT},M(auto-confirm^${RG_IDX})${DIAL_OPTIONS}) ;------------------------------------------------------------------------ @@ -1018,4 +1019,5 @@ ; MACRO_RESULT variable to NOTHING. This is the magic string that joins both legs of the call together exten => s,n(ok),DBDel(RG/${ARG3}/${UNIQCHAN}) +exten => s,n,DBDel(${BLKVM_OVERRIDE}) exten => s,n,Set(__MACRO_RESULT=) Index: /freepbx/branches/2.2/amp_conf/agi-bin/dialparties.agi =================================================================== --- /freepbx/branches/2.2/amp_conf/agi-bin/dialparties.agi (revision 3316) +++ /freepbx/branches/2.2/amp_conf/agi-bin/dialparties.agi (revision 3400) @@ -60,4 +60,7 @@ $pr_dialstatus = get_var( $AGI, "PR_DIALSTATUS" ); +$nodest = get_var( $AGI, "NODEST" ); +if (empty($nodest)) $nodest = ''; + $use_confirmation = get_var( $AGI, "USE_CONFIRMATION" ); $ringgroup_index = get_var( $AGI, "RINGGROUP_INDEX" ); @@ -178,5 +181,4 @@ $dndprimary = 1; debug("Primary extension is DND, so if mastermode, all should be dnd", 4); - } } @@ -238,6 +240,6 @@ { $mastermode = 0; - $extstate = is_ext_avail($extnum); - debug("Extension $extnum has ExtensionState: $extstate",1); + $extstate = is_ext_avail($extnum); + debug("Extension $extnum has ExtensionState: $extstate",1); if ( ($exthascw == 1) && ($extstate == 1) ) @@ -246,5 +248,5 @@ // the extension is occupied. This will try this extension but not the others. $skipremaining = 1; - debug("In mastermode with cw enabled so $extnum will be tried and others skipped",4); + debug("In mastermode with cw enabled so $extnum will be tried and others skipped",4); } elseif ( ($exthascw == 0) && ($extstate == 1) ) @@ -253,5 +255,5 @@ // ignored as normal behavior. In either case, we skip the remaining numbers. $skipremaining = 1; - debug("In mastermode with cw disabled so $extnum will be processed in case cfb set",4); + debug("In mastermode with cw disabled so $extnum will be processed in case cfb set",4); } // All other cases should act like normal. Unavailable, not busy, ringing, etc. @@ -275,5 +277,5 @@ // get ExtensionState: 0-idle; 1-busy; 4-unavail; 8-ringing <--- these are unconfirmed $extstate = is_ext_avail($extnum); - debug("Extension $extnum has ExtensionState: $extstate",1); + debug("Extension $extnum has ExtensionState: $extstate",1); if ( ($exthascfu == 1) && ($extstate == 4) ) // Ext has CFU and is Unavailable @@ -284,5 +286,5 @@ { debug("Extension $extnum has call forward on no answer set and is unavailable and is part of a Ring Group forwarding to '$extcfu'",1); - $extnum = $extcfu . '#'; # same method as the normal cf, i.e. send to Local + $extnum = $extcfu . '#'; # same method as the normal cf, i.e. send to Local } else @@ -347,6 +349,5 @@ if ((strpos($k,"#")==0) && (($rgmethod != "hunt") && ($rgmethod != "memoryhunt")) ) { - if ( isset($cidnum) && is_numeric($cidnum) ) - + if ( isset($cidnum) && is_numeric($cidnum) ) { $rc = $AGI->database_put('CALLTRACE', $k, $cidnum); @@ -408,4 +409,15 @@ $ds = chop($ds," &"); +if ($nodest != '' && $use_confirmation == 'FALSE') { + if (strpos($dialopts,"M(auto-blkvm)") > 0 || strpos($dialopts,"M(auto-blkvm)") === 0 || + strpos($dialopts,"M(auto-confirm") > 0 || strpos($dialopts,"M(auto-confirm") === 0 || + strpos($dialopts,"M(confirm") > 0 || strpos($dialopts,"M(confirm") === 0) { + debug("NODEST: $nodest blkvm enabled macro already in dialopts: $dialopts",4); + } else { + $dialopts .= "M(auto-blkvm)"; + debug("NODEST: $nodest adding M(auto-blkvm) to dialopts: $dialopts",4); + } +} + if (!strlen($ds)) { @@ -435,7 +447,7 @@ $AGI->set_variable('__RG_IDX',$ringgroup_index); if ( isset($cidnum) && is_numeric($cidnum) ) { - $AGI->set_variable('__CALLCONFIRMCID',$cidnum); + $AGI->set_variable('__CALLCONFIRMCID',$cidnum); } else { - $AGI->set_variable('__CALLCONFIRMCID',"999"); + $AGI->set_variable('__CALLCONFIRMCID',"999"); } $AGI->set_variable('ds',$ds); @@ -478,5 +490,5 @@ $dialstring = 'Local/'.$extnum.'@from-internal/n'; else - $dialstring = 'Local/RG-'.$ringgroup_index.'-'.$extnum.'#@grps'; + $dialstring = 'Local/RG-'.$ringgroup_index.'-'.$extnum.'#@from-internal'; debug("Built External dialstring component for $extnum: $dialstring", 4); } @@ -497,5 +509,5 @@ $dialstring .= '&'; } else { - $dialstring .= 'Local/'.$adevice.'@ext-local-confirm&'; + $dialstring .= 'Local/LC-'.$adevice.'@from-internal&'; } }