Hi,
Below is the custom lock code you need to copy into your extensions_custom.conf file. You need to change the context on the extension to be ‘custom-checklock’ so it will check if the extension is locked when trying to dial. The prompt on the phone is currently a simple ‘Password?’ and when you lock an extension you just get ‘Goodbye’. You can change the prompts used to anything you want, including recording your own.
Set the VALIDPIN entry to be the PIN code you want to use and set the 911 emergency bypass (thanks fskrotzki) to whatever the emergency number is in your country.
Finally, set the feature code you want to use for locking the phone to point to ‘custom-setlock,s,1’.
It works by checking a database entry, and if it exists it asks for the PIN (don’t forget to press # after the PIN number). You get three attempts to enter the pin then it hangs up. If you get the PIN right, it deletes the database entry and carries on with the code so next time you dial you just get straight out. Dialling the feature code will add the database entry back in and lock the extension.
That should be it. I have done some testing on an Asterisk V1.4/FreePBX V2.5 system but, as it is free, no warranties expressed or implied etc. etc.
Graham
[custom-checklock]
exten => _.,1,NoOp(AMPUSER/${CALLERID(num)}/locked)
exten => _.,n,Gotoif($[${DB_EXISTS(AMPUSER/${CALLERID(num)}/locked)}=0]?carryon)
exten => _.,n,Set(PINCOUNT=0)
exten => _.,n,Set(VALIDPIN=1234)
exten => _.,n(readpin),Read(PIN,vm-password,)
exten => _.,n,Gotoif($[${PIN}=${VALIDPIN}]?carryon)
exten => _.,n,Set(PINCOUNT=$[${PINCOUNT}+1])
exten => _.,n,Playback(vm-incorrect)
exten => _.,n,GotoIf($[${PINCOUNT}>3]?h)
exten => _.,n,Wait(1)
exten => _.,n,Goto(readpin)
exten => _.,n(carryon),NoOp(${DB_DELETE(AMPUSER/${CALLERID(num)}/locked)})
exten => _.,n,Goto(from-internal,${EXTEN},1)
exten => h,1,Hangup
exten => 911,1,Goto(from-internal,${EXTEN},1)
[custom-setlock]
exten => s,1,NoOp(In Set Lock)
exten => s,n,Set(DB(AMPUSER/${CALLERID(num)}/locked)=1)
exten => s,n,Playback(vm-goodbye)
exten => s,n,Hangup