Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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) unless assigned to the logged in user
$returnsql boolean false Return SQL query object instead of the results?

Return

mixed Resulting array of requests or an SQL query object

Location

include/request_functions.php lines 232 to 279

Definition

 
function get_requests($excludecompleted=false,$excludeassigned=false,$returnsql=false)
    {
    global 
$userref;
    
$condition="";

    
$parameters=array();

    
# Include requests assigned to the user if the user can accept requests (permission "Rb")
    
if (checkperm("Rb")) 
        {
        
$condition="WHERE r.assigned_to=?";
        
$parameters=array("i",$userref);
        }
    
# Include all requests if the user can assign requests (permission "Ra")
    
if (checkperm("Ra")) 
        {
        
$condition="";
        
$parameters=array();
        
# Excluding assigned requests only makes sense if user is able to assign requests 
        
if ($excludeassigned
            {
            
$condition "WHERE (r.assigned_to IS null OR r.assigned_to = ?)"// Ensure they see requests that have been assigned to them
            
$parameters=array("i",$userref);
            }
        }
    
# 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";
    
    
$request_query = new PreparedStatementQuery($sql$parameters);

    if (
$returnsql
        {
        return 
$request_query;
        }
    else 
        {
        return 
ps_query($request_query->sql,$request_query->parameters);
        }
    }

This article was last updated 14th December 2024 20:35 Europe/London time based on the source file dated 18th November 2024 16:40 Europe/London time.