Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

get_resource_data()

Parameters

ColumnTypeDefaultDescription
$ref
$cache true

Location

include/resource_functions.php lines 360 to 407

Definition

 
function get_resource_data($ref,$cache=true)
    {
    if ((string)(int)
$ref != (string)$ref)
        {
        return 
false;
        }
    
# Returns basic resource data (from the resource table alone) for resource $ref.
    # For 'dynamic' field data, see get_resource_field_data
    
global $default_resource_type$get_resource_data_cache,$always_record_resource_creator;
    if (
$cache && isset($get_resource_data_cache[$ref])) {return $get_resource_data_cache[$ref];}
    
truncate_cache_arrays();
    
$resource=sql_query("select *,mapzoom,lock_user from resource where ref='" escape_check($ref) . "'");
    if (
count($resource)==0
        {
        if (
$ref>=0)
            {
            return 
false;
            }
        else
            {
            
# For upload templates (negative reference numbers), generate a new resource if upload permission.
            
if (!(checkperm("c") || checkperm("d"))) {return false;}
            elseif(!
hook('replace_upload_template_creation''', array($ref)))
                {
                if (isset(
$always_record_resource_creator) && $always_record_resource_creator)
                    {
                    global 
$userref;
                    
$user $userref;
                    }
                else {
$user = -1;}

                
$default_archive_state escape_check(get_default_archive_state());
                
$wait sql_query("insert into resource (ref,resource_type,created_by, archive) values ('" escape_check($ref) . "','$default_resource_type','$user', '{$default_archive_state}')");
                
$resource sql_query("select *,mapzoom,lock_user from resource where ref='" escape_check($ref) . "'");
                }
            }
        }
    
    if (isset(
$resource[0]))
        {
        
$get_resource_data_cache[$ref]=$resource[0];
        return 
$resource[0];
        }
    else
        {
        return 
false;
        }
    }

This article was last updated 24th November 2020 05:35 Europe/London time based on the source file dated 13th November 2020 16:50 Europe/London time.