Collections functions
General functions
Render functions
Theme permission functions
Resource 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
$resource_id integer|array - Resource unique ref -or- array of Resource refs

Return

void

Location

include/resource_functions.php lines 5953 to 5989

Definition

 
function update_archive_status($resource$archive$existingstates = array(), $collection  0)
    {
    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'', 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")));
    
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);
    return;
    }

This article was last updated 3rd October 2022 11:35 Europe/London time based on the source file dated 30th September 2022 14:20 Europe/London time.