Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

get_requests()

Description

Fetch a list of requests assigned to the logged in user

Parameters

ColumnTypeDefaultDescription
$excludecompleted boolean false Exclude completed requests?
$excludeassigned boolean false Exclude assigned requests? (e.g. if the user is able to assign unassigned requests)
$returnsql boolean false Return SQL instead of the results?

Return

array The set of request records

Location

include/request_functions.php lines 223 to 249

Definition

 
function get_requests($excludecompleted=false,$excludeassigned=false,$returnsql=false)
    {
    
$condition="";global $userref;
    
# Include requests assigned to the user if the user can accept requests (permission "Rb")
    
if (checkperm("Rb")) 
        {
        
$condition="WHERE r.assigned_to='" $userref "'";
        }
    
# Include all requests if the user can assign requests (permission "Ra")
    
if (checkperm("Ra")) 
        {
        
$condition="";
        
# Excluding assigned requests only makes sense if user is able to assign requests 
        
if ($excludeassigned
            {
            
$condition "WHERE r.assigned_to IS null"
            }
        }
    
# Exclude completed requests if necessary
    
if ($excludecompleted
        {
        
$condition .= (($condition!="") ? " AND" "WHERE") . " r.status=0";
        }
        
    
$sql="SELECT u.username,u.fullname,r.*,(SELECT count(*) FROM collection_resource cr WHERE cr.collection=r.collection) c,u2.username assigned_to_username FROM request r LEFT OUTER JOIN user u ON r.user=u.ref LEFT OUTER JOIN user u2 ON r.assigned_to=u2.ref $condition  ORDER BY status,ref desc";
    return 
$returnsql?$sql:sql_query($sql);
    }

This article was last updated 24th November 2020 17:05 Europe/London time based on the source file dated 28th September 2020 10:05 Europe/London time.