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_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 6636 to 6654

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 4th December 2024 08:35 Europe/London time based on the source file dated 28th November 2024 12:10 Europe/London time.