From 3da6221b3e0bcf340adf979c09b5679aa2f013d0 Mon Sep 17 00:00:00 2001 From: mattf Date: Sat, 14 Feb 2009 09:50:43 +0000 Subject: [PATCH] Added default DID option to DID routing process made trunkinbound inbound context consistent throughout git-svn-id: svn://192.168.202.10@1058 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/agi/agi-DID_route.agi | 34 +++++++++++++++++-- .../docs/conf_examples/extensions.conf.sample | 2 +- .../conf_examples/extensions.conf.sample-1.4 | 2 +- .../trunk/docs/conf_examples/iax.conf.sample | 2 +- .../docs/conf_examples/iax.conf.sample-1.4 | 2 +- .../trunk/extras/MySQL_AST_CREATE_tables.sql | 8 +++-- agc_2-X/trunk/extras/upgrade_2.0.5.sql | 7 ++-- .../TO_BE_TRANSLATED_2.0.5.txt | 2 ++ agc_2-X/trunk/www/vicidial/admin.php | 4 +-- 9 files changed, 49 insertions(+), 14 deletions(-) diff --git a/agc_2-X/trunk/agi/agi-DID_route.agi b/agc_2-X/trunk/agi/agi-DID_route.agi index 70a24ed8..94f37a7f 100644 --- a/agc_2-X/trunk/agi/agi-DID_route.agi +++ b/agc_2-X/trunk/agi/agi-DID_route.agi @@ -16,6 +16,7 @@ # 81007-0324 - First Build # 90115-0645 - Activated AGENT call routing # 90117-0756 - Added vicidial_did_log logging to database +# 90214-0217 - Added 'default' did option, to send all non-matching calls to, enforced did_active setting # $script = 'agi-DID_route.agi'; @@ -150,7 +151,7 @@ if ( (!$callerid) or ($callerid =~ /unknown/) ) ### Grab DID values from the database -$stmtA = "SELECT did_id,did_pattern,did_description,did_active,did_route,extension,exten_context,voicemail_ext,phone,server_ip,user,user_unavailable_action,user_route_settings_ingroup FROM vicidial_inbound_dids where did_pattern = '$extension';"; +$stmtA = "SELECT did_id,did_pattern,did_description,did_active,did_route,extension,exten_context,voicemail_ext,phone,server_ip,user,user_unavailable_action,user_route_settings_ingroup FROM vicidial_inbound_dids where did_pattern = '$extension' and did_active='Y';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -182,8 +183,35 @@ if ($AGILOG) {$did_string = "$SQLdate|$uniqueid|$channel|$extension|$callerid|$c if ($sthArows < 1) { - ### nothing found, so exit script - exit; + ### Grab DID values from the database for a default DID pattern if there is one + $stmtA = "SELECT did_id,did_pattern,did_description,did_active,did_route,extension,exten_context,voicemail_ext,phone,server_ip,user,user_unavailable_action,user_route_settings_ingroup FROM vicidial_inbound_dids where did_pattern = 'default' and did_active='Y';"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows=$sthA->rows; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $did_id = $aryA[0]; + $did_pattern = $aryA[1]; + $did_description = $aryA[2]; + $did_active = $aryA[3]; + $did_route = $aryA[4]; + $did_extension = $aryA[5]; + $exten_context = $aryA[6]; + $voicemail_ext = $aryA[7]; + $phone = $aryA[8]; + $did_server_ip = $aryA[9]; + $user = $aryA[10]; + $user_unavailable_action = $aryA[11]; + $user_route_settings_ingroup = $aryA[12]; + } + $sthA->finish(); + + if ($sthArows < 1) + { + ### if nothing found, exit script + exit; + } } ### Grab Server values from the database diff --git a/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample b/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample index 39429724..f24b693c 100644 --- a/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample +++ b/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample @@ -15,7 +15,7 @@ SIPtrunk=SIP/1234:PASSWORD@sip.provider.net ; SIP trunk TRUNKloop = IAX2/ASTloop:test@127.0.0.1:40569 ; used for blind monitoring TRUNKblind = IAX2/ASTblind:test@127.0.0.1:41569 ; used for testing -[testtrunkinbound] +[trunkinbound] ; agent dial-in: exten => 2345,1,Answer ; Answer the line exten => 2345,2,AGI(agi-AGENT_dial_in.agi) diff --git a/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-1.4 b/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-1.4 index f321a8cd..9e532346 100644 --- a/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-1.4 +++ b/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-1.4 @@ -15,7 +15,7 @@ SIPtrunk=SIP/1234:PASSWORD@sip.provider.net ; SIP trunk TRUNKloop = IAX2/ASTloop:test@127.0.0.1:40569 ; used for blind monitoring TRUNKblind = IAX2/ASTblind:test@127.0.0.1:41569 ; used for testing -[testtrunkinbound] +[trunkinbound] ; agent dial-in: exten => 2345,1,Answer ; Answer the line exten => 2345,2,AGI(agi-AGENT_dial_in.agi) diff --git a/agc_2-X/trunk/docs/conf_examples/iax.conf.sample b/agc_2-X/trunk/docs/conf_examples/iax.conf.sample index 3ff22852..d734cfb3 100644 --- a/agc_2-X/trunk/docs/conf_examples/iax.conf.sample +++ b/agc_2-X/trunk/docs/conf_examples/iax.conf.sample @@ -54,4 +54,4 @@ type=friend username=1112223333 secret=PASSWORD host=iax.binfone.com -context=incoming-IAX-context-in-extensions.conf +context=trunkinbound diff --git a/agc_2-X/trunk/docs/conf_examples/iax.conf.sample-1.4 b/agc_2-X/trunk/docs/conf_examples/iax.conf.sample-1.4 index 1382c77e..6d5440fb 100644 --- a/agc_2-X/trunk/docs/conf_examples/iax.conf.sample-1.4 +++ b/agc_2-X/trunk/docs/conf_examples/iax.conf.sample-1.4 @@ -85,4 +85,4 @@ type=friend username=1112223333 secret=PASSWORD host=iax.binfone.com -context=incoming-IAX-context-in-extensions.conf +context=trunkinbound diff --git a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql index 2dfebd8d..49a7b470 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -1466,8 +1466,10 @@ INSERT INTO vicidial_conf_templates SET template_id='SIP_generic',template_name= INSERT INTO vicidial_conf_templates SET template_id='IAX_generic',template_name='IAX phone generic',template_contents="type=friend\nhost=dynamic\nmaxauthreq=10\nauth=md5,plaintext,rsa\ncontext=default"; INSERT INTO vicidial_server_carriers SET carrier_id='PARAXIP', carrier_name='TEST ParaXip CPD example',registration_string='', template_id='--NONE--', account_entry="[paraxip]\ndisallow=all\nallow=ulaw\ntype=peer\nusername=paraxip\nfromuser=paraxip\nsecret=test\nfromdomain=10.10.10.16\nhost=10.10.10.15\ninsecure=port,invite\noutboundproxy=10.0.0.7", protocol='SIP', globals_string='TESTSIPTRUNKP = SIP/paraxip', dialplan_entry="exten => _5591999NXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)\nexten => _5591999NXXXXXX,2,Dial(${TESTSIPTRUNKP}/${EXTEN:4},,tTor)\nexten => _5591999NXXXXXX,3,Hangup", server_ip='10.10.10.15', active='N'; -INSERT INTO vicidial_server_carriers SET carrier_id='SIPEXAMPLE', carrier_name='TEST SIP carrier example',registration_string='register => testcarrier:test@10.10.10.15:5060', template_id='--NONE--', account_entry="[testcarrier]\ndisallow=all\nallow=ulaw\ntype=friend\nusername=testcarrier\nsecret=test\nhost=dynamic\ndtmfmode=rfc2833\n", protocol='SIP', globals_string='TESTSIPTRUNK = SIP/testcarrier', dialplan_entry="exten => _91999NXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)\nexten => _91999NXXXXXX,2,Dial(${TESTSIPTRUNK}/${EXTEN:2},,tTor)\nexten => _91999NXXXXXX,3,Hangup\n", server_ip='10.10.10.15', active='N'; -INSERT INTO vicidial_server_carriers SET carrier_id='IAXEXAMPLE', carrier_name='TEST IAX carrier example',registration_string='register => testcarrier:test@10.10.10.15:4569', template_id='--NONE--', account_entry="[testcarrier]\ndisallow=all\nallow=ulaw\ntype=friend\naccountcode=testcarrier\nsecret=test\nhost=dynamic\n", protocol='IAX2', globals_string='TESTIAXTRUNK = IAX2/testcarrier', dialplan_entry="exten => _71999NXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)\nexten => _71999NXXXXXX,2,Dial(${TESTIAXTRUNK}/${EXTEN:2},,tTor)\nexten => _71999NXXXXXX,3,Hangup\n", server_ip='10.10.10.15', active='N'; +INSERT INTO vicidial_server_carriers SET carrier_id='SIPEXAMPLE', carrier_name='TEST SIP carrier example',registration_string='register => testcarrier:test@10.10.10.15:5060', template_id='--NONE--', account_entry="[testcarrier]\ndisallow=all\nallow=ulaw\ntype=friend\nusername=testcarrier\nsecret=test\nhost=dynamic\ndtmfmode=rfc2833\ncontext=trunkinbound\n", protocol='SIP', globals_string='TESTSIPTRUNK = SIP/testcarrier', dialplan_entry="exten => _91999NXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)\nexten => _91999NXXXXXX,2,Dial(${TESTSIPTRUNK}/${EXTEN:2},,tTor)\nexten => _91999NXXXXXX,3,Hangup\n", server_ip='10.10.10.15', active='N'; +INSERT INTO vicidial_server_carriers SET carrier_id='IAXEXAMPLE', carrier_name='TEST IAX carrier example',registration_string='register => testcarrier:test@10.10.10.15:4569', template_id='--NONE--', account_entry="[testcarrier]\ndisallow=all\nallow=ulaw\ntype=friend\naccountcode=testcarrier\nsecret=test\nhost=dynamic\ncontext=trunkinbound\n", protocol='IAX2', globals_string='TESTIAXTRUNK = IAX2/testcarrier', dialplan_entry="exten => _71999NXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)\nexten => _71999NXXXXXX,2,Dial(${TESTIAXTRUNK}/${EXTEN:2},,tTor)\nexten => _71999NXXXXXX,3,Hangup\n", server_ip='10.10.10.15', active='N'; + +INSERT INTO vicidial_inbound_dids SET did_pattern='default', did_description='Default DID', did_active='Y', did_route='EXTEN', extension='9998811112', exten_context='default'; UPDATE system_settings SET qc_last_pull_time=NOW(); @@ -1489,7 +1491,7 @@ CREATE INDEX phone_number on vicidial_closer_log (phone_number); CREATE INDEX date_user on vicidial_closer_log (call_date,user); CREATE INDEX comment_a on live_inbound_log (comment_a); -UPDATE system_settings SET db_schema_version='1130'; +UPDATE system_settings SET db_schema_version='1131'; GRANT RELOAD ON *.* TO cron@'%'; GRANT RELOAD ON *.* TO cron@localhost; diff --git a/agc_2-X/trunk/extras/upgrade_2.0.5.sql b/agc_2-X/trunk/extras/upgrade_2.0.5.sql index 03a6c1ab..f5a7b726 100644 --- a/agc_2-X/trunk/extras/upgrade_2.0.5.sql +++ b/agc_2-X/trunk/extras/upgrade_2.0.5.sql @@ -720,8 +720,11 @@ INSERT INTO vicidial_conf_templates SET template_id='SIP_generic',template_name= INSERT INTO vicidial_conf_templates SET template_id='IAX_generic',template_name='IAX phone generic',template_contents="type=friend\nhost=dynamic\nmaxauthreq=10\nauth=md5,plaintext,rsa\ncontext=default"; INSERT INTO vicidial_server_carriers SET carrier_id='PARAXIP', carrier_name='TEST ParaXip CPD example',registration_string='', template_id='--NONE--', account_entry="[paraxip]\ndisallow=all\nallow=ulaw\ntype=peer\nusername=paraxip\nfromuser=paraxip\nsecret=test\nfromdomain=10.10.10.16\nhost=10.10.10.15\ninsecure=port,invite\noutboundproxy=10.0.0.7", protocol='SIP', globals_string='TESTSIPTRUNKP = SIP/paraxip', dialplan_entry="exten => _5591999NXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)\nexten => _5591999NXXXXXX,2,Dial(${TESTSIPTRUNKP}/${EXTEN:4},,tTor)\nexten => _5591999NXXXXXX,3,Hangup", server_ip='10.10.10.15', active='N'; -INSERT INTO vicidial_server_carriers SET carrier_id='SIPEXAMPLE', carrier_name='TEST SIP carrier example',registration_string='register => testcarrier:test@10.10.10.15:5060', template_id='--NONE--', account_entry="[testcarrier]\ndisallow=all\nallow=ulaw\ntype=friend\nusername=testcarrier\nsecret=test\nhost=dynamic\ndtmfmode=rfc2833\n", protocol='SIP', globals_string='TESTSIPTRUNK = SIP/testcarrier', dialplan_entry="exten => _91999NXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)\nexten => _91999NXXXXXX,2,Dial(${TESTSIPTRUNK}/${EXTEN:2},,tTor)\nexten => _91999NXXXXXX,3,Hangup\n", server_ip='10.10.10.15', active='N'; -INSERT INTO vicidial_server_carriers SET carrier_id='IAXEXAMPLE', carrier_name='TEST IAX carrier example',registration_string='register => testcarrier:test@10.10.10.15:4569', template_id='--NONE--', account_entry="[testcarrier]\ndisallow=all\nallow=ulaw\ntype=friend\naccountcode=testcarrier\nsecret=test\nhost=dynamic\n", protocol='IAX2', globals_string='TESTIAXTRUNK = IAX2/testcarrier', dialplan_entry="exten => _71999NXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)\nexten => _71999NXXXXXX,2,Dial(${TESTIAXTRUNK}/${EXTEN:2},,tTor)\nexten => _71999NXXXXXX,3,Hangup\n", server_ip='10.10.10.15', active='N'; +INSERT INTO vicidial_server_carriers SET carrier_id='SIPEXAMPLE', carrier_name='TEST SIP carrier example',registration_string='register => testcarrier:test@10.10.10.15:5060', template_id='--NONE--', account_entry="[testcarrier]\ndisallow=all\nallow=ulaw\ntype=friend\nusername=testcarrier\nsecret=test\nhost=dynamic\ndtmfmode=rfc2833\ncontext=trunkinbound\n", protocol='SIP', globals_string='TESTSIPTRUNK = SIP/testcarrier', dialplan_entry="exten => _91999NXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)\nexten => _91999NXXXXXX,2,Dial(${TESTSIPTRUNK}/${EXTEN:2},,tTor)\nexten => _91999NXXXXXX,3,Hangup\n", server_ip='10.10.10.15', active='N'; +INSERT INTO vicidial_server_carriers SET carrier_id='IAXEXAMPLE', carrier_name='TEST IAX carrier example',registration_string='register => testcarrier:test@10.10.10.15:4569', template_id='--NONE--', account_entry="[testcarrier]\ndisallow=all\nallow=ulaw\ntype=friend\naccountcode=testcarrier\nsecret=test\nhost=dynamic\ncontext=trunkinbound\n", protocol='IAX2', globals_string='TESTIAXTRUNK = IAX2/testcarrier', dialplan_entry="exten => _71999NXXXXXX,1,AGI(agi://127.0.0.1:4577/call_log)\nexten => _71999NXXXXXX,2,Dial(${TESTIAXTRUNK}/${EXTEN:2},,tTor)\nexten => _71999NXXXXXX,3,Hangup\n", server_ip='10.10.10.15', active='N'; UPDATE system_settings SET db_schema_version='1130'; +INSERT INTO vicidial_inbound_dids SET did_pattern='default', did_description='Default DID', did_active='Y', did_route='EXTEN', extension='9998811112', exten_context='default'; + +UPDATE system_settings SET db_schema_version='1131'; diff --git a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.5.txt b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.5.txt index bf83d3b1..0a3d529c 100644 --- a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.5.txt +++ b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.5.txt @@ -460,6 +460,8 @@ Server IP -<\/B> This is the server that this specific carrier record is associa Active -<\/B> This defines whether the carrier will be included in the auto-generated conf files or not|| Conf Override Settings -<\/B> If populated, and the Template ID is set to --NONE-- then the contents of this field are used as the conf file entries for this phone. generate_vicidial_conf for this phones server must be set to Y for this to work. This field should NOT contain the [extension] line, that will be automatically generated|| Template ID -<\/B> This is the conf file template ID that this phone entry will use for its Asterisk settings. Default is --NONE--|| +If you will be taking in inbound calls from this carrier trunk you might want to set the context=trunkinbound within this field so that you can use the DID handling process within VICIDIAL|| +There is a reserved default DID that you can use which is just the word -default- without the dashes, that will allos you to send any call that does not match any other existing patterns to the default DID|| ############################################################ CLIENT diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index 421e08a4..8baf32a3 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -3596,7 +3596,7 @@ if ($SSqc_features_active > 0)

-DID Extension - This is the number, extension or DID that will trigger this entry and that you will route within the system using this function. +DID Extension - This is the number, extension or DID that will trigger this entry and that you will route within the system using this function. There is a reserved default DID that you can use which is just the word -default- without the dashes, that will allos you to send any call that does not match any other existing patterns to the default DID.
@@ -4566,7 +4566,7 @@ if ($SSoutbound_autodial_active > 0)

-Account Entry - This field is used if you have not selected a template to use, and it is where you can enter in the specific account settings to be used for this carrier. +Account Entry - This field is used if you have not selected a template to use, and it is where you can enter in the specific account settings to be used for this carrier. If you will be taking in inbound calls from this carrier trunk you might want to set the context=trunkinbound within this field so that you can use the DID handling process within VICIDIAL.