Added options to update_campaign, add_user, update_phone in Non-Agent API

Added function update_did to Non-Agent API

git-svn-id: svn://192.168.202.10@2959 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2018-03-31 21:29:15 +00:00
parent ec5e7a5324
commit cc11988def
4 changed files with 544 additions and 16 deletions
+2
View File
@@ -291,6 +291,8 @@ OTHER CHANGES:
77. Added LOCALFQDN trigger for webforms and script Iframes to allow for use of
absolute URLs on multi-home networks. See CALL_URL_FEATURES.txt doc.
78. Added update_did Non-Agent API function
+75 -3
View File
@@ -1,4 +1,4 @@
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2018-02-08
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2018-03-31
This document describes the functions of an API(Application Programming
Interface) for all functions NOT directly relating to the VICIDIAL Agent screen.
@@ -41,6 +41,7 @@ server_refresh - forces a conf file refresh on all telco servers in the cluster
check_phone_number - allows you to check if a phone number is valid and dialable
logged_in_agents - list of agents that are logged in to the system
update_campaign - updates campaign settings in the system
update_did - updates Inbound DID information in the system
phone_number_log - exports list of calls placed to one of more phone numbers
ccc_lead_info - outputs lead data for cross-cluster-communication call
lead_status_search - displays all field values of all leads that match the status and call date in request
@@ -134,6 +135,7 @@ Changes:
171229-1602 - Added lead_status_search function
180109-1313 - Added call_status_stats function
180208-1655 - Added call_dispo_report function
180331-1716 - Added options to update_campaign, add_user, update_phone. Added function update_did
API Functions use the 'function' variable
@@ -997,6 +999,10 @@ custom_three - 1-100 characters
custom_four - 1-100 characters
custom_five - 1-100 characters
wrapup_seconds_override - number from -1 to 9999
agent_choose_ingroups - 0 or 1, default 1
agent_choose_blended - 0 or 1, default 1
closer_default_blended - 0 or 1, default 0
in_groups - pipe-delimited list of inbound groups to make selected for the user "SALESLINE|SUPPORT"
NOTE: This function does not work with Vtiger integration
@@ -1177,10 +1183,13 @@ protocol - Must be one of these: 'IAX2','SIP','Zap','EXTERNAL'
registration_password - 1-20 characters
phone_full_name - 1-50 characters
local_gmt - timezone setting, not adjusting for DST, default: '-5.00'
outbound_cid - 1-20 digits
outbound_cid - 6-18 digits
outbound_alt_cid - 6-18 digits, to clear this field send '--BLANK--'
phone_context - a phone context, default is 'default'
email - 1-100 characters
email - 5-100 characters, email address for voicemail, to clear this field send '--BLANK--'
admin_user_group - a valid user group or '---ALL---'
phone_ring_timeout - 1-3 digits, default '60'
delete_vm_after_email - Y or N, default 'N'
Example URL strings for API calls:
http://server/vicidial/non_agent_api.php?source=test&function=update_phone&user=6666&pass=1234&extension=55000&dialplan_number=55000&voicemail_id=55000&phone_login=55000&phone_pass=test&server_ip=192.168.198.5&protocol=SIP&registration_password=test&phone_full_name=Extension+55000&local_gmt=-5.00&outbound_cid=7275551212
@@ -1201,7 +1210,14 @@ ERROR: update_phone YOU MUST USE A VALID REGISTRATION PASSWORD - 6666|0
ERROR: update_phone YOU MUST USE A VALID PROTOCOL - 6666|0
ERROR: update_phone YOU MUST USE A VALID PHONE NAME - 6666|0
ERROR: update_phone YOU MUST USE A VALID PHONE CONTEXT - 6666|0
ERROR: update_phone YOU MUST USE A VALID EMAIL - 6666|x.com
ERROR: update_phone NO UPDATES DEFINED - 6666|0
ERROR: update_phone ACTIVE MUST BE Y OR N, THIS IS AN OPTIONAL FIELD - 6666|0
ERROR: update_phone OUTBOUND CID MUST BE FROM 6 TO 18 DIGITS, THIS IS AN OPTIONAL FIELD - 6666|0
ERROR: update_phone OUTBOUND ALT CID MUST BE FROM 6 TO 18 DIGITS, THIS IS AN OPTIONAL FIELD - 6666|0
ERROR: update_phone USER GROUP MUST BE FROM 2 TO 20 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|0
ERROR: update_phone PHONE RING TIMEOUT MUST BE FROM 2 TO 180 SECONDS, THIS IS AN OPTIONAL FIELD - 6666|0
ERROR: update_phone DELETE VOICEMAIL AFTER EMAIL MUST BE Y OR N, THIS IS AN OPTIONAL FIELD - 6666|0
SUCCESS: update_phone PHONE HAS BEEN UPDATED - 6666|cc100|10.0.9.8|SIP|100
SUCCESS: update_phone PHONE HAS BEEN DELETED - 6666|cc100|10.0.9.8|
NOTICE: update_phone USER DOES NOT HAVE PERMISSION TO DELETE PHONES - 6666|7878
@@ -1603,6 +1619,8 @@ hopper_level - Must be from 1 to 2000
reset_hopper - Must be one of these: 'Y','N', will default to 'N'
dial_method - Must be one of these: 'MANUAL','RATIO','INBOUND_MAN','ADAPT_AVERAGE','ADAPT_HARD_LIMIT','ADAPT_TAPERED'
dial_timeout - Must be from 1 to 120
outbound_cid - 1-20 digits
lead_filter_id - Must be a valid Filter in the system, or '---NONE---' to not use a filter
NOTES:
- please use no special characters like apostrophes, quotes or amphersands
@@ -1623,10 +1641,64 @@ ERROR: update_campaign ROUTING EXTENSION MUST BE FROM 3 TO 20 CHARACTERS, THIS I
ERROR: update_campaign HOPPER LEVEL MUST BE FROM 1 TO 2000, THIS IS AN OPTIONAL FIELD - 6666|12345
ERROR: update_campaign DIAL TIMEOUT MUST BE FROM 1 TO 120, THIS IS AN OPTIONAL FIELD - 6666|123
ERROR: update_campaign CAMPAIGN NAME MUST BE FROM 6 TO 40 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|test
ERROR: update_campaign CAMPAIGN CID MUST BE FROM 6 TO 20 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|test
ERROR: update_campaign CAMPAIGN LEAD FILTER MUST BE A VALID FILTER IN THE SYSTEM, THIS IS AN OPTIONAL FIELD - 6666|test
ERROR: update_campaign ACTIVE MUST BE Y OR N, THIS IS AN OPTIONAL FIELD - 6666|U
NOTICE: update_campaign NO UPDATES DEFINED - 6666|
NOTICE: update_campaign HOPPER HAS BEEN RESET - 6666|1101|324
SUCCESS: update_campaign CAMPAIGN HAS BEEN UPDATED - 6666|1101
--------------------------------------------------------------------------------
update_did - updates Inbound DID information in the vicidial_inbound_dids table
NOTE: api user for this function must have user_level set to 8 or higher and "Modify DIDs" enabled
REQUIRED FIELDS-
did_pattern - 2-50 characters, must be a valid DID in the system
NOTE: special characters in the did_pattern need to be URL encoded, for example the plus sign '+' must be sent as '%2B'
source - description of what originated the API call (maximum 20 characters)
EDITABLE FIELDS-
did_description - 6-50 characters
active - Must be one of these: 'Y','N'
did_route - must be one of these: 'EXTEN','VOICEMAIL','AGENT','PHONE','IN_GROUP','CALLMENU','VMAIL_NO_INST'
record_call - must be one of these: 'Y','N','Y_QUEUESTOP'
extension - 1-50 digits
exten_context - 1-50 characters
voicemail_ext - 1-10 digits
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
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
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=update_did&did_pattern=7275553331&did_description=Testing+DID&active=N&did_route=EXTEN&record_call=Y_QUEUESTOP&extension=8300&exten_context=notdefault&voicemail_ext=8301&phone_extension=55000&server_ip=192.168.198.5&group=TEST_IN2&filter_clean_cid_number=R10
Example responses:
ERROR: update_did USER DOES NOT HAVE PERMISSION TO UPDATE 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
ERROR: update_did DID DESCRIPTION MUST BE FROM 6 TO 50 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|012
ERROR: update_did ACTIVE MUST BE Y OR N, THIS IS AN OPTIONAL FIELD - 6666|U
ERROR: update_did DID ROUTE IS NOT VALID, THIS IS AN OPTIONAL FIELD - 6666|12
ERROR: update_did RECORD CALL MUST BE Y OR N, THIS IS AN OPTIONAL FIELD - 6666|
ERROR: update_did EXTENSION MUST BE FROM 1 TO 50 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|
ERROR: update_did EXTENSION CONTEXT MUST BE FROM 1 TO 50 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|
ERROR: update_did VOICEMAIL EXTENSION MUST BE FROM 1 TO 10 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|
ERROR: update_did PHONE EXTENSION MUST BE FROM 1 TO 100 CHARACTERS, THIS IS AN OPTIONAL FIELD - 6666|
ERROR: update_did SERVER IP MUST BE A VALID SERVER IN THE SYSTEM, THIS IS AN OPTIONAL FIELD - 6666|0.0.0.0
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 UPDATED - 6666|1101
ERROR: NO FUNCTION SPECIFIED
+4 -3
View File
@@ -126,7 +126,7 @@ $UGreports = 'ALL REPORTS, NONE, Real-Time Main Report, Real-Time Campaign Summa
$Vtables = 'NONE,log_noanswer,did_agent_log,contact_information';
$APIfunctions = 'ALL_FUNCTIONS add_group_alias add_lead add_list add_phone add_phone_alias add_user agent_ingroup_info agent_stats_export agent_status audio_playback blind_monitor call_agent callid_info change_ingroups check_phone_number did_log_export external_add_lead external_dial external_hangup external_pause external_status in_group_status logout moh_list park_call pause_code preview_dial_action ra_call_control recording recording_lookup send_dtmf server_refresh set_timer_action sounds_list st_get_agent_active_lead st_login_log transfer_conference update_fields update_lead update_list update_log_entry update_phone update_phone_alias update_user user_group_status vm_list webphone_url webserver logged_in_agents update_campaigns lead_field_info phone_number_log switch_lead ccc_lead_info lead_status_search call_status_stats calls_in_queue_count';
$APIfunctions = 'ALL_FUNCTIONS add_group_alias add_lead add_list add_phone add_phone_alias add_user agent_ingroup_info agent_stats_export agent_status audio_playback blind_monitor call_agent callid_info change_ingroups check_phone_number did_log_export external_add_lead external_dial external_hangup external_pause external_status in_group_status logout moh_list park_call pause_code preview_dial_action ra_call_control recording recording_lookup send_dtmf server_refresh set_timer_action sounds_list st_get_agent_active_lead st_login_log transfer_conference update_fields update_lead update_list update_log_entry update_phone update_phone_alias update_user user_group_status vm_list webphone_url webserver logged_in_agents update_campaign update_did lead_field_info phone_number_log switch_lead ccc_lead_info lead_status_search call_status_stats calls_in_queue_count';
### BEGIN housecleaning of old static report files, if not done before ###
@@ -4328,12 +4328,13 @@ else
# 180310-2321 - Added source_id_display system option
# 180316-0751 - Translated phrases fixes, issue #1081
# 180330-1425 - Added download of CID Group records feature
# 180331-1715 - Added update_did non-agent API function
#
# 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-666a';
$build = '180330-1425';
$admin_version = '2.14-667a';
$build = '180331-1715';
$STARTtime = date("U");
$SQLdate = date("Y-m-d H:i:s");
+463 -10
View File
@@ -130,10 +130,11 @@
# 180109-1313 - Added call_status_stats function
# 180208-1655 - Added call_dispo_report function
# 180301-2301 - Added GET-AND-POST URL logging
# 180331-1716 - Added options to update_campaign, add_user, update_phone. Added function update_did
#
$version = '2.14-107';
$build = '180301-2301';
$version = '2.14-108';
$build = '180331-1716';
$api_url_log = 0;
$startMS = microtime();
@@ -430,8 +431,8 @@ if (isset($_GET["campaign_name"])) {$campaign_name=$_GET["campaign_name"];}
elseif (isset($_POST["campaign_name"])) {$campaign_name=$_POST["campaign_name"];}
if (isset($_GET["did_ids"])) {$did_ids=$_GET["did_ids"];}
elseif (isset($_POST["did_ids"])) {$did_ids=$_POST["did_ids"];}
if (isset($_GET["did_patterns"])) {$did_patterns=$_GET["did_patterns"];}
elseif (isset($_POST["did_patterns"])) {$did_patterns=$_POST["did_patterns"];}
if (isset($_GET["did_pattern"])) {$did_pattern=$_GET["did_pattern"];}
elseif (isset($_POST["did_pattern"])) {$did_pattern=$_POST["did_pattern"];}
if (isset($_GET["users"])) {$users=$_GET["users"];}
elseif (isset($_POST["users"])) {$users=$_POST["users"];}
if (isset($_GET["auto_dial_level"])) {$auto_dial_level=$_GET["auto_dial_level"];}
@@ -462,6 +463,34 @@ if (isset($_GET["file_download"])) {$file_download=$_GET["file_download"];}
elseif (isset($_POST["file_download"])) {$file_download=$_POST["file_download"];}
if (isset($_GET["force_entry_list_id"])) {$force_entry_list_id=$_GET["force_entry_list_id"];}
elseif (isset($_POST["force_entry_list_id"])) {$force_entry_list_id=$_POST["force_entry_list_id"];}
if (isset($_GET["lead_filter_id"])) {$lead_filter_id=$_GET["lead_filter_id"];}
elseif (isset($_POST["lead_filter_id"])) {$lead_filter_id=$_POST["lead_filter_id"];}
if (isset($_GET["agent_choose_ingroups"])) {$agent_choose_ingroups=$_GET["agent_choose_ingroups"];}
elseif (isset($_POST["agent_choose_ingroups"])) {$agent_choose_ingroups=$_POST["agent_choose_ingroups"];}
if (isset($_GET["agent_choose_blended"])) {$agent_choose_blended=$_GET["agent_choose_blended"];}
elseif (isset($_POST["agent_choose_blended"])) {$agent_choose_blended=$_POST["agent_choose_blended"];}
if (isset($_GET["closer_default_blended"])) {$closer_default_blended=$_GET["closer_default_blended"];}
elseif (isset($_POST["closer_default_blended"])) {$closer_default_blended=$_POST["closer_default_blended"];}
if (isset($_GET["outbound_alt_cid"])) {$outbound_alt_cid=$_GET["outbound_alt_cid"];}
elseif (isset($_POST["outbound_alt_cid"])) {$outbound_alt_cid=$_POST["outbound_alt_cid"];}
if (isset($_GET["phone_ring_timeout"])) {$phone_ring_timeout=$_GET["phone_ring_timeout"];}
elseif (isset($_POST["phone_ring_timeout"])) {$phone_ring_timeout=$_POST["phone_ring_timeout"];}
if (isset($_GET["delete_vm_after_email"])) {$delete_vm_after_email=$_GET["delete_vm_after_email"];}
elseif (isset($_POST["delete_vm_after_email"])) {$delete_vm_after_email=$_POST["delete_vm_after_email"];}
if (isset($_GET["did_description"])) {$did_description=$_GET["did_description"];}
elseif (isset($_POST["did_description"])) {$did_description=$_POST["did_description"];}
if (isset($_GET["did_route"])) {$did_route=$_GET["did_route"];}
elseif (isset($_POST["did_route"])) {$did_route=$_POST["did_route"];}
if (isset($_GET["record_call"])) {$record_call=$_GET["record_call"];}
elseif (isset($_POST["record_call"])) {$record_call=$_POST["record_call"];}
if (isset($_GET["exten_context"])) {$exten_context=$_GET["exten_context"];}
elseif (isset($_POST["exten_context"])) {$exten_context=$_POST["exten_context"];}
if (isset($_GET["voicemail_ext"])) {$voicemail_ext=$_GET["voicemail_ext"];}
elseif (isset($_POST["voicemail_ext"])) {$voicemail_ext=$_POST["voicemail_ext"];}
if (isset($_GET["phone_extension"])) {$phone_extension=$_GET["phone_extension"];}
elseif (isset($_POST["phone_extension"])) {$phone_extension=$_POST["phone_extension"];}
if (isset($_GET["filter_clean_cid_number"])) {$filter_clean_cid_number=$_GET["filter_clean_cid_number"];}
elseif (isset($_POST["filter_clean_cid_number"])) {$filter_clean_cid_number=$_POST["filter_clean_cid_number"];}
header ("Content-type: text/html; charset=utf-8");
@@ -504,7 +533,6 @@ if ($non_latin < 1)
$status_breakdown = preg_replace('/[^1Y]/','',$status_breakdown);
$show_percentages = preg_replace('/[^1Y]/','',$show_percentages);
$DB=preg_replace('/[^0-9]/','',$DB);
$user=preg_replace('/[^-_0-9a-zA-Z]/','',$user);
$pass=preg_replace('/[^-_0-9a-zA-Z]/','',$pass);
@@ -661,6 +689,21 @@ if ($non_latin < 1)
$type = preg_replace('/[^A-Z]/','',$type);
$force_entry_list_id = preg_replace('/[^0-9]/','',$force_entry_list_id);
$file_download = preg_replace('/[^0-9]/','',$file_download);
$lead_filter_id = preg_replace('/[^-_0-9a-zA-Z]/','',$lead_filter_id);
$agent_choose_ingroups = preg_replace('/[^0-9]/','',$agent_choose_ingroups);
$agent_choose_blended = preg_replace('/[^0-9]/','',$agent_choose_blended);
$closer_default_blended = preg_replace('/[^0-9]/','',$closer_default_blended);
$outbound_alt_cid = preg_replace('/[^0-9a-zA-Z]/','',$outbound_alt_cid);
$phone_ring_timeout = preg_replace('/[^0-9]/','',$phone_ring_timeout);
$delete_vm_after_email = preg_replace('/[^a-zA-Z]/','',$delete_vm_after_email);
$did_pattern = preg_replace('/[^:\+\*\#\.\_0-9a-zA-Z]/','',$did_pattern);
$did_description = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$did_description);
$did_route = preg_replace('/[^-_0-9a-zA-Z]/','',$did_route);
$record_call = preg_replace('/[^-_0-9a-zA-Z]/','',$record_call);
$exten_context = preg_replace('/[^-_0-9a-zA-Z]/','',$exten_context);
$voicemail_ext = preg_replace('/[^\*\#\.\_0-9a-zA-Z]/','',$voicemail_ext);
$extension = preg_replace('/[^-\*\#\.\:\/\@\_0-9a-zA-Z]/','',$extension);
$filter_clean_cid_number = preg_replace('/[^- \.\,\_0-9a-zA-Z]/','',$filter_clean_cid_number);
}
else
{
@@ -2057,6 +2100,9 @@ if ($function == 'add_user')
if (strlen($hotkeys_active)<1) {$hotkeys_active='0';}
if (strlen($wrapup_seconds_override)<1) {$wrapup_seconds_override='-1';}
if (strlen($agent_choose_ingroups)<1) {$agent_choose_ingroups='1';}
if (strlen($agent_choose_blended)<1) {$agent_choose_blended='1';}
if (strlen($closer_default_blended)<1) {$closer_default_blended='0';}
$pass_hash='';
if ( ($SSpass_hash_enabled > 0) and (strlen($agent_pass) > 1) )
@@ -2067,7 +2113,13 @@ if ($function == 'add_user')
$agent_pass='';
}
$stmt="INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,phone_login,phone_pass,hotkeys_active,voicemail_id,email,custom_one,custom_two,custom_three,custom_four,custom_five,pass_hash,wrapup_seconds_override) values('$agent_user','$agent_pass','$agent_full_name','$agent_user_level','$agent_user_group','$phone_login','$phone_pass','$hotkeys_active','$voicemail_id','$email','$custom_one','$custom_two','$custom_three','$custom_four','$custom_five','$pass_hash','$wrapup_seconds_override');";
if (strlen($in_groups) > 0)
{
$in_groups = preg_replace("/\|/"," ",$in_groups);
$in_groups = " ".$in_groups." -";
}
$stmt="INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,phone_login,phone_pass,hotkeys_active,voicemail_id,email,custom_one,custom_two,custom_three,custom_four,custom_five,pass_hash,wrapup_seconds_override,agent_choose_ingroups,agent_choose_blended,closer_default_blended,closer_campaigns) values('$agent_user','$agent_pass','$agent_full_name','$agent_user_level','$agent_user_group','$phone_login','$phone_pass','$hotkeys_active','$voicemail_id','$email','$custom_one','$custom_two','$custom_three','$custom_four','$custom_five','$pass_hash','$wrapup_seconds_override','$agent_choose_ingroups','$agent_choose_blended','$closer_default_blended','$in_groups');";
$rslt=mysql_to_mysqli($stmt, $link);
### LOG INSERTION Admin Log Table ###
@@ -3068,6 +3120,9 @@ if ($function == 'update_phone')
$emailSQL='';
$local_gmtSQL='';
$admin_user_groupSQL='';
$outbound_alt_cidSQL='';
$phone_ring_timeoutSQL='';
$delete_vm_after_emailSQL='';
if (strlen($local_gmt) > 0)
{
@@ -3089,7 +3144,7 @@ if ($function == 'update_phone')
{$emailSQL = " ,email=''";}
else
{
if ( (strlen($email) > 300) or (strlen($email) < 4) )
if ( (strlen($email) > 300) or (strlen($email) < 5) )
{
$result = 'ERROR';
$result_reason = "update_phone YOU MUST USE A VALID EMAIL";
@@ -3280,9 +3335,56 @@ if ($function == 'update_phone')
else
{$admin_user_groupSQL = " ,user_group='$admin_user_group'";}
}
if (strlen($outbound_alt_cid) > 0)
{
if ($outbound_alt_cid == '--BLANK--')
{$outbound_alt_cidSQL = " ,outbound_alt_cid=''";}
else
{
if ( (strlen($outbound_alt_cid) > 18) or (strlen($outbound_alt_cid) < 6) )
{
$result = 'ERROR';
$result_reason = "update_phone OUTBOUND ALT CID MUST BE FROM 6 TO 18 DIGITS, THIS IS AN OPTIONAL FIELD";
$data = "$outbound_alt_cid";
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
{$outbound_alt_cidSQL = " ,outbound_alt_cid='$outbound_alt_cid'";}
}
}
if (strlen($phone_ring_timeout) > 0)
{
if ( ($phone_ring_timeout > 180) or ($phone_ring_timeout < 2) )
{
$result = 'ERROR';
$result_reason = "update_phone PHONE RING TIMEOUT MUST BE FROM 2 TO 180 SECONDS, THIS IS AN OPTIONAL FIELD";
$data = "$outbound_alt_cid";
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
{$phone_ring_timeoutSQL = " ,phone_ring_timeout='$phone_ring_timeout'";}
}
if (strlen($delete_vm_after_email) > 0)
{
if ( ($delete_vm_after_email != 'N') and ($delete_vm_after_email != 'Y') )
{
$result = 'ERROR';
$result_reason = "update_phone DELETE VOICEMAIL AFTER EMAIL MUST BE Y OR N, THIS IS AN OPTIONAL FIELD";
$data = "$delete_vm_after_email";
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
{$delete_vm_after_emailSQL = " ,delete_vm_after_email='$delete_vm_after_email'";}
}
$updateSQL = "$dialplan_numberSQL$activeSQL$outboundcidSQL$voicemail_idSQL$phone_loginSQL$phone_passSQL$protocolSQL$registration_passwordSQL$phone_full_nameSQL$phone_contextSQL$emailSQL$local_gmtSQL$admin_user_groupSQL";
$updateSQL = "$dialplan_numberSQL$activeSQL$outboundcidSQL$voicemail_idSQL$phone_loginSQL$phone_passSQL$protocolSQL$registration_passwordSQL$phone_full_nameSQL$phone_contextSQL$emailSQL$local_gmtSQL$admin_user_groupSQL$outbound_alt_cidSQL$phone_ring_timeoutSQL$delete_vm_after_emailSQL";
if (strlen($updateSQL)< 3)
@@ -4529,6 +4631,8 @@ if ($function == 'update_campaign')
$hopperlevelSQL='';
$dialtimeoutSQL='';
$campaignnameSQL='';
$campaigncidSQL='';
$campaignfilterSQL='';
$activeSQL='';
$autodiallevelSQL='';
@@ -4548,7 +4652,7 @@ if ($function == 'update_campaign')
}
if (strlen($dial_method) > 0)
{
if (preg_match("/MANUAL|RATIO|INBOUND_MAN|ADAPT_AVERAGE|ADAPT_HARD_LIMIT|ADAPT_TAPERED/",$dial_method))
if (preg_match("/^MANUAL$|^RATIO$|^INBOUND_MAN$|^ADAPT_AVERAGE$|^ADAPT_HARD_LIMIT$|^ADAPT_TAPERED$/",$dial_method))
{$dialmethodSQL = " ,dial_method='$dial_method'";}
else
{
@@ -4630,6 +4734,43 @@ if ($function == 'update_campaign')
else
{$campaignnameSQL = " ,campaign_name='$campaign_name'";}
}
if (strlen($outbound_cid) > 0)
{
if ( (strlen($outbound_cid) > 20) or (strlen($outbound_cid) < 6) )
{
$result = 'ERROR';
$result_reason = "update_campaign CAMPAIGN CID MUST BE FROM 6 TO 20 CHARACTERS, THIS IS AN OPTIONAL FIELD";
$data = "$outbound_cid";
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
{$campaigncidSQL = " ,campaign_cid='$outbound_cid'";}
}
if (strlen($lead_filter_id) > 0)
{
if ($lead_filter_id == '---NONE---')
{$lead_filter_id='';}
else
{
$stmt="SELECT count(*) from vicidial_lead_filters where lead_filter_id='$lead_filter_id';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$filter_exists=$row[0];
if ($filter_exists < 1)
{
$result = 'ERROR';
$result_reason = "update_campaign CAMPAIGN LEAD FILTER MUST BE A VALID FILTER IN THE SYSTEM, THIS IS AN OPTIONAL FIELD";
$data = "$lead_filter_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;
}
}
$campaignfilterSQL = " ,lead_filter_id='$lead_filter_id'";
}
if (strlen($active) > 0)
{
if ( ($active != 'Y') and ($active != 'N') )
@@ -4645,7 +4786,7 @@ if ($function == 'update_campaign')
{$activeSQL = " ,active='$active'";}
}
$updateSQL = "$campaignnameSQL$activeSQL$dialtimeoutSQL$hopperlevelSQL$campaignvdadextenSQL$adaptivemaximumlevelSQL$dialmethodSQL$autodiallevelSQL";
$updateSQL = "$campaignnameSQL$activeSQL$dialtimeoutSQL$hopperlevelSQL$campaignvdadextenSQL$adaptivemaximumlevelSQL$dialmethodSQL$autodiallevelSQL$campaigncidSQL$campaignfilterSQL";
if (strlen($updateSQL)< 3)
{
@@ -4710,6 +4851,318 @@ if ($function == 'update_campaign')
################################################################################
### update_did - updates Inbound DID information in the vicidial_inbound_dids table
################################################################################
if ($function == 'update_did')
{
if(strlen($source)<2)
{
$result = 'ERROR';
$result_reason = "Invalid Source";
echo "$result: $result_reason - $source\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
echo "ERROR: Invalid Source: |$source|\n";
exit;
}
else
{
if ( (!preg_match("/ $function /",$api_allowed_functions)) and (!preg_match("/ALL_FUNCTIONS/",$api_allowed_functions)) )
{
$result = 'ERROR';
$result_reason = "auth USER DOES NOT HAVE PERMISSION TO USE THIS FUNCTION";
echo "$result: $result_reason: |$user|$function|\n";
$data = "$allowed_user";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
exit;
}
$stmt="SELECT count(*) from vicidial_users where user='$user' and vdc_agent_api_access='1' and modify_inbound_dids='1' and user_level >= 8 and active='Y';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$allowed_user=$row[0];
if ($allowed_user < 1)
{
$result = 'ERROR';
$result_reason = "update_did USER DOES NOT HAVE PERMISSION TO UPDATE 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
{
if ( (strlen($did_pattern)<2) or (strlen($did_pattern)>50) )
{
$result = 'ERROR';
$result_reason = "update_did YOU MUST USE ALL REQUIRED FIELDS";
$data = "$did_pattern";
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 allowed_campaigns,admin_viewable_groups from vicidial_user_groups where user_group='$LOGuser_group';";
if ($DB>0) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$LOGallowed_campaigns = $row[0];
$LOGadmin_viewable_groups = $row[1];
$admin_viewable_groupsSQL='';
$WHEREadmin_viewable_groupsSQL='';
if (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups))
{
$rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups);
$rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL);
$admin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')";
$WHEREadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')";
}
$stmt="SELECT count(*) from vicidial_inbound_dids where did_pattern='$did_pattern' $admin_viewable_groupsSQL;";
if ($DB>0) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$did_exists=$row[0];
if ($did_exists < 1)
{
$result = 'ERROR';
$result_reason = "update_did DID DOES NOT EXIST";
$data = "$did_pattern";
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 did_id from vicidial_inbound_dids where did_pattern='$did_pattern' $admin_viewable_groupsSQL;";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$did_id=$row[0];
$did_descriptionSQL='';
$activeSQL='';
$did_routeSQL='';
$record_callSQL='';
$extensionSQL='';
$exten_contextSQL='';
$voicemail_extSQL='';
$phone_extensionSQL='';
$server_ipSQL='';
$groupSQL='';
$filter_clean_cid_numberSQL='';
if (strlen($did_description) > 0)
{
if ( (strlen($did_description) > 50) or (strlen($did_description) < 6) )
{
$result = 'ERROR';
$result_reason = "update_did DID DESCRIPTION MUST BE FROM 6 TO 50 CHARACTERS, THIS IS AN OPTIONAL FIELD";
$data = "$did_description";
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
{$did_descriptionSQL = " ,did_description='$did_description'";}
}
if (strlen($active) > 0)
{
if ( ($active != 'Y') and ($active != 'N') )
{
$result = 'ERROR';
$result_reason = "update_did ACTIVE MUST BE Y OR N, THIS IS AN OPTIONAL FIELD";
$data = "$active";
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
{$activeSQL = " ,did_active='$active'";}
}
if (strlen($did_route) > 0)
{
if (preg_match("/^EXTEN$|^VOICEMAIL$|^AGENT$|^PHONE$|^IN_GROUP$|^CALLMENU$|^VMAIL_NO_INST$/",$did_route))
{$did_routeSQL = " ,did_route='$did_route'";}
else
{
$result = 'ERROR';
$result_reason = "update_did DID ROUTE IS NOT VALID, THIS IS AN OPTIONAL FIELD";
$data = "$did_route";
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($record_call) > 0)
{
if ( ($record_call != 'Y') and ($record_call != 'N') and ($record_call != 'Y_QUEUESTOP') )
{
$result = 'ERROR';
$result_reason = "update_did RECORD CALL MUST BE Y OR N, THIS IS AN OPTIONAL FIELD";
$data = "$record_call";
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
{$record_callSQL = " ,record_call='$record_call'";}
}
if (strlen($extension) > 0)
{
if (strlen($extension) > 50)
{
$result = 'ERROR';
$result_reason = "update_did EXTENSION MUST BE FROM 1 TO 50 CHARACTERS, THIS IS AN OPTIONAL FIELD";
$data = "$extension";
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
{$extensionSQL = " ,extension='$extension'";}
}
if (strlen($exten_context) > 0)
{
if (strlen($exten_context) > 50)
{
$result = 'ERROR';
$result_reason = "update_did EXTENSION CONTEXT MUST BE FROM 1 TO 50 CHARACTERS, THIS IS AN OPTIONAL FIELD";
$data = "$exten_context";
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
{$exten_contextSQL = " ,exten_context='$exten_context'";}
}
if (strlen($voicemail_ext) > 0)
{
if ( (strlen($voicemail_ext) > 10) or (strlen($voicemail_ext) < 1) )
{
$result = 'ERROR';
$result_reason = "update_did VOICEMAIL EXTENSION MUST BE FROM 1 TO 10 CHARACTERS, THIS IS AN OPTIONAL FIELD";
$data = "$voicemail_ext";
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
{$voicemail_extSQL = " ,voicemail_ext='$voicemail_ext'";}
}
if (strlen($phone_extension) > 0)
{
if ( (strlen($phone_extension) > 100) or (strlen($phone_extension) < 1) )
{
$result = 'ERROR';
$result_reason = "update_did PHONE EXTENSION MUST BE FROM 1 TO 100 CHARACTERS, THIS IS AN OPTIONAL FIELD";
$data = "$phone_extension";
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
{$phone_extensionSQL = " ,phone='$phone_extension'";}
}
if (strlen($server_ip) > 0)
{
$stmt="SELECT count(*) from servers where server_ip='$server_ip';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$server_exists=$row[0];
if ($server_exists < 1)
{
$result = 'ERROR';
$result_reason = "update_did SERVER IP MUST BE A VALID SERVER IN THE SYSTEM, THIS IS AN OPTIONAL FIELD";
$data = "$server_ip";
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;
}
$server_ipSQL = " ,server_ip='$server_ip'";
}
if (strlen($group) > 0)
{
$stmt="SELECT count(*) from vicidial_inbound_groups where group_id='$group';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$group_exists=$row[0];
if ($group_exists < 1)
{
$result = 'ERROR';
$result_reason = "update_did GROUP ID MUST BE A VALID INBOUND GROUP IN THE SYSTEM, THIS IS AN OPTIONAL FIELD";
$data = "$group";
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;
}
$groupSQL = " ,group_id='$group'";
}
if (strlen($filter_clean_cid_number) > 0)
{
if ( (strlen($filter_clean_cid_number) > 20) or (strlen($filter_clean_cid_number) < 1) )
{
$result = 'ERROR';
$result_reason = "update_did CLEAN CID NUMBER MUST BE FROM 1 TO 20 CHARACTERS, THIS IS AN OPTIONAL FIELD";
$data = "$filter_clean_cid_number";
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
{$filter_clean_cid_numberSQL = " ,filter_clean_cid_number='$filter_clean_cid_number'";}
}
$updateSQL = "$did_descriptionSQL$activeSQL$did_routeSQL$record_callSQL$extensionSQL$exten_contextSQL$voicemail_extSQL$phone_extensionSQL$server_ipSQL$groupSQL$filter_clean_cid_numberSQL";
if (strlen($updateSQL)< 3)
{
$result = 'NOTICE';
$result_reason = "update_did NO UPDATES DEFINED";
$data = "$updateSQL";
echo "$result: $result_reason: |$user|$data\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}
else
{
$updateSQL = preg_replace("/^ ,/",'',$updateSQL);
$stmt="UPDATE vicidial_inbound_dids SET $updateSQL WHERE did_pattern='$did_pattern';";
$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='MODIFY', record_id='$did_id', event_code='ADMIN API UPDATE 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 UPDATED";
$data = "$did_pattern";
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;
}
################################################################################
### END update_did
################################################################################
################################################################################
### recording_lookup - looks up recordings based upon user and date or lead_id
################################################################################