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

update_archive_status()

Description

Update the archive state of resource(s) and log this

Parameters

ColumnTypeDefaultDescription
$resource
$archive integer - Destination archive state
$existingstates integer|array array - existing archive state _or_ array of corresponding existing archive states
$collection integer 0 - optional id of collection containing resources
$more_notes ""
$resource_id integer|array - Resource unique ref -or- array of Resource refs

Return

void

Location

include/resource_functions.php lines 6696 to 6745

Definition

 
function update_archive_status($resource$archive$existingstates = array(), $collection  0$more_notes="")
    {
    global 
$resource_deletion_state;
    
    if(!
is_array($resource))
        {
        
$resource = array($resource);
        }

    if(!
is_array($existingstates))
        {
        
$existingstates = array($existingstates);
        }

    
$count count($resource);

    for(
$n 0$n $count$n++)
        {
        if(!
is_numeric($resource[$n]))
            {
            continue;
            }

        
resource_log($resource[$n], LOG_CODE_STATUS_CHANGED0$more_notes, isset($existingstates[$n]) ? $existingstates[$n] : ''$archive);
        }

    
# Prevent any attempt to update with non-numeric archive state
    
if (!is_numeric($archive))
        {
        
debug("update_archive_status FAILED - resources=(" implode(",",$resource) . "), archive: " $archive ", existingstates:(" implode(",",$existingstates) . "), collection: " $collection);
        return;
        }

    
ps_query("UPDATE resource SET archive = ? WHERE ref IN (" ps_param_insert(count($resource)) . ")",array_merge(["i",$archive],ps_param_fill($resource,"i")));

    
# Resources should be removed from collections when being moved into the deletion state as specified in config,default.php
    
if ($resource_deletion_state == $archive) {
        foreach (
$resource as $ref) {
            
$in_collections ps_query('SELECT collection, resource FROM collection_resource WHERE resource = ?', ['i'$ref]);
            
ps_query('DELETE FROM collection_resource WHERE resource = ?', ['i'$ref]);
            foreach (
$in_collections as $col) { 
                
collection_log($col['collection'], LOG_CODE_COLLECTION_DELETED_RESOURCE$col['resource']);
            }
        }
    }

    
hook('after_update_archive_status''', array($resource$archive,$existingstates));
    
// Send notifications
    
debug("update_archive_status - resources=(" implode(",",$resource) . "), archive: " $archive ", existingstates:(" implode(",",$existingstates) . "), collection: " $collection);
    }

This article was last updated 8th December 2024 20:35 Europe/London time based on the source file dated 6th December 2024 14:05 Europe/London time.