Added delete_did option to update_did function, Issue #1242

git-svn-id: svn://192.168.202.10@3324 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2020-11-13 12:57:19 +00:00
parent 8cddd49af2
commit f9f18b797b
4 changed files with 57 additions and 9 deletions
+1 -1
View File
@@ -893,7 +893,7 @@ lead_id -
OPTIONAL, The lead_id of the call that the agent is currently on, if populated it will validate that is the lead the agent is talking to
EXAMPLE URLS:
http://server/agc/api.php?source=test&user=6666&pass=1234&agent_user=1000&function=vm_message&lead_id=12345&value=EXship01|EXship02|EXship03
http://server/agc/api.php?source=test&user=6666&pass=1234&agent_user=1000&function=vm_message&value=EXship01|EXship02|EXship03
http://server/agc/api.php?source=test&user=6666&pass=1234&agent_user=1000&function=vm_message&lead_id=12345&value=appointment_reminder2
RESPONSES:
+5 -1
View File
@@ -1,4 +1,4 @@
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2020-11-06
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2020-11-13
This document describes the functions of an API(Application Programming
Interface) for all functions NOT directly relating to the VICIDIAL Agent screen.
@@ -165,6 +165,7 @@ Changes:
200824-2330 - Added search_method BLOCK option for hopper_list function
201002-1545 - Added extension as recording_lookup option, Allowed for secure sounds_web_server setting
201106-1654 - Added campaign_id option to agent_stats_export function
201113-0713 - Added delete_did option to update_did function
API Functions use the 'function' variable
@@ -2007,6 +2008,7 @@ phone_extension - 1-100 characters
server_ip - must be all numbers and dots, max 15 characters
group - a valid in-group group_id
filter_clean_cid_number - 1-20 characters
delete_did - Can be one of these: 'Y','N' (default is 'N')
Example URL strings for API calls:
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_did&did_pattern=%2B1727555112&did_description=Updated+test+API+DID&active=Y
@@ -2014,6 +2016,7 @@ http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&functio
Example responses:
ERROR: update_did USER DOES NOT HAVE PERMISSION TO UPDATE DIDS - 6666
ERROR: update_did USER DOES NOT HAVE PERMISSION TO DELETE DIDS - 6666
ERROR: update_did YOU MUST USE ALL REQUIRED FIELDS - 6666|1
ERROR: update_did NOT AN ALLOWED DID - 98762
ERROR: update_did DID DOES NOT EXIST - 6666|1000
@@ -2029,6 +2032,7 @@ ERROR: update_did SERVER IP MUST BE A VALID SERVER IN THE SYSTEM, THIS IS AN OPT
ERROR: update_did GROUP ID MUST BE A VALID INBOUND GROUP IN THE SYSTEM, THIS IS AN OPTIONAL FIELD - 6666|test
ERROR: update_did CLEAN CID NUMBER MUST BE FROM 1 TO 20 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|
NOTICE: update_did NO UPDATES DEFINED - 6666|
SUCCESS: update_did DID HAS BEEN DELETED - 6666|23|1101
SUCCESS: update_did DID HAS BEEN UPDATED - 6666|1101
+7 -4
View File
@@ -4736,12 +4736,13 @@ else
# 201106-2324 - Fix for issue with populate_lead_source menu
# 201111-1258 - Added campaigns hopper_drop_run_trigger setting
# 201111-1616 - Fix for CID Groups permissions issue #1234
# 201113-0754 - Changed Modify DID page variable population
#
# make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time
$admin_version = '2.14-776a';
$build = '201111-1616';
$admin_version = '2.14-777a';
$build = '201113-0754';
$STARTtime = date("U");
$SQLdate = date("Y-m-d H:i:s");
@@ -32533,8 +32534,10 @@ if ($ADD==3311)
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$did_id = $row[0];
$did_pattern = $row[1];
if (strlen($row[0])>0)
{$did_id = $row[0];}
if (strlen($row[1])>0)
{$did_pattern = $row[1];}
$did_description = $row[2];
$did_active = $row[3];
$did_route = $row[4];
+44 -3
View File
@@ -155,10 +155,11 @@
# 200824-2330 - Added search_method BLOCK option for hopper_list function
# 201002-1545 - Added extension as recording lookup option, Allowed for secure sounds_web_server setting
# 201106-1654 - Added campaign_id option to agent_stats_export function
# 201113-0713 - Added delete_did option to update_did function, Issue #1242
#
$version = '2.14-132';
$build = '201106-1654';
$version = '2.14-133';
$build = '201113-0713';
$api_url_log = 0;
$startMS = microtime();
@@ -551,6 +552,8 @@ if (isset($_GET["template_id"])) {$template_id=$_GET["template_id"];}
elseif (isset($_POST["template_id"])) {$template_id=$_POST["template_id"];}
if (isset($_GET["on_hook_agent"])) {$on_hook_agent=$_GET["on_hook_agent"];}
elseif (isset($_POST["on_hook_agent"])) {$on_hook_agent=$_POST["on_hook_agent"];}
if (isset($_GET["delete_did"])) {$delete_did=$_GET["delete_did"];}
elseif (isset($_POST["delete_did"])) {$delete_did=$_POST["delete_did"];}
header ("Content-type: text/html; charset=utf-8");
@@ -785,6 +788,7 @@ if ($non_latin < 1)
$use_external_server_ip = preg_replace('/[^-_0-9a-zA-Z]/','',$use_external_server_ip);
$template_id = preg_replace('/[^-_0-9a-zA-Z]/','',$template_id);
$on_hook_agent = preg_replace('/[^-_0-9a-zA-Z]/','',$on_hook_agent);
$delete_did = preg_replace('/[^0-9a-zA-Z]/','',$delete_did);
}
else
{
@@ -952,7 +956,7 @@ if ($auth < 1)
exit;
}
$stmt="SELECT api_list_restrict,api_allowed_functions,user_group,selected_language from vicidial_users where user='$user' and active='Y';";
$stmt="SELECT api_list_restrict,api_allowed_functions,user_group,selected_language,delete_inbound_dids from vicidial_users where user='$user' and active='Y';";
if ($DB>0) {echo "DEBUG: auth query - $stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
@@ -960,6 +964,8 @@ $api_list_restrict = $row[0];
$api_allowed_functions = $row[1];
$LOGuser_group = $row[2];
$VUselected_language = $row[3];
$VUdelete_inbound_dids = $row[4];
if ( ($api_list_restrict > 0) and ( ($function == 'add_lead') or ($function == 'update_lead') or ($function == 'update_list') or ($function == 'list_info') or ($function == 'list_custom_fields') ) )
{
$stmt="SELECT allowed_campaigns from vicidial_user_groups where user_group='$LOGuser_group';";
@@ -6615,6 +6621,41 @@ if ($function == 'update_did')
$groupSQL='';
$filter_clean_cid_numberSQL='';
if ($delete_did == 'Y')
{
if ($VUdelete_inbound_dids < 1)
{
$result = 'ERROR';
$result_reason = "update_did USER DOES NOT HAVE PERMISSION TO DELETE DIDS";
$data = "$allowed_user";
echo "$result: $result_reason: |$user|$data\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
exit;
}
else
{
$stmt="DELETE FROM vicidial_inbound_dids WHERE did_pattern='$did_pattern' limit 1;";
$rslt=mysql_to_mysqli($stmt, $link);
$update_count = mysqli_affected_rows($link);
if ($DB) {echo "$update_count|$stmt|\n";}
### LOG INSERTION Admin Log Table ###
$SQL_log = "$stmt|";
$SQL_log = preg_replace('/;/', '', $SQL_log);
$SQL_log = addslashes($SQL_log);
$stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$user', ip_address='$ip', event_section='DIDS', event_type='DELETE', record_id='$did_id', event_code='ADMIN API DELETE DID', event_sql=\"$SQL_log\", event_notes='did: $did_pattern did_id: $did_id';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$result = 'SUCCESS';
$result_reason = "update_did DID HAS BEEN DELETED";
$data = "$did_pattern|$did_id";
echo "$result: $result_reason - $user|$data\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
exit;
}
}
if (strlen($did_description) > 0)
{
if ( (strlen($did_description) > 50) or (strlen($did_description) < 6) )