Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

generate_collection_access_key()

Description

For each resource in the collection, create an access key so an external user can access each resource.

Parameters

ColumnTypeDefaultDescription
$collection integer
$feedback integer 0
$email string ""
$access integer -1
$expires string ""
$group string ""
$sharepwd string ""

Return

string The generated key

Location

include/collections_functions.php lines 1606 to 1623

Definition

 
function generate_collection_access_key($collection,$feedback=0,$email="",$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.
    
$k=substr(md5($collection "," time()),0,10);
    
$r=get_collection_resources($collection);
    for (
$m=0;$m<count($r);$m++)
        {
        
# Add the key to each resource in the collection
        
if(can_share_resource($r[$m]))
            {
            
sql_query("insert into external_access_keys(resource,access_key,collection,user,usergroup,request_feedback,email,date,access,expires, password_hash) values ('" $r[$m] . "','$k','$collection','$userref','$group','$feedback','" escape_check($email) . "',now(),$access," . (($expires=="")?"null":"'" escape_check($expires) . "'"). "," . (($sharepwd != "" && $sharepwd != "(unchanged)") ? "'" hash('sha256'$k $sharepwd $scramble_key) . "'""null") . ");");
            }
        }
    
    
hook("generate_collection_access_key","",array($collection,$k,$userref,$feedback,$email,$access,$expires,$group,$sharepwd));
    return 
$k;
    }

This article was last updated 14th July 2020 06:05 Europe/London time based on the source file dated 9th July 2020 17:22 Europe/London time.