Added user_details Non-Agent API function

git-svn-id: svn://192.168.202.10@3866 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2024-08-24 20:44:00 +00:00
parent 852c5ca5c0
commit f0ffe3fcc2
3 changed files with 174 additions and 6 deletions
+31 -1
View File
@@ -1,4 +1,4 @@
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2024-07-30 NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2024-08-24
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.
@@ -69,6 +69,7 @@ update_alt_url - updates/adds/displays alternate dispo call url entries for a ca
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 update_remote_agent - updates some remote agent settings in the system
user_details - display information about one user
New scripts: New scripts:
@@ -225,6 +226,7 @@ Changes:
240718-0942 - Fixes for inconsistencies in documentation and permissions for some functions 240718-0942 - Fixes for inconsistencies in documentation and permissions for some functions
240718-1716 - Added fields to campaigns_list function output 240718-1716 - Added fields to campaigns_list function output
240730-1832 - Changes for PHP8 compatibility, Added copy_did function 240730-1832 - Changes for PHP8 compatibility, Added copy_did function
240824-1626 - Added user_details function
API Functions use the 'function' variable API Functions use the 'function' variable
@@ -720,6 +722,34 @@ NOTE: real_time_sub_status field can consist of: DEAD, DISPO, 3-WAY, PARK, RING,
--------------------------------------------------------------------------------
user_details - display information about one user
NOTE: api user for this function must have user_level set to 7 or higher and "view reports" enabled
REQUIRED FIELDS-
source - description of what originated the API call (maximum 20 characters)
agent_user - 2-20 characters, use only for one user
SETTINGS FIELDS-
stage - the format of the exported data: csv, tab, pipe(default)
header - include a header(YES) or not(NO). This is optional, default is not to include a header
Example URL strings for API calls:
http://server/vicidial/non_agent_api.php?source=test&user=6666&pass=1234&function=user_details&agent_user=1234&stage=csv&header=YES&include_ip=YES
Example responses:
ERROR: user_details USER DOES NOT HAVE PERMISSION TO GET USER DETAILS - 6666|0
ERROR: user_details INVALID SEARCH PARAMETERS - 6666||
ERROR: user_details USER NOT FOUND - 6666||
A SUCCESS response will not show "SUCCESS", but instead will just print the results in the following format:
user,full_name,user_group,user_level,active
11111,test user,ADMIN,6,Y
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
callid_info - information about a call based upon the caller_code or call ID callid_info - information about a call based upon the caller_code or call ID
+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 copy_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'; $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 copy_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 user_details';
$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';
@@ -6190,12 +6190,13 @@ if ($SSscript_remove_js > 0)
# 240716-1453 - Small header fixes # 240716-1453 - Small header fixes
# 240730-1829 - Changes for PHP8 compatibility, added copy_did Non-Agent API function # 240730-1829 - Changes for PHP8 compatibility, added copy_did Non-Agent API function
# 240805-1738 - Added DID listing display filter # 240805-1738 - Added DID listing display filter
# 240824-1629 - Added user_details 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-926a'; $admin_version = '2.14-927a';
$build = '240805-1738'; $build = '240824-1629';
$STARTtime = date("U"); $STARTtime = date("U");
$SQLdate = date("Y-m-d H:i:s"); $SQLdate = date("Y-m-d H:i:s");
+139 -2
View File
@@ -215,10 +215,11 @@
# 240718-0942 - Fixes for inconsistencies in documentation and permissions for some functions # 240718-0942 - Fixes for inconsistencies in documentation and permissions for some functions
# 240718-1716 - Added fields to campaigns_list function output # 240718-1716 - Added fields to campaigns_list function output
# 240730-1832 - Changes for PHP8 compatibility, Added copy_did function # 240730-1832 - Changes for PHP8 compatibility, Added copy_did function
# 240824-1626 - Added user_details function
# #
$version = '2.14-192'; $version = '2.14-193';
$build = '240730-1832'; $build = '240824-1626';
$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;
@@ -12948,6 +12949,142 @@ if ($function == 'agent_status')
################################################################################
### user_details - display information about one user
################################################################################
if ($function == 'user_details')
{
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 view_reports='1' and user_level > 6 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 = "user_details USER DOES NOT HAVE PERMISSION TO GET USER DETAILS";
echo "$result: $result_reason: |$user|$allowed_user|\n";
$data = "$allowed_user";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
exit;
}
else
{
$agent_search_SQL='';
$search_ready=0;
if ( (strlen($agent_user)>0) and (strlen($agent_user)<100) )
{
$agent_search_SQL .= "where user='$agent_user'";
$search_ready++;
}
if ($search_ready < 1)
{
$result = 'ERROR';
$result_reason = "user_details INVALID SEARCH PARAMETERS";
$data = "$user|$agent_user";
echo "$result: $result_reason: $data\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
exit;
}
else
{
$stmt="SELECT admin_viewable_groups from vicidial_user_groups where user_group='$LOGuser_group';";
if ($DB) {$MAIN.="|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$LOGadmin_viewable_groups = $row[0];
$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')";
}
$k=0;
$output='';
$DLset=0;
if ($stage == 'csv')
{$DL = ','; $DLset++;}
if ($stage == 'tab')
{$DL = "\t"; $DLset++;}
if ($stage == 'pipe')
{$DL = '|'; $DLset++;}
if ($DLset < 1)
{$DL='|'; $stage='pipe';}
if (strlen($time_format) < 1)
{$time_format = 'HF';}
if ($header == 'YES')
{
$output .= 'user' . $DL . 'full_name' . $DL . 'user_group' . $DL . 'user_level' . $DL . 'active';
$output .= "\n";
}
$stmt="SELECT full_name,user_group,user_level,active from vicidial_users $agent_search_SQL $LOGadmin_viewable_groupsSQL;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($DB) {echo "$stmt\n";}
$user_to_list = mysqli_num_rows($rslt);
if ($user_to_list > 0)
{
$row=mysqli_fetch_row($rslt);
$full_name = $row[0];
$user_group = $row[1];
$user_level = $row[2];
$active = $row[3];
$output .= "$agent_user$DL$full_name$DL$user_group$DL$user_level$DL$active\n";
echo "$output";
$result = 'SUCCESS';
$data = "$user|$agent_user|$stage";
$result_reason = "user_details $output";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
}
else
{
$result = 'ERROR';
$result_reason = "user_details USER NOT FOUND";
$data = "$user|$agent_user";
echo "$result: $result_reason: $data\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
exit;
}
}
}
}
exit;
}
################################################################################
### END user_details
################################################################################
################################################################################ ################################################################################
### callid_info - outputs information about a call based upon the caller_code(or call ID) ### callid_info - outputs information about a call based upon the caller_code(or call ID)