Collections functions
General functions
Render functions
Theme permission functions
Resource functions

get_resource_types()

Parameters

ColumnTypeDefaultDescription
$types ""
$translate true

Location

include/resource_functions.php lines 3315 to 3366

Definition

 
function get_resource_types($types ""$translate true)
    {
    
# Returns a list of resource types. The standard resource types are translated using $lang. Custom resource types are i18n translated.
    // support getting info for a comma-delimited list of restypes (as in a search)
    
$parameters=array();
    if (
$types==""){$sql="";} else
        {
        
# Ensure $types are suitably quoted and escaped
        
$cleantypes="";
        
$s=explode(",",$types);
        
        foreach (
$s as $type)
            {
            if (
is_numeric(str_replace("'","",$type))) # Process numeric types only, to avoid inclusion of collection-based filters (mycol, public, etc.)
                
{
                if (
$cleantypes!="") {$cleantypes.=",";}
                
$cleantypes.="?";
                
$parameters[]="i";$parameters[]=$type;
                }
            }
        
$sql=" WHERE ref IN ($cleantypes) ";
        }
    
    
$r=ps_query("SELECT ref,
                        name,
                        allowed_extensions,
                        order_by,
                        config_options,
                        tab_name,
                        push_metadata,
                        inherit_global_fields,
                        colour,
                        icon
                   FROM resource_type
                        
$sql
               ORDER BY order_by,
                        ref"
,
                        
$parameters,
                        
"schema");

    
$return=array();
    
# Translate names (if $translate==true) and check permissions
    
for ($n=0;$n<count($r);$n++)
        {
        if (!
checkperm('T' $r[$n]['ref']))
            {
            if (
$translate==true) {$r[$n]["name"]=lang_or_i18n_get_translated($r[$n]["name"], "resourcetype-");} # Translate name
            
$return[]=$r[$n]; # Add to return array
            
}
        }
    return 
$return;
    }

This article was last updated 25th May 2022 05:05 Europe/London time based on the source file dated 24th May 2022 09:25 Europe/London time.