From b9efd4a7bae1bd6ef5548c3ad93d5708f911e54a Mon Sep 17 00:00:00 2001 From: mattf Date: Tue, 16 Feb 2021 19:25:49 +0000 Subject: [PATCH] Added list_exists_check option for add_lead Non-Agent API function git-svn-id: svn://192.168.202.10@3354 3d104415-ff17-0410-8863-d5cf3c621b8a --- docs/NON-AGENT_API.txt | 5 ++++- www/vicidial/non_agent_api.php | 25 +++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/docs/NON-AGENT_API.txt b/docs/NON-AGENT_API.txt index 73e08a62..7ba7a935 100644 --- a/docs/NON-AGENT_API.txt +++ b/docs/NON-AGENT_API.txt @@ -1,4 +1,4 @@ -NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2021-02-10 +NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2021-02-16 This document describes the functions of an API(Application Programming Interface) for all functions NOT directly relating to the VICIDIAL Agent screen. @@ -172,6 +172,7 @@ Changes: 210113-1714 - Added copy_user function 210209-2014 - Added add_did function 210210-1627 - Added duplicate check with more X-day options for add_lead function +210216-1415 - Added list_exists_check option for add_lead function API Functions use the 'function' variable @@ -918,6 +919,7 @@ callback_type - USERONLY or ANYONE, default is ANYONE callback_user - User ID the USERONLY callback is assigned to callback_comments - Optional comments to appear when the callback is called back lookup_state - Y or N, default is N. Looks up state field from areacode list. Only works if the 'state' field is not populated. +list_exists_check - Y or N, default is N. If the list_id is not a defined list in the system, it will ERROR and not insert the lead. (for fields with spaces in the values, you can replace the space with a plus + sign[address, city, first_name, etc...]) OPTIONAL FIELDS- @@ -995,6 +997,7 @@ ERROR: add_lead INVALID PHONE NUMBER NANPA AREACODE PREFIX - 7275551212|6666 ERROR: add_lead USER DOES NOT HAVE PERMISSION TO ADD LEADS TO THE SYSTEM - 6666|0 ERROR: add_lead NOT AN ALLOWED LIST ID - 7275551212|98762 +ERROR: add_lead NOT A DEFINED LIST ID, LIST EXISTS CHECK ENABLED - 7275551212|12344 ERROR: NO FUNCTION SPECIFIED diff --git a/www/vicidial/non_agent_api.php b/www/vicidial/non_agent_api.php index c04c5875..4471c398 100644 --- a/www/vicidial/non_agent_api.php +++ b/www/vicidial/non_agent_api.php @@ -161,10 +161,11 @@ # 210113-1714 - Added copy_user function # 210209-2014 - Added add_did function # 210210-1627 - Added duplicate check with more X-day options for add_lead function +# 210216-1415 - Added list_exists_check option for add_lead function # -$version = '2.14-138'; -$build = '210210-1627'; +$version = '2.14-139'; +$build = '210216-1415'; $api_url_log = 0; $startMS = microtime(); @@ -563,6 +564,8 @@ if (isset($_GET["group_by_campaign"])) {$group_by_campaign=$_GET["group_by_cam elseif (isset($_POST["group_by_campaign"])) {$group_by_campaign=$_POST["group_by_campaign"];} if (isset($_GET["source_user"])) {$source_user=$_GET["source_user"];} elseif (isset($_POST["source_user"])) {$source_user=$_POST["source_user"];} +if (isset($_GET["list_exists_check"])) {$list_exists_check=$_GET["list_exists_check"];} + elseif (isset($_POST["list_exists_check"])) {$list_exists_check=$_POST["list_exists_check"];} header ("Content-type: text/html; charset=utf-8"); @@ -808,6 +811,7 @@ else $source = preg_replace("/'|\"|\\\\|;|#/","",$source); $source_user = preg_replace("/'|\"|\\\\|;|#/","",$source_user); } +$list_exists_check = preg_replace('/[^0-9a-zA-Z]/','',$list_exists_check); $USarea = substr($phone_number, 0, 3); $USprefix = substr($phone_number, 3, 3); @@ -10902,6 +10906,23 @@ if ($function == 'add_lead') exit; } } + if (preg_match("/Y/i",$list_exists_check)) + { + $stmt="SELECT count(*) from vicidial_lists where list_id='$list_id';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + if ($DB>0) {echo "DEBUG: add_lead list_exists_check query - $row[0]|$stmt\n";} + $list_exists_count = $row[0]; + if ($list_exists_count < 1) + { + $result = 'ERROR'; + $result_reason = "add_lead NOT A DEFINED LIST ID, LIST EXISTS CHECK ENABLED"; + $data = "$phone_number|$list_id"; + echo "$result: $result_reason - $data\n"; + api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); + exit; + } + } if (strlen($gender)<1) {$gender='U';} if (strlen($rank)<1) {$rank='0';} if (strlen($list_id)<3) {$list_id='999';}