get_resource_external_access()

Description

Retrieves all external access keys granted for a specific resource.

This function returns a list of all external access details for the given resource,
including users and emails associated with each access key. If the user does not have
the elevated 'v' permission, the function will only return access keys associated
with the current user. The results are grouped by access key, allowing for multiple
users or emails to be returned as comma-separated values.

and other related information for the specified resource.

Parameters

ColumnTypeDefaultDescription
$resource int The reference ID of the resource for which external access is being retrieved.

Return

array An array of access details, including access keys, users, emails, expiration dates,

Location

include/resource_functions.php lines 6096 to 6114

Definition

 
function get_resource_external_access($resource)
{
    
# Return all external access given to a resource
    # Users, emails and dates could be multiple for a given access key, an in this case they are returned comma-separated.
    
global $userref;

    
# Build parameters for the query
    
$params = array("i",$resource);

    
# Restrict to only their shares unless they have the elevated 'v' permission
    
$condition "";
    if (!
checkperm("v")) {
        
$condition "AND user=?";
        
$params[] = "i";
        
$params[] = $userref;
    }

    return 
ps_query("select access_key,group_concat(DISTINCT user ORDER BY user SEPARATOR ', ') users,group_concat(DISTINCT email ORDER BY email SEPARATOR ', ') emails,max(date) maxdate,max(lastused) lastused,access,expires,collection,usergroup, password_hash from external_access_keys where resource=? $condition group by access_key,access,expires,collection,usergroup order by maxdate"$params);
}

This article was last updated 7th July 2025 08:35 Europe/London time based on the source file dated 4th July 2025 10:35 Europe/London time.