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

get_resources_to_validate()

Description

Get an array of all resources that require files to be validated

Parameters

ColumnTypeDefaultDescription
$days int Return only resources not validated in the last X number of days
$GLOBALS["file_integrity_ignore_resource_types"]

Return

array *

Location

include/resource_functions.php lines 9701 to 9736

Definition

 
function get_resources_to_validate(int $days 0): array
{
    
$params = [];
    
$filtersql "";
    
$restypes_ignore array_unique(array_merge(
        
$GLOBALS["data_only_resource_types"],
        
$GLOBALS["file_integrity_ignore_resource_types"])
        );

    if (
count($GLOBALS["file_integrity_ignore_states"]) > 0) {
        
$filtersql .= " AND archive NOT IN (" ps_param_insert(count($GLOBALS["file_integrity_ignore_states"])) . ")";
        
$params array_merge($params,ps_param_fill($GLOBALS["file_integrity_ignore_states"], "i"));
    }

    if(
count($restypes_ignore) > 0) {
        
$filtersql .= " AND resource_type NOT IN (" ps_param_insert(count($restypes_ignore)) . ")";
        
$params array_merge($params,ps_param_fill($restypes_ignore"i"));
    }

    if(
$days 0) {
        
$filtersql .= " AND (last_verified IS NULL OR DATEDIFF(NOW(), last_verified) > ?)";
        
$params array_merge($params,["i"$days]);
    }

    return 
ps_query("SELECT ref,
                            archive,
                            file_extension,
                            resource_type,
                            file_checksum,
                            last_verified,
                            integrity_fail
                    FROM resource
                    WHERE ref > 0 AND no_file = 0 
{$filtersql}
                    ORDER BY integrity_fail DESC, last_verified ASC"
,
                    
$params);
}

This article was last updated 4th December 2024 08:35 Europe/London time based on the source file dated 28th November 2024 12:10 Europe/London time.