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

edit_resource_external_access()

Description

Edits the external access settings for a given resource.

Parameters

ColumnTypeDefaultDescription
$key string The external access key to edit.
$access int -1 The new access level; defaults to -1 for no change.
$expires string "" The expiration date for the access key; optional.
$group string "" The user group to share with; defaults to the current user group if not specified.
$sharepwd string "" The password for accessing the resource; "(unchanged)" means no change.

Return

bool Returns true if the operation was successful; false if the key is empty.

Location

include/resource_functions.php lines 5617 to 5639

Definition

 
function edit_resource_external_access($key,$access=-1,$expires="",$group="",$sharepwd="")
    {
    global 
$userref,$usergroup$scramble_key;
    if (
$group=="" || !checkperm("x")) {$group=$usergroup;} # Default to sharing with the permission of the current usergroup if not specified OR no access to alternative group selection.
    
if ($key==""){return false;}
    if (
$sharepwd != "(unchanged)")
        {
        
$sql "password_hash= ?,";
        
$params = ['s', (($sharepwd == "") ? "" hash('sha256'$key $sharepwd $scramble_key))];
        }
        else{
$sql "";$params=[];}
    
# Update the expiration and acccess
    
ps_query("UPDATE external_access_keys SET {$sql} access= ?, expires= ?,date=NOW(),usergroup= ? WHERE access_key = ?",
        
array_merge($params, [
        
'i'$access,
        
's', (($expires=="")?null$expires),
        
'i'$group,
        
's',$key,
        ])
    );
    
hook('edit_resource_external_access','',array($key,$access,$expires,$group));
    return 
true;
    }

This article was last updated 17th November 2024 15:35 Europe/London time based on the source file dated 15th November 2024 18:30 Europe/London time.