From e210febaeb87c320b3142d47caa108d960adf709 Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 26 Apr 2024 02:13:22 +0000 Subject: [PATCH] Added md_check option for transfer_conference function for Agent API Added ConfBridge support for 3-way press-1 features git-svn-id: svn://192.168.202.10@3829 3d104415-ff17-0410-8863-d5cf3c621b8a --- agi/agi-3way_press_agent.agi | 12 +++++- agi/agi-3way_press_outside.agi | 12 +++++- docs/AGENT_API.txt | 5 ++- .../ConfBridge/ConfBridge Documentation.txt | 4 +- www/agc/api.php | 42 ++++++++++++++++--- 5 files changed, 63 insertions(+), 12 deletions(-) diff --git a/agi/agi-3way_press_agent.agi b/agi/agi-3way_press_agent.agi index b87480d7..c25f76d8 100644 --- a/agi/agi-3way_press_agent.agi +++ b/agi/agi-3way_press_agent.agi @@ -35,6 +35,7 @@ # 231227-1428 - Added multi-phone ability # 240114-0942 - Added agent_heartbeat # 240116-2110 - Added CLI flags for timeout and outside-agent dial timeout +# 240425-2207 - Added ConfBridge support # $script = 'agi-3way_press_agent.agi'; @@ -48,6 +49,7 @@ $one_mysql_log=0; $MT[0]=''; $timeout=100; $Local_dial_timeout=80; +$conf_engine=''; $now_date_epoch = time(); @@ -117,7 +119,7 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA or die "Couldn't connect to database: " . DBI->errstr; ### Grab Server values from the database -$stmtA = "SELECT agi_output,local_gmt FROM servers where server_ip = '$VARserver_ip';"; +$stmtA = "SELECT agi_output,local_gmt,conf_engine FROM servers where server_ip = '$VARserver_ip';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -129,6 +131,7 @@ while ($sthArows > $rec_count) @aryA = $sthA->fetchrow_array; $DBagi_output = $aryA[0]; $local_gmt = $aryA[1]; + $conf_engine = $aryA[2]; if ($isdst) {$local_gmt++;} if ($DBagi_output =~ /STDERR/) {$AGILOG = '1';} if ($DBagi_output =~ /FILE/) {$AGILOG = '2';} @@ -593,11 +596,16 @@ while ($wait_loop < $timeout) # $affected_rowsD = $dbhA->do($stmtA); # if ($AGILOG) {$agi_string = "-- vicidial_conferences UPDATE: |$affected_rowsD|$stmtA|"; &agi_output;} + if ($conf_engine eq "CONFBRIDGE") + {$XFERstr = "8$CALLconf_exten";} + else + {$XFERstr = "7$CALLconf_exten";} + if ($AGILOG) {$agi_string = "3-WAY AGENT TRANSFER: |$CALLuser|$CALLserver_ip|$CALLconf_exten|$calleridname|$VIDqueryCID|"; &agi_output;} print "SET CONTEXT $ext_context\n"; $result = ; checkresult($result); - print "SET EXTENSION 7$CALLconf_exten\n"; + print "SET EXTENSION $XFERstr\n"; $result = ; checkresult($result); print "SET PRIORITY 1\n"; diff --git a/agi/agi-3way_press_outside.agi b/agi/agi-3way_press_outside.agi index f3b9dbed..817632e8 100644 --- a/agi/agi-3way_press_outside.agi +++ b/agi/agi-3way_press_outside.agi @@ -55,6 +55,7 @@ # 240108-1503 - Added call_channel and call_transfer logging # 240114-0946 - Added check of agent_heartbeat # 240116-2109 - Added CLI flag for timeout +# 240425-2208 - Added ConfBridge support # $script = 'agi-3way_press_outside.agi'; @@ -67,6 +68,7 @@ $mysql_log_count=272; $one_mysql_log=0; $MT[0]=''; $timeout=100; +$conf_engine=''; $now_date_epoch = time(); @@ -135,7 +137,7 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA or die "Couldn't connect to database: " . DBI->errstr; ### Grab Server values from the database -$stmtA = "SELECT agi_output,local_gmt FROM servers where server_ip = '$VARserver_ip';"; +$stmtA = "SELECT agi_output,local_gmt,conf_engine FROM servers where server_ip = '$VARserver_ip';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -147,6 +149,7 @@ while ($sthArows > $rec_count) @aryA = $sthA->fetchrow_array; $DBagi_output = $aryA[0]; $local_gmt = $aryA[1]; + $conf_engine = $aryA[2]; if ($isdst) {$local_gmt++;} if ($DBagi_output =~ /STDERR/) {$AGILOG = '1';} if ($DBagi_output =~ /FILE/) {$AGILOG = '2';} @@ -563,11 +566,16 @@ if ($stage =~ /accepted/i) $affected_rowsE = $dbhA->do($stmtA); if ($AGILOG) {$agi_string = "-- vicidial_3way_press_live transfer DELETE: |$affected_rowsE|$stmtA|"; &agi_output;} + if ($conf_engine eq "CONFBRIDGE") + {$XFERstr = "8$CALLconf_exten";} + else + {$XFERstr = "7$CALLconf_exten";} + if ($AGILOG) {$agi_string = "3-WAY AGENT TRANSFER: |$CALLuser|$CALLserver_ip|$CALLconf_exten|$calleridname|"; &agi_output;} print "SET CONTEXT $ext_context\n"; $result = ; checkresult($result); - print "SET EXTENSION 7$CALLconf_exten\n"; + print "SET EXTENSION $XFERstr\n"; $result = ; checkresult($result); print "SET PRIORITY 1\n"; diff --git a/docs/AGENT_API.txt b/docs/AGENT_API.txt index ea16380e..8f0b5fc7 100644 --- a/docs/AGENT_API.txt +++ b/docs/AGENT_API.txt @@ -1,4 +1,4 @@ -AGENT API DOCUMENT Started: 2008-07-03 Updated: 2023-12-22 +AGENT API DOCUMENT Started: 2008-07-03 Updated: 2024-04-25 This document describes the functions of an API(Application Programming Interface) for the VICIDIAL Agent screen. This functionality will be rather limited at first @@ -717,6 +717,8 @@ VALUES: OPTIONAL, alternate method for caller ID number to use when doing DIAL_WITH_CUSTOMER or PARK_CUSTOMER_DIAL: 'CAMPAIGN','AGENT_PHONE','CUSTOMER','CUSTOM_CID' multi_dial_phones - OPTIONAL, for use only with "Agent 3-way Press-1 Calls", contains up to 10 phone numbers separated by commas: "2125551212,4075551212,3125551212" (duplicates will be removed) + md_check - + OPTIONAL, for use only with 'multi_dial_phones' option above, if this is set to 'YES' it will check for still-active previous 3-way calls and show an error if any are found EXAMPLE URLS: http://server/agc/api.php?source=test&user=6666&pass=1234&agent_user=1000&function=transfer_conference&value=HANGUP_XFER @@ -743,6 +745,7 @@ ERROR: agent_user does not have a live call - 6666 ERROR: caller_id_number from group_alias is not valid - 6666|TESTING|123 ERROR: group_alias is not valid - 6666|TESTING ERROR: cid_choice is not valid - 6666|TESTING +ERROR: agent_user has previous active 3-way calls - 6666|1|0|YES SUCCESS: transfer_conference function set - LOCAL_CLOSER|SALESLINE||YES|6666|M2141842580000000044| diff --git a/extras/ConfBridge/ConfBridge Documentation.txt b/extras/ConfBridge/ConfBridge Documentation.txt index 570c67ed..5e20613e 100644 --- a/extras/ConfBridge/ConfBridge Documentation.txt +++ b/extras/ConfBridge/ConfBridge Documentation.txt @@ -1,11 +1,11 @@ -VICIdial ConfBridge Support: STARTED: 2022-06-22 UPDATED: 2024-04-20 +VICIdial ConfBridge Support: STARTED: 2022-06-22 UPDATED: 2024-04-25 !!! NOTE: VICIdial ConfBridge has been in use by several companies in production for over a year now and is considered stable !!! !!! NOTE: VICIdial ConfBridge support requires Asterisk 16 or higher to be installed on your dialers. Code development and testing was done with VICIbox 11 and the optional Asterisk 16 package available through VICIbox 11 !!! -!!! NOTE: As of svn/trunk revision 3826, the new 'AST_conf_update_screen.pl' script is installed by the VICIdial codebase and the 'AST_VDremote_agents.pl.diff' patch is already applied by default. +!!! NOTE: As of svn/trunk revision 3828, the new 'AST_conf_update_screen.pl' script is installed by the VICIdial codebase and all other required code patches are already applied by default. BETA support for ConfBridge was first included in the VICIdial svn/trunk codebase as of revision 3624. diff --git a/www/agc/api.php b/www/agc/api.php index 8e294fab..e5b921c2 100644 --- a/www/agc/api.php +++ b/www/agc/api.php @@ -113,10 +113,11 @@ # 231129-1457 - Added refresh_panel function # 231222-2105 - Added multi_dial_phones option to the transfer_conference function # 240219-1500 - Added daily_limit setting to change_ingroups function +# 240425-1901 - Added md_check option for transfer_conference function # -$version = '2.14-78'; -$build = '240219-1500'; +$version = '2.14-79'; +$build = '240425-1901'; $php_script = 'api.php'; $startMS = microtime(); @@ -292,6 +293,8 @@ if (isset($_GET["text_color"])) {$text_color=$_GET["text_color"];} elseif (isset($_POST["text_color"])) {$text_color=$_POST["text_color"];} if (isset($_GET["multi_dial_phones"])) {$multi_dial_phones=$_GET["multi_dial_phones"];} elseif (isset($_POST["multi_dial_phones"])) {$multi_dial_phones=$_POST["multi_dial_phones"];} +if (isset($_GET["md_check"])) {$md_check=$_GET["md_check"];} + elseif (isset($_POST["md_check"])) {$md_check=$_POST["md_check"];} $DB=preg_replace("/[^0-9a-zA-Z]/","",$DB); @@ -354,6 +357,7 @@ $dnc_check=preg_replace("/[^-_0-9a-zA-Z]/","",$dnc_check); $campaign_dnc_check=preg_replace("/[^-_0-9a-zA-Z]/","",$campaign_dnc_check); $notification_date = preg_replace('/[^- \:0-9]/','',$notification_date); $multi_dial_phones = preg_replace('/[^\,0-9]/','',$multi_dial_phones); +$md_check = preg_replace("/[^0-9a-zA-Z]/","",$md_check); if ($non_latin < 1) { @@ -4248,9 +4252,37 @@ if ($function == 'transfer_conference') $affected_rowsVP=0; if ($vp > 0) { - $stmtVP = "INSERT IGNORE INTO vicidial_3way_press_multi SET user='$agent_user',call_date=NOW(),phone_numbers='$multi_dial_phones_STRING',phone_numbers_ct='$vp',status='NEW' ON DUPLICATE KEY UPDATE call_date=NOW(),phone_numbers='$multi_dial_phones_STRING',phone_numbers_ct='$vp',status='NEW';"; - $rslt=mysql_to_mysqli($stmtVP, $link); - $affected_rowsVP = mysqli_affected_rows($link); + $md_check_ok=1; + $md_check_ct=0; + if (preg_match("/YES/i",$md_check)) + { + # check for still-active previous 3-way calls from this agent and send error if any are found + $stmt = "select count(*) from vicidial_3way_press_live where user='$agent_user' and status!='HUNGUP';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + $VDTW_live_ct = mysqli_num_rows($rslt); + if ($VDTW_live_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $md_check_ct = $row[0]; + } + if ($md_check_ct > 0) {$md_check_ok = 0;} + } + if ($md_check_ok > 0) + { + $stmtVP = "INSERT IGNORE INTO vicidial_3way_press_multi SET user='$agent_user',call_date=NOW(),phone_numbers='$multi_dial_phones_STRING',phone_numbers_ct='$vp',status='NEW' ON DUPLICATE KEY UPDATE call_date=NOW(),phone_numbers='$multi_dial_phones_STRING',phone_numbers_ct='$vp',status='NEW';"; + $rslt=mysql_to_mysqli($stmtVP, $link); + $affected_rowsVP = mysqli_affected_rows($link); + } + else + { + $result = _QXZ("ERROR"); + $result_reason = _QXZ("agent_user has previous active 3-way calls"); + $data = "$md_check_ct|$md_check_ok|$md_check"; + echo "$result: $result_reason - $agent_user|$data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } } $multi_dial_phones_OUTPUT = "|Multi-phones: $vp $mp $affected_rowsVP"; }