diff --git a/UPGRADE b/UPGRADE index 5c3075d5..55d2fdd1 100644 --- a/UPGRADE +++ b/UPGRADE @@ -414,6 +414,12 @@ OTHER CHANGES: each dialer's astguiclient.conf/extensions.conf/manager.conf files Read SIP_EVENT_LOGGING.txt doc for more details +115. Added new Non-Agent API function 'update_cid_group_entry' which allows you + to add/update/delete/info CID Group entries and AC-CID entries + +116. Added new Non-Agent API 'custom_fields_copy' option to the 'add_list' + function + diff --git a/docs/NON-AGENT_API.txt b/docs/NON-AGENT_API.txt index 4e15afb3..5eb3bfff 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: 2019-06-28 +NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2019-07-03 This document describes the functions of an API(Application Programming Interface) for all functions NOT directly relating to the VICIDIAL Agent screen. @@ -143,6 +143,7 @@ Changes: 181214-1606 - Added lead_callback_info function 190325-1055 - Added agent_campaigns function 190628-1504 - Added update_cid_group_entry function +190703-0858 - Added custom_fields_copy option to add_list function API Functions use the 'function' variable @@ -1401,13 +1402,16 @@ web_form_address_two - 6-100 characters web_form_address_three - 6-100 characters reset_time - 4-100 characters, must be in valid 4-digit groups of 24-hour time (i.e. 0900-1700-2359) expiration_date - 10 characters, must be in valid date format YYYY-MM-DD (i.e. 2012-11-25) +custom_fields_copy - A valid list ID with custom fields to be copied to this new list, 2-14 digits NOTES: - for the web form addresses, you can URL encode them to include standard URL special characters + - to use the 'custom_fields_copy' option, the API user must have the "Custom Fields Modify" user option enabled Example URL strings for API calls: http://server/vicidial/non_agent_api.php?source=test&function=add_list&user=6666&pass=1234&list_id=1101&list_name=Test+API+list&campaign_id=TESTCAMP http://server/vicidial/non_agent_api.php?source=test&function=add_list&user=6666&pass=1234&list_id=1101&list_name=Test+API+list&campaign_id=TESTCAMP&active=N&outbound_cid=7275551212&script=DEMOSCRIPT&am_message=8304&drop_inbound_group=SALESLINE&web_form_address=http://www.vicidial.org/?testing=hghg +http://server/vicidial/non_agent_api.php?source=test&function=add_list&user=6666&pass=1234&list_id=303&list_name=Test+API+list+3&campaign_id=TESTCAMP&custom_fields_copy=222 Example responses: ERROR: add_list USER DOES NOT HAVE PERMISSION TO ADD LISTS - 6666|0 @@ -1418,6 +1422,9 @@ ERROR: add_list SCRIPT DOES NOT EXIST, THIS IS AN OPTIONAL FIELD - 6666|TESTSCRI ERROR: add_list IN-GROUP DOES NOT EXIST, THIS IS AN OPTIONAL FIELD - 6666|TEST_IN8 ERROR: add_list RESET TIME IS NOT VALID, THIS IS AN OPTIONAL FIELD - 6666|012 ERROR: add_list EXPIRATION DATE IS NOT VALID, THIS IS AN OPTIONAL FIELD - 6666|012 +ERROR: add_list CUSTOM FIELDS LIST ID TO COPY FROM DOES NOT EXIST, THIS IS AN OPTIONAL FIELD - 6666|12 +ERROR: add_list CUSTOM FIELDS LIST ID TO COPY FROM HAS NO CUSTOM FIELDS, THIS IS AN OPTIONAL FIELD - 6666|12 +ERROR: add_list USER DOES NOT HAVE PERMISSION TO MODIFY CUSTOM FIELDS, THIS IS AN OPTIONAL FIELD - 6666|12 SUCCESS: add_list LIST HAS BEEN ADDED - 6666|1101|TESTCAMP diff --git a/www/vicidial/list_split.php b/www/vicidial/list_split.php index 5d880ebd..7d23eafb 100644 --- a/www/vicidial/list_split.php +++ b/www/vicidial/list_split.php @@ -1,7 +1,7 @@ LICENSE: AGPLv2 +# Copyright (C) 2019 Matt Florell,Michael Cargile LICENSE: AGPLv2 # # CHANGES # 140916-1215 - Initial Build @@ -11,10 +11,11 @@ # 161014-0842 - Added screen colors # 170409-1542 - Added IP List validation code # 170819-1001 - Added allow_manage_active_lists option +# 190703-0925 - Added use of admin_web_directory system setting # -$version = '2.14-7'; -$build = '170819-1001'; +$version = '2.14-8'; +$build = '190703-0925'; require("dbconnect_mysqli.php"); require("functions.php"); @@ -55,7 +56,7 @@ $num_leads = preg_replace('/[^0-9]/','',$num_leads); ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### -$sys_settings_stmt = "SELECT use_non_latin,outbound_autodial_active,sounds_central_control_active,enable_languages,language_method,active_modules,admin_screen_colors,allow_manage_active_lists FROM system_settings;"; +$sys_settings_stmt = "SELECT use_non_latin,outbound_autodial_active,sounds_central_control_active,enable_languages,language_method,active_modules,admin_screen_colors,allow_manage_active_lists,admin_web_directory FROM system_settings;"; $sys_settings_rslt=mysql_to_mysqli($sys_settings_stmt, $link); if ($DB) {echo "$sys_settings_stmt\n";} $num_rows = mysqli_num_rows($sys_settings_rslt); @@ -70,6 +71,7 @@ if ($num_rows > 0) $SSactive_modules = $sys_settings_row[5]; $SSadmin_screen_colors = $sys_settings_row[6]; $SSallow_manage_active_lists = $sys_settings_row[7]; + $SSadmin_web_directory = $sys_settings_row[8]; } else { @@ -440,7 +442,7 @@ if ($confirm == "confirm") { $admin_lists_custom = 'admin_lists_custom.php'; - $url = "http" . (isset($_SERVER['HTTPS']) ? 's' : '') . "://$_SERVER[HTTP_HOST]/vicidial/" . $admin_lists_custom . "?action=COPY_FIELDS_SUBMIT&list_id=$new_list_id&source_list_id=$orig_list©_option=APPEND"; + $url = "http" . (isset($_SERVER['HTTPS']) ? 's' : '') . "://$_SERVER[HTTP_HOST]/$SSadmin_web_directory/" . $admin_lists_custom . "?action=COPY_FIELDS_SUBMIT&list_id=$new_list_id&source_list_id=$orig_list©_option=APPEND"; # use cURL to call the copy custom fields code $curl = curl_init(); diff --git a/www/vicidial/non_agent_api.php b/www/vicidial/non_agent_api.php index 696b1b19..755c03ab 100644 --- a/www/vicidial/non_agent_api.php +++ b/www/vicidial/non_agent_api.php @@ -137,10 +137,11 @@ # 190313-0710 - Fix for update_lead custom fields issue #1134 # 190325-1055 - Added agent_campaigns function # 190628-1504 - Added update_cid_group_entry function +# 190703-0858 - Added custom_fields_copy option to add_list function # -$version = '2.14-114'; -$build = '190628-1504'; +$version = '2.14-115'; +$build = '190703-0858'; $api_url_log = 0; $startMS = microtime(); @@ -505,6 +506,8 @@ if (isset($_GET["cid_group_id"])) {$cid_group_id=$_GET["cid_group_id"];} elseif (isset($_POST["cid_group_id"])) {$cid_group_id=$_POST["cid_group_id"];} if (isset($_GET["cid_description"])) {$cid_description=$_GET["cid_description"];} elseif (isset($_POST["cid_description"])) {$cid_description=$_POST["cid_description"];} +if (isset($_GET["custom_fields_copy"])) {$custom_fields_copy=$_GET["custom_fields_copy"];} + elseif (isset($_POST["custom_fields_copy"])) {$custom_fields_copy=$_POST["custom_fields_copy"];} header ("Content-type: text/html; charset=utf-8"); @@ -513,7 +516,7 @@ header ("Pragma: no-cache"); // HTTP/1.0 ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### -$stmt = "SELECT use_non_latin,custom_fields_enabled,pass_hash_enabled,agent_whisper_enabled,active_modules,auto_dial_limit,enable_languages,language_method FROM system_settings;"; +$stmt = "SELECT use_non_latin,custom_fields_enabled,pass_hash_enabled,agent_whisper_enabled,active_modules,auto_dial_limit,enable_languages,language_method,admin_web_directory FROM system_settings;"; $rslt=mysql_to_mysqli($stmt, $link); $qm_conf_ct = mysqli_num_rows($rslt); if ($qm_conf_ct > 0) @@ -529,6 +532,7 @@ if ($qm_conf_ct > 0) $SSauto_dial_limit = ($SSauto_dial_limit + 0.001); $SSenable_languages = $row[6]; $SSlanguage_method = $row[7]; + $SSadmin_web_directory = $row[8]; } ##### END SETTINGS LOOKUP ##### ########################################### @@ -722,6 +726,7 @@ if ($non_latin < 1) $areacode = preg_replace('/[^-_0-9a-zA-Z]/','',$areacode); $cid_group_id = preg_replace('/[^-_0-9a-zA-Z]/','',$cid_group_id); $cid_description = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$cid_description); + $custom_fields_copy = preg_replace('/[^0-9]/','',$custom_fields_copy); if ($outbound_cid != '---ALL---') {$outbound_cid=preg_replace('/[^0-9]/','',$outbound_cid);} if ($areacode != '---ALL---') @@ -4712,6 +4717,64 @@ if ($function == 'add_list') api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data); exit; } + $copy_custom_fields_trigger=0; + if ( (strlen($custom_fields_copy) > 1) and (strlen($custom_fields_copy) < 15) ) + { + $stmt="SELECT count(*) from vicidial_lists where list_id='$custom_fields_copy';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $custom_fields_copy_exists=$row[0]; + if ($DB>0) {echo "$custom_fields_copy_exists|$stmt|\n";} + if ($custom_fields_copy_exists < 1) + { + $result = 'ERROR'; + $result_reason = "add_list CUSTOM FIELDS LIST ID TO COPY FROM DOES NOT EXIST, THIS IS AN OPTIONAL FIELD"; + $data = "$custom_fields_copy_exists"; + 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="SELECT count(*) from vicidial_lists_fields where list_id='$custom_fields_copy';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $vicidial_lists_fields_exists=$row[0]; + if ($DB>0) {echo "$vicidial_lists_fields_exists|$stmt|\n";} + if ($vicidial_lists_fields_exists < 1) + { + $result = 'ERROR'; + $result_reason = "add_list CUSTOM FIELDS LIST ID TO COPY FROM HAS NO CUSTOM FIELDS, THIS IS AN OPTIONAL FIELD"; + $data = "$custom_fields_copy"; + 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="SELECT count(*) from vicidial_users where user='$user' and custom_fields_modify='1';"; + $rslt=mysql_to_mysqli($stmt, $link); + $row=mysqli_fetch_row($rslt); + $custom_fields_modify_exists=$row[0]; + if ($DB>0) {echo "$custom_fields_modify_exists|$stmt|\n";} + if ($custom_fields_modify_exists < 1) + { + $result = 'ERROR'; + $result_reason = "add_list USER DOES NOT HAVE PERMISSION TO MODIFY CUSTOM FIELDS, THIS IS AN OPTIONAL FIELD"; + $data = "$custom_fields_copy"; + 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 + { + if ($DB>0) {echo "Copy custom fields triggered|$copy_custom_fields_trigger|\n";} + $copy_custom_fields_trigger++; + } + } + } + } + $webformSQL=''; $webformtwoSQL=''; $webformthreeSQL=''; @@ -4758,11 +4821,38 @@ if ($function == 'add_list') $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {echo "|$stmt|\n";} + if ( ($copy_custom_fields_trigger > 0) and (strlen($custom_fields_copy) > 1) ) + { + ### BEGIN copy custom fields ### + $admin_lists_custom = 'admin_lists_custom.php'; + + $url = "http" . (isset($_SERVER['HTTPS']) ? 's' : '') . "://$_SERVER[HTTP_HOST]/$SSadmin_web_directory/" . $admin_lists_custom . "?copy_option=APPEND&action=COPY_FIELDS_SUBMIT&list_id=$list_id&source_list_id=$custom_fields_copy"; + + if ($DB>0) {echo "Copy custom fields url|$url|\n";} + # use cURL to call the copy custom fields code + $curl = curl_init(); + + # Set some options - we are passing in a useragent too here + curl_setopt_array($curl, array( + CURLOPT_RETURNTRANSFER => 1, + CURLOPT_URL => $url, + CURLOPT_USERPWD => "$user:$pass", + CURLOPT_USERAGENT => 'non_agent_api.php' + )); + + # Send the request & save response to $resp + $resp = curl_exec($curl); + + # Close request to clear up some resources + curl_close($curl); + ### END copy custom fields ### + } + ### 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='LISTS', event_type='ADD', record_id='$list_id', event_code='ADMIN API ADD LIST', event_sql=\"$SQL_log\", event_notes='list: $list_id|$campaign_id';"; + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$user', ip_address='$ip', event_section='LISTS', event_type='ADD', record_id='$list_id', event_code='ADMIN API ADD LIST', event_sql=\"$SQL_log\", event_notes='list: $list_id|$campaign_id|$custom_fields_copy';"; if ($DB) {echo "|$stmt|\n";} $rslt=mysql_to_mysqli($stmt, $link);