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 7ecb924b7a
commit c76f413b49
3 changed files with 174 additions and 6 deletions
+139 -2
View File
@@ -215,10 +215,11 @@
# 240718-0942 - Fixes for inconsistencies in documentation and permissions for some functions
# 240718-1716 - Added fields to campaigns_list function output
# 240730-1832 - Changes for PHP8 compatibility, Added copy_did function
# 240824-1626 - Added user_details function
#
$version = '2.14-192';
$build = '240730-1832';
$version = '2.14-193';
$build = '240824-1626';
$php_script='non_agent_api.php';
$api_url_log = 0;
$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)