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

purge_expired_shares()

Description

Purge all expired shares
"share_group" - (int) Usergroup ref 'shared as'
"share_user" - (int) user ID of share creator
"share_type" - (int) 0=view, 1=upload
"share_collection" - (int) Collection ID

Parameters

ColumnTypeDefaultDescription
$filteropts array Array of options to filter shares purged

Return

string|int

Location

include/collections_functions.php lines 6758 to 6808

Definition

 
function purge_expired_shares($filteropts)
    {
    global 
$userref;

    
$share_group $filteropts['share_group'] ?? null;
    
$share_user $filteropts['share_user'] ?? null;
    
$share_type $filteropts['share_type'] ?? null;
    
$share_collection $filteropts['share_collection'] ?? null;
   
    
$conditions = array();
    
$params = [];
    if((int)
$share_user && ($share_user == $userref || checkperm_user_edit($share_user)))
        {
        
$conditions[] = "user = ?";
        
$params array_merge($params, ['i'$share_user]);
        }
    elseif(!
checkperm('a') && !checkperm('ex'))
        {
        
$conditions[] = "user = ?";
        
$params array_merge($params, ['i'$userref]);
        }

    if(!
is_null($share_group) && (int)$share_group 0  && checkperm('a'))
        {
        
$conditions[] = "usergroup = ?";
        
$params array_merge($params, ['i'$share_group]);
        }
    if(
$share_type == 0)
        {
        
$conditions[] = "(upload=0 OR upload IS NULL)";
        }
    elseif(
$share_type == 1)
        {
        
$conditions[] = "upload=1";
        }
    if((int)
$share_collection 0)
        {
        
$conditions[] = "collection = ?";
        
$params array_merge($params, ['i'$share_collection]);
        }

    
$conditional_sql=" WHERE expires < now()";
    if (
count($conditions)>0)
        {
        
$conditional_sql .= " AND " implode(" AND ",$conditions);
        }

    
$purge_query "DELETE FROM external_access_keys " $conditional_sql;
    
ps_query($purge_query$params);
    return 
sql_affected_rows();
    }

This article was last updated 11th December 2024 08:05 Europe/London time based on the source file dated 4th December 2024 16:35 Europe/London time.