Added list_info Non-Agent API function

git-svn-id: svn://192.168.202.10@3158 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2019-11-07 17:40:38 +00:00
parent 091754b58b
commit 60386dbfe2
3 changed files with 209 additions and 7 deletions
+38 -1
View File
@@ -1,4 +1,4 @@
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2019-09-30
NON-AGENT API DOCUMENT Started: 2008-07-24 Updated: 2019-11-07
This document describes the functions of an API(Application Programming
Interface) for all functions NOT directly relating to the VICIDIAL Agent screen.
@@ -31,6 +31,7 @@ add_phone_alias - adds a phone alias record to the system
update_phone_alias - updates or deletes an existing phone alias record in the system
add_list - adds a list to the system
update_list - updates list settings in the system, reset leads in list, delete list
list_info - summary information about a list
add_group_alias - adds group alias to the system
user_group_status - real-time status of one or more user groups
in_group_status - real-time status of one or more in groups
@@ -145,6 +146,7 @@ Changes:
190628-1504 - Added update_cid_group_entry function
190703-0858 - Added custom_fields_copy option to add_list function
190930-1629 - Added list_description field to add_list and update_list functions
191107-1143 - Added list_info function
API Functions use the 'function' variable
@@ -1505,6 +1507,41 @@ NOTICE: update_list LEADS IN LIST HAVE BEEN DELETED - 6666|1101|324
--------------------------------------------------------------------------------
list_info - summary information about a list
NOTE: api user for this function must have user_level set to 8 or higher and "modify lists" enabled
REQUIRED FIELDS-
list_id - must be all numbers, 2-14 digits
source - description of what originated the API call (maximum 20 characters)
SETTINGS FIELDS- (optional)
leads_counts - Y or N, will include the counts of all leads and NEW status leads in the response, default is 'N'
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=list_info&list_id=1101&leads_counts=Y&header=YES
Example responses:
ERROR: list_info USER DOES NOT HAVE PERMISSION TO MODIFY LISTS - 6666
ERROR: list_info YOU MUST USE ALL REQUIRED FIELDS - 6666|1
ERROR: list_info NOT AN ALLOWED LIST ID - 98762
ERROR: list_info LIST DOES NOT EXIST - 98762
A SUCCESS response will not show "SUCCESS", but instead will just print the results in the following formats:
list_id|list_name|campaign_id|active|list_changedate|list_lastcalldate|expiration_date|resets_today
1101|performance list|TESTCAMP|Y|2019-09-02 08:52:50|2019-11-07 10:12:12|2099-12-31|0|
list_id|list_name|campaign_id|active|list_changedate|list_lastcalldate|expiration_date|resets_today|all_leads_count|new_leads_count
1101|performance list|TESTCAMP|Y|2019-09-02 08:52:50|2019-11-07 10:12:12|2099-12-31|0|59896|3
--------------------------------------------------------------------------------
check_phone_number - allows you to check if a phone number is valid and dialable
+5 -4
View File
@@ -128,7 +128,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_campaign update_did lead_field_info phone_number_log switch_lead ccc_lead_info lead_status_search call_status_stats calls_in_queue_count force_fronter_leave_3way force_fronter_audio_stop update_cid_group_entry';
$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 list_info 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 force_fronter_leave_3way force_fronter_audio_stop update_cid_group_entry';
### BEGIN housecleaning of old static report files, if not done before ###
@@ -4574,13 +4574,14 @@ else
# 191014-1816 - Additional PHP7 fixes
# 191015-1620 - Added user inbound call count filters
# 191101-1149 - Added 2nd script tab, voicemail message groups and fixed translation issues
# 191106-0934 - Added several multi-ccampaign options to the add/delete DNC number page
# 191106-0934 - Added several multi-campaign options to the add/delete DNC number page
# 191107-1150 - Added list_info as API function option
#
# 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-723a';
$build = '191106-0934';
$admin_version = '2.14-724a';
$build = '191107-1150';
$STARTtime = date("U");
$SQLdate = date("Y-m-d H:i:s");
+166 -2
View File
@@ -139,10 +139,11 @@
# 190628-1504 - Added update_cid_group_entry function
# 190703-0858 - Added custom_fields_copy option to add_list function
# 190930-1629 - Added list_description field to add_list and update_list functions
# 191107-1143 - Added list_info function
#
$version = '2.14-116';
$build = '190930-1629';
$version = '2.14-117';
$build = '191107-1143';
$api_url_log = 0;
$startMS = microtime();
@@ -511,6 +512,8 @@ if (isset($_GET["custom_fields_copy"])) {$custom_fields_copy=$_GET["custom_fi
elseif (isset($_POST["custom_fields_copy"])) {$custom_fields_copy=$_POST["custom_fields_copy"];}
if (isset($_GET["list_description"])) {$list_description=$_GET["list_description"];}
elseif (isset($_POST["list_description"])) {$list_description=$_POST["list_description"];}
if (isset($_GET["leads_counts"])) {$leads_counts=$_GET["leads_counts"];}
elseif (isset($_POST["leads_counts"])) {$leads_counts=$_POST["leads_counts"];}
header ("Content-type: text/html; charset=utf-8");
@@ -734,6 +737,7 @@ if ($non_latin < 1)
{$outbound_cid=preg_replace('/[^0-9]/','',$outbound_cid);}
if ($areacode != '---ALL---')
{$areacode=preg_replace('/[^0-9a-zA-Z]/','',$areacode);}
$leads_counts = preg_replace('/[^-_0-9a-zA-Z]/','',$leads_counts);
}
else
{
@@ -4574,6 +4578,166 @@ if ($function == 'update_list')
################################################################################
### list_info - summary information about a list
################################################################################
if ($function == 'list_info')
{
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_lists='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 = "list_info USER DOES NOT HAVE PERMISSION TO MODIFY LISTS";
$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($list_id)<2) or (strlen($list_id)>14) )
{
$result = 'ERROR';
$result_reason = "list_info YOU MUST USE ALL REQUIRED FIELDS";
$data = "$list_id|$list_name|$campaign_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;
}
else
{
if ($api_list_restrict > 0)
{
if (!preg_match("/ $list_id /",$allowed_lists))
{
$result = 'ERROR';
$result_reason = "list_info NOT AN ALLOWED LIST ID";
$data = "$list_id";
echo "$result: $result_reason - $data\n";
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
exit;
}
}
$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];
$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_lists where list_id='$list_id' $LOGallowed_campaignsSQL;";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$list_exists=$row[0];
if ($list_exists < 1)
{
$result = 'ERROR';
$result_reason = "list_info LIST DOES NOT EXIST";
$data = "$list_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;
}
else
{
$stmt="SELECT list_name,campaign_id,active,list_changedate,list_lastcalldate,expiration_date,resets_today from vicidial_lists where list_id='$list_id' $LOGallowed_campaignsSQL;";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$list_name = $row[0];
$campaign_id = $row[1];
$active = $row[2];
$list_changedate = $row[3];
$list_lastcalldate = $row[4];
$expiration_date = $row[5];
$resets_today = $row[6];
$output='';
$DLset=0;
if ($stage == 'csv')
{$DL = ','; $DLset++;}
if ($stage == 'tab')
{$DL = "\t"; $DLset++;}
if ($stage == 'pipe')
{$DL = '|'; $DLset++;}
if ($DLset < 1)
{$DL='|';}
if ($header == 'YES')
{$output .= 'list_id' . $DL . 'list_name' . $DL . 'campaign_id' . $DL . 'active' . $DL . 'list_changedate' . $DL . 'list_lastcalldate' . $DL . 'expiration_date' . $DL . 'resets_today';}
$leads_counts_output='';
if ($leads_counts == 'Y')
{
if ($header == 'YES')
{$output .= $DL . 'all_leads_count' . $DL . 'new_leads_count';}
$stmt="SELECT count(*) from vicidial_list where list_id='$list_id';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$all_leads_count = $row[0];
$stmt="SELECT count(*) from vicidial_list where list_id='$list_id' and status='NEW';";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$new_leads_count = $row[0];
$leads_counts_output .= $DL . "$all_leads_count" . $DL . "$new_leads_count";
}
if ($header == 'YES')
{$output .= "\n";}
$output .= "$list_id" . $DL . "$list_name" . $DL . "$campaign_id" . $DL . "$active" . $DL . "$list_changedate" . $DL . "$list_lastcalldate" . $DL . "$expiration_date" . $DL . "$resets_today" . $leads_counts_output . "\n";
$result = 'SUCCESS';
$result_reason = "list_info LIST INFORMATION SENT";
$data = "$list_id";
echo $output;
api_log($link,$api_logging,$api_script,$user,$agent_user,$function,$value,$result,$result_reason,$source,$data);
exit;
}
}
}
}
}
################################################################################
### END list_info
################################################################################
################################################################################
### add_list - adds list to the vicidial_lists table
################################################################################