Restrict Call Forward settings to current extension

I don’t like the way that a user can set call forward information for other users on the system. A rogue user could redirect someone else’s calls to his/her extension. I also didn’t like having two access codes to enable and disable call forward data. To “fix” this I disabled all call forward feature codes except for *52, *72, and *90 and placed the following in my extensions_custom.conf. These contexts in _custom are caught first in the dialplan before the built-in call forward contexts. Dial the code once and you will be prompted for the extension to forward to. Dial the code again and the forward is deactivated.

[from-internal-custom]
include => custom-CALLFORWARD

[custom-CALLFORWARD]
;callforward-busy
exten => *90,1,Answer
exten => *90,n,Wait(1)
exten => *90,n,Macro(user-callerid,)
exten => *90,n,Playback(call-fwd-on-busy)
exten => *90,n,Set(CFEXTEN=${DB(CFB/${AMPUSER})})
exten => *90,n,GotoIf($[“foo${CFEXTEN}”=“foo”]?startread)
exten => *90,n,dbDel(CFB/${AMPUSER})
exten => *90,n,Playback(de-activated)
exten => *90,n,Macro(hangupcall,)
exten => *90,n(startread),Playback(ent-target-attendant)
exten => *90,n,Read(CFEXTEN,then-press-pound,)
exten => *90,n,GotoIf($[“foo${CFEXTEN}”=“foo”]?startread)
exten => *90,n,Set(DB(CFB/${AMPUSER})=${CFEXTEN})
exten => *90,n,Playback(call-fwd-on-busy&for&extension)
exten => *90,n,SayDigits(${AMPUSER})
exten => *90,n,Playback(is-set-to)
exten => *90,n,SayDigits(${CFEXTEN})
exten => *90,n,Macro(hangupcall,)

;callforward-all
exten => *72,1,Answer
exten => *72,n,Wait(1)
exten => *72,n,Macro(user-callerid,)
exten => *72,n,Playback(call-fwd-unconditional)
exten => *72,n,Set(CFEXTEN=${DB(CF/${AMPUSER})})
exten => *72,n,GotoIf($[“foo${CFEXTEN}”=“foo”]?startread)
exten => *72,n,dbDel(CF/${AMPUSER})
exten => *72,n,Playback(de-activated)
exten => *72,n,Macro(hangupcall,)
exten => *72,n(startread),Playback(ent-target-attendant)
exten => *72,n,Read(CFEXTEN,then-press-pound,)
exten => *72,n,GotoIf($[“foo${CFEXTEN}”=“foo”]?startread)
exten => *72,n,Set(DB(CF/${AMPUSER})=${CFEXTEN})
exten => *72,n,Playback(call-fwd-unconditional&for&extension)
exten => *72,n,SayDigits(${AMPUSER})
exten => *72,n,Playback(is-set-to)
exten => *72,n,SayDigits(${CFEXTEN})
exten => *72,n,Macro(hangupcall,)

;callforward-no-answer
exten => *52,1,Answer
exten => *52,n,Wait(1)
exten => *52,n,Macro(user-callerid,)
exten => *52,n,Playback(call-fwd-no-ans)
exten => *52,n,Set(CFEXTEN=${DB(CFU/${AMPUSER})})
exten => *52,n,GotoIf($[“foo${CFEXTEN}”=“foo”]?startread)
exten => *52,n,dbDel(CFU/${AMPUSER})
exten => *52,n,Playback(de-activated)
exten => *52,n,Macro(hangupcall,)
exten => *52,n(startread),Playback(ent-target-attendant)
exten => *52,n,Read(CFEXTEN,then-press-pound,)
exten => *52,n,GotoIf($[“foo${CFEXTEN}”=“foo”]?startread)
exten => *52,n,Set(DB(CFU/${AMPUSER})=${CFEXTEN})
exten => *52,n,Playback(call-fwd-no-ans&for&extension)
exten => *52,n,SayDigits(${AMPUSER})
exten => *52,n,Playback(is-set-to)
exten => *52,n,SayDigits(${CFEXTEN})
exten => *52,n,Macro(hangupcall,)

i disabled call-forward in our freepbx system. because it’s crazy if you can forward other people’s phone to else where without permission. i think your method is really good. i will try it. hope the freepbx team would consider it also.

As Philippe would say “thanks and I hate to ask you to post twice but… If this is a bug/issue, can you please open a ticket on the ticket system describing the issue and including this fix. Otherwise, it will simply get lost again - there is too much to keep track of and that is what we rely on to do it. Thanks!”

Agree your fixes are worth it and they can roll it out in the release easly.