Coding standards
Security in ResourceSpace
Developer reference
Database
Mcp browse functions
Mcp report functions
Mcp management functions
Core feature functions
Embed functions

get_active_core_features()

Description

Get enabled core features and their hook configuration. Before the upgrade runs, honour the old registry.

Parameters

ColumnTypeDefaultDescription
array { : int get_sysvar'upgrade_system_level'
0;

Return

array Feature records keyed by name, including priority and group restrictions.

Location

include/core_feature_functions.php lines 53 to 111

Definition

 
function get_active_core_features(): array
{
    
$level = (int) get_sysvar('upgrade_system_level', 0);
    if (
$level < 35) {
        
$records = ps_query(
            
'SELECT name, enabled_groups, config, config_json, priority FROM plugins WHERE inst_version >= 0',
            [],
            
'plugins'
        
);
        return 
array_intersect_key(array_column($records, null, 'name'), CORE_FEATURES);
    }

    if (isset(
$GLOBALS['active_core_features'])) {
        return 
$GLOBALS['active_core_features'];
    }
    
$options = [];
    
get_config_options([], $options);
    
$settings = array_column($options, 'value', 'parameter');
    
$overrides = [];
    
$group_settings = array_map(
        static fn(
string $name): string => 'core_feature_' . $name,
        
array_diff(array_keys(CORE_FEATURES), CORE_FEATURES_ALL_GROUPS)
    );
    
$rows = ps_query(
        
'SELECT usergroup, parameter, `value` FROM user_preferences
          WHERE user IS NULL AND usergroup IS NOT NULL AND parameter IN (' 
. ps_param_insert(count($group_settings)) . ')',
        
ps_param_fill($group_settings, 's'),
        
'preferences'
    
);
    foreach (
$rows as $row) {
        
$overrides[$row['parameter']][(int) $row['usergroup']] = $row['value'] === '1';
    }

    
$features = [];
    foreach (
CORE_FEATURES as $name => $priority) {
        
$setting = "core_feature_{$name}";
        
$default = (bool) ($settings[$setting] ?? $GLOBALS['system_wide_config_options'][$setting] ?? $GLOBALS[$setting] ?? false);
        
$groups = $overrides[$setting] ?? [];
        if (!
$default && !in_array(true, $groups, true)) {
            continue;
        }
        
$features[$name] = [
            
'name' => $name,
            
'system_enabled' => $default,
            
'group_options' => $groups,
            
'enabled_groups' => '',
            
'config' => null,
            
'config_json' => $settings[$setting . '_options'] ?? null,
            
'priority' => (int) ($settings[$setting . '_priority'] ?? $priority),
        ];
        
// A request can load before the upgrade converts the old system-scoped allowlist.
        
if ($level === 35 && ($settings[$setting . '_groups'] ?? '') !== '') {
            
$features[$name]['enabled_groups'] = $settings[$setting . '_groups'];
            unset(
$features[$name]['system_enabled']);
        }
    }
    
$GLOBALS['active_core_features'] = $features;
    return 
$features;
}

This article was last updated 4th December 2026 17:35 Europe/London time based on the source file dated 4th December 2026 14:10 Europe/London time.