Added update_remote_agent Non-Agent API function

git-svn-id: svn://192.168.202.10@3843 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2024-07-03 22:55:18 +00:00
parent bd2291e949
commit ad3ca0ade7
3 changed files with 282 additions and 11 deletions
+37 -1
View File
@@ -1,4 +1,4 @@
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2024-03-02 NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2024-07-03
This document describes the functions of an API(Application Programming This document describes the functions of an API(Application Programming
Interface) for all functions NOT directly relating to the VICIDIAL Agent screen. Interface) for all functions NOT directly relating to the VICIDIAL Agent screen.
@@ -67,6 +67,7 @@ hopper_list - displays information about leads in the hopper for a campaign
update_alt_url - updates/adds/displays alternate dispo call url entries for a campaign update_alt_url - updates/adds/displays alternate dispo call url entries for a campaign
update_presets - updates/adds/displays/deletes campaign preset entries update_presets - updates/adds/displays/deletes campaign preset entries
lead_dearchive - moves a lead from the archive to active leads table lead_dearchive - moves a lead from the archive to active leads table
update_remote_agent - updates some remote agent settings in the system
New scripts: New scripts:
@@ -219,6 +220,7 @@ Changes:
240120-0840 - Added list_order,list_order_randomize,list_order_secondary optional fields to update_campaign function 240120-0840 - Added list_order,list_order_randomize,list_order_secondary optional fields to update_campaign function
240217-0907 - Added more missing vicidial_users fields from copy function 240217-0907 - Added more missing vicidial_users fields from copy function
240302-0804 - Added delete_dnc_phone function 240302-0804 - Added delete_dnc_phone function
240703-1657 - Added update_remote_agent function
API Functions use the 'function' variable API Functions use the 'function' variable
@@ -1556,6 +1558,40 @@ SUCCESS: update_user USER HAS BEEN DELETED - 6666|7878
--------------------------------------------------------------------------------
update_remote_agent - updates remote agent entry in the system
NOTE: api user for this function must have user_level set to 8 or higher and "modify remote agents" enabled
REQUIRED FIELDS-
agent_user - 2-20 characters
OPTIONAL FIELDS-
status - 'ACTIVE' or 'INACTIVE' only
campaign_id - 1-8 characters, must be a valid Campaign ID
number_of_lines - 1-20 digits
Example URL strings for API calls:
http://server/vicidial/non_agent_api.php?source=test&function=update_remote_agent&user=6666&pass=1234&agent_user=2424&number_of_lines=1&campaign_id=TESTCAMP
http://server/vicidial/non_agent_api.php?source=test&function=update_remote_agent&user=6666&pass=1234&agent_user=2424&status=INACTIVE
Example responses:
ERROR: update_remote_agent USER DOES NOT HAVE PERMISSION TO UPDATE REMOTE AGENTS - 6666|0
ERROR: update_remote_agent YOU MUST USE ALL REQUIRED FIELDS - 6666||
ERROR: update_remote_agent REMOTE AGENT DOES NOT EXIST - 6666|78789
ERROR: update_remote_agent USER DOES NOT HAVE PERMISSION TO UPDATE THIS REMOTE AGENT - 6666
ERROR: update_remote_agent YOU MUST USE A VALID NUMBER OF LINES, THIS IS AN OPTIONAL FIELD - 6666|0
ERROR: update_remote_agent YOU MUST USE A VALID CAMPAIGN ID, THIS IS AN OPTIONAL FIELD - 6666|TEST|0
ERROR: update_remote_agent STATUS MUST BE ACTIVE OR INACTIVE, THIS IS AN OPTIONAL FIELD - 6666|Y
ERROR: update_remote_agent NO UPDATES DEFINED - 6666|0
NOTICE: update_remote_agent REMOTE AGENT IS ALREADY ACTIVE - 6666|7878
NOTICE: update_remote_agent REMOTE AGENT IS ALREADY INACTIVE - 6666|7878
SUCCESS: update_remote_agent USER HAS BEEN UPDATED - 6666|7878
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
add_group_alias - adds group alias to the system add_group_alias - adds group alias to the system
+4 -3
View File
@@ -131,7 +131,7 @@ $UGreports = 'ALL REPORTS, NONE, Real-Time Main Report, Real-Time Campaign Summa
$Vtables = 'NONE,log_noanswer,did_agent_log,contact_information'; $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 copy_user did_log_export external_add_lead external_dial external_hangup external_pause external_status in_group_status logout moh_list ingroup_list campaigns_list callmenu_list hopper_list call_dispo_report agent_campaigns 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 batch_update_lead update_list list_info list_custom_fields update_log_entry update_phone update_phone_alias update_user user_group_status vm_list vm_message webphone_url webserver logged_in_agents update_campaign update_alt_url update_presets add_did update_did lead_field_info lead_all_info lead_callback_info phone_number_log switch_lead ccc_lead_info lead_status_search lead_search lead_dearchive call_status_stats calls_in_queue_count force_fronter_leave_3way force_fronter_audio_stop update_cid_group_entry add_dnc_phone delete_dnc_phone add_fpg_phone send_notification refresh_panel'; $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 copy_user did_log_export external_add_lead external_dial external_hangup external_pause external_status in_group_status logout moh_list ingroup_list campaigns_list callmenu_list hopper_list call_dispo_report agent_campaigns 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 batch_update_lead update_list list_info list_custom_fields update_log_entry update_phone update_phone_alias update_user user_group_status vm_list vm_message webphone_url webserver logged_in_agents update_campaign update_alt_url update_presets add_did update_did lead_field_info lead_all_info lead_callback_info phone_number_log switch_lead ccc_lead_info lead_status_search lead_search lead_dearchive call_status_stats calls_in_queue_count force_fronter_leave_3way force_fronter_audio_stop update_cid_group_entry add_dnc_phone delete_dnc_phone add_fpg_phone send_notification refresh_panel update_remote_agent';
$browser_alert_sounds_list = 'bark_dog,beep_double,beep_five,beep_up,bell_double,bell_school,bird,blaster1,blaster2,buzz1,buzz2,cash_register,chat_alert,click_single,click_double,click_quiet,close_encounter,confirmation,ding,droplet,droplet_double,elephant,email_alert,hold_tone,horn_bike,horn_car,horn_car_triple,horn_clown,horn_double,horn_train,meow_cat,scream_wilhelm,silence_quick,siren,slide_down,slide_up,swish,teleport1,teleport2,ticking_two,ticking_four,ticking_six,whip,whistle_up,whistle_two,whistle_three,whoosh,xylophone1,xylophone2,xylophone3,xylophone4,20Hz_tone'; $browser_alert_sounds_list = 'bark_dog,beep_double,beep_five,beep_up,bell_double,bell_school,bird,blaster1,blaster2,buzz1,buzz2,cash_register,chat_alert,click_single,click_double,click_quiet,close_encounter,confirmation,ding,droplet,droplet_double,elephant,email_alert,hold_tone,horn_bike,horn_car,horn_car_triple,horn_clown,horn_double,horn_train,meow_cat,scream_wilhelm,silence_quick,siren,slide_down,slide_up,swish,teleport1,teleport2,ticking_two,ticking_four,ticking_six,whip,whistle_up,whistle_two,whistle_three,whoosh,xylophone1,xylophone2,xylophone3,xylophone4,20Hz_tone';
@@ -6155,12 +6155,13 @@ if ($SSscript_remove_js > 0)
# 240528-1722 - Added display of Dial Prefixes column on the CAMPAIGH LISTINGS page # 240528-1722 - Added display of Dial Prefixes column on the CAMPAIGH LISTINGS page
# 240617-0833 - Fix for 2FA user override # 240617-0833 - Fix for 2FA user override
# 240627-1950 - Added leave_3way_stop_recording campaign setting # 240627-1950 - Added leave_3way_stop_recording campaign setting
# 240703-1758 - Added update_remote_agent 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 # 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-920a'; $admin_version = '2.14-921a';
$build = '240627-1950'; $build = '240703-1758';
$STARTtime = date("U"); $STARTtime = date("U");
$SQLdate = date("Y-m-d H:i:s"); $SQLdate = date("Y-m-d H:i:s");
+241 -7
View File
@@ -211,10 +211,11 @@
# 240217-0907 - Added more missing vicidial_users fields from copy function # 240217-0907 - Added more missing vicidial_users fields from copy function
# 240302-0804 - Added delete_dnc_phone function # 240302-0804 - Added delete_dnc_phone function
# 240420-2236 - Added ConfBridge code # 240420-2236 - Added ConfBridge code
# 240703-1657 - Added update_remote_agent function
# #
$version = '2.14-188'; $version = '2.14-189';
$build = '240420-2236'; $build = '240703-1657';
$php_script='non_agent_api.php'; $php_script='non_agent_api.php';
$api_url_log = 0; $api_url_log = 0;
$camp_lead_order_random=1; $camp_lead_order_random=1;
@@ -733,6 +734,8 @@ if (isset($_GET["list_order_randomize"])) {$list_order_randomize=$_GET["list_o
elseif (isset($_POST["list_order_randomize"])) {$list_order_randomize=$_POST["list_order_randomize"];} elseif (isset($_POST["list_order_randomize"])) {$list_order_randomize=$_POST["list_order_randomize"];}
if (isset($_GET["list_order_secondary"])) {$list_order_secondary=$_GET["list_order_secondary"];} if (isset($_GET["list_order_secondary"])) {$list_order_secondary=$_GET["list_order_secondary"];}
elseif (isset($_POST["list_order_secondary"])) {$list_order_secondary=$_POST["list_order_secondary"];} elseif (isset($_POST["list_order_secondary"])) {$list_order_secondary=$_POST["list_order_secondary"];}
if (isset($_GET["number_of_lines"])) {$number_of_lines=$_GET["number_of_lines"];}
elseif (isset($_POST["number_of_lines"])) {$number_of_lines=$_POST["number_of_lines"];}
$DB=preg_replace('/[^0-9]/','',$DB); $DB=preg_replace('/[^0-9]/','',$DB);
@@ -892,6 +895,7 @@ $archived_lead = preg_replace('/[^0-9a-zA-Z]/','',$archived_lead);
$list_order = preg_replace('/[^ 0-9a-zA-Z]/','',$list_order); $list_order = preg_replace('/[^ 0-9a-zA-Z]/','',$list_order);
$list_order_randomize = preg_replace('/[^-_0-9a-zA-Z]/','',$list_order_randomize); $list_order_randomize = preg_replace('/[^-_0-9a-zA-Z]/','',$list_order_randomize);
$list_order_secondary = preg_replace('/[^-_0-9a-zA-Z]/','',$list_order_secondary); $list_order_secondary = preg_replace('/[^-_0-9a-zA-Z]/','',$list_order_secondary);
$number_of_lines = preg_replace('/[^0-9]/','',$number_of_lines);
if ($non_latin < 1) if ($non_latin < 1)
{ {
@@ -3916,6 +3920,7 @@ if ($function == 'copy_user')
################################################################################ ################################################################################
### update_user - updates user entry already in the system ### update_user - updates user entry already in the system
################################################################################ ################################################################################
@@ -4644,6 +4649,240 @@ if ($function == 'update_user')
################################################################################
### update_remote_agent - updates remote agent entry already in the system
################################################################################
if ($function == 'update_remote_agent')
{
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_remoteagents='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_remote_agent USER DOES NOT HAVE PERMISSION TO UPDATE REMOTE AGENTS";
$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($agent_user)<2) or (strlen($agent_user)>20) )
{
$result = 'ERROR';
$result_reason = "update_remote_agent YOU MUST USE ALL REQUIRED FIELDS";
$data = "$agent_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="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];
$LOGadmin_viewable_groupsSQL='';
$whereLOGadmin_viewable_groupsSQL='';
if ( (!preg_match('/\-\-ALL\-\-/i',$LOGadmin_viewable_groups)) and (strlen($LOGadmin_viewable_groups) > 3) )
{
$rawLOGadmin_viewable_groupsSQL = preg_replace("/ -/",'',$LOGadmin_viewable_groups);
$rawLOGadmin_viewable_groupsSQL = preg_replace("/ /","','",$rawLOGadmin_viewable_groupsSQL);
$LOGadmin_viewable_groupsSQL = "and user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')";
$whereLOGadmin_viewable_groupsSQL = "where user_group IN('---ALL---','$rawLOGadmin_viewable_groupsSQL')";
}
$LOGallowed_campaignsSQL='';
$whereLOGallowed_campaignsSQL='';
if ( (!preg_match('/\-ALL/i', $LOGallowed_campaigns)) )
{
$rawLOGallowed_campaignsSQL = preg_replace("/ -/",'',$LOGallowed_campaigns);
$rawLOGallowed_campaignsSQL = preg_replace("/ /","','",$rawLOGallowed_campaignsSQL);
$LOGallowed_campaignsSQL = "and campaign_id IN('$rawLOGallowed_campaignsSQL')";
$whereLOGallowed_campaignsSQL = "where campaign_id IN('$rawLOGallowed_campaignsSQL')";
}
$stmt="SELECT count(*) from vicidial_remote_agents where user_start='$agent_user';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$user_exists=$row[0];
if ($user_exists < 1)
{
$result = 'ERROR';
$result_reason = "update_remote_agent REMOTE AGENT DOES NOT EXIST";
$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;
}
else
{
$user_level_modify_gt='<=';
$stmt="SELECT user_level,modify_same_user_level from vicidial_users where user='$user';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$api_user_level = $row[0];
$api_modify_same_user_level = $row[1];
if ($api_modify_same_user_level < 1)
{$user_level_modify_gt='<';}
$stmt="SELECT count(*) from vicidial_users where user='$agent_user' and user_level $user_level_modify_gt '$api_user_level' $LOGadmin_viewable_groupsSQL;";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$agent_allowed=$row[0];
if ($agent_allowed < 1)
{
$result = 'ERROR';
$result_reason = "update_remote_agent USER DOES NOT HAVE PERMISSION TO UPDATE THIS REMOTE AGENT";
$data = "$agent_user|$user_level_modify_gt|$api_user_level\n";
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
{
$statusSQL='';
$campaign_idSQL='';
$number_of_linesSQL='';
if (strlen($number_of_lines) > 0)
{
if ( ($number_of_lines > 999) or ($number_of_lines < 1) )
{
$result = 'ERROR';
$result_reason = "update_remote_agent YOU MUST USE A VALID NUMBER OF LINES, THIS IS AN OPTIONAL FIELD";
$data = "$number_of_lines";
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
{$number_of_linesSQL = " ,number_of_lines='$number_of_lines'";}
}
if (strlen($campaign_id) > 0)
{
$stmt="SELECT count(*) from vicidial_campaigns where campaign_id='$campaign_id' $LOGallowed_campaignsSQL;";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$valid_campaign = $row[0];
if ( (strlen($campaign_id) > 8) or (strlen($campaign_id) < 1) or ($valid_campaign < 1) )
{
$result = 'ERROR';
$result_reason = "update_remote_agent YOU MUST USE A VALID CAMPAIGN ID, THIS IS AN OPTIONAL FIELD";
$data = "$campaign_id|$valid_campaign";
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
{$campaign_idSQL = " ,campaign_id='$campaign_id'";}
}
if (strlen($status) > 0)
{
if (!preg_match("/ACTIVE|INACTIVE/",$status))
{
$result = 'ERROR';
$result_reason = "update_remote_agent STATUS MUST BE ACTIVE OR INACTIVE, THIS IS AN OPTIONAL FIELD";
$data = "$status";
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_remote_agents where user_start='$agent_user' and status='$status';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$agent_status=$row[0];
if ($agent_status > 0)
{
$result = 'NOTICE';
$result_reason = "update_remote_agent REMOTE AGENT IS ALREADY $status";
$data = "$agent_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);
}
else
{$statusSQL = " ,status='$status'";}
}
}
$updateSQL = "$number_of_linesSQL$campaign_idSQL$statusSQL";
$updateSQL = preg_replace("/^ ,/",'',$updateSQL);
if (strlen($updateSQL)< 3)
{
$result = 'ERROR';
$result_reason = "update_remote_agent 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);
exit;
}
else
{
$stmt="UPDATE vicidial_remote_agents SET $updateSQL WHERE user_start='$agent_user';";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "|$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='REMOTEAGENTS', event_type='MODIFY', record_id='$agent_user', event_code='ADMIN API UPDATE REMOTEAGENTS', event_sql=\"$SQL_log\", event_notes='user start: $agent_user';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$result = 'SUCCESS';
$result_reason = "update_remote_agent REMOTE AGENT HAS BEEN UPDATED";
$data = "$agent_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;
}
################################################################################
### END update_remote_agent
################################################################################
################################################################################ ################################################################################
### add_group_alias - adds group alias to the system ### add_group_alias - adds group alias to the system
################################################################################ ################################################################################
@@ -11399,11 +11638,6 @@ if ($function == 'phone_number_log')
################################################################################ ################################################################################
### agent_stats_export - exports agent stats for set time period ### agent_stats_export - exports agent stats for set time period
################################################################################ ################################################################################