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

process_config_options()

Description

Process configuration options from database either system wide or user specific, setting the global variable.
Three modes are possible: 1. User ID is null to get system preferences.
2. User ID and user group ID are supplied. User group preferences are overridden by user preferences.
3. User ID is 0 and user group ID supplied. Only user group preferences are retrieved.
Note: calling this function will not revert user preferences applied previously e.g. during initialisation as a different user.
If the current user's preferences shouldn't be shown, consider using $system_wide_config_options to reapply selected system values.

Parameters

ColumnTypeDefaultDescription
$user_id int null User ID when getting user preferences. NULL when getting system preferences.
$usergroup_id int null User group ID used when getting user preferences.

Return

void

Location

include/config_functions.php lines 492 to 539

Definition

 
function process_config_options(?int $user_id null, ?int $usergroup_id null)
{
    global 
$user_preferences;
    
$config_options = array();

    
# Processing for user group preferences.
    
if (!is_null($user_id) && get_config_options(array('usergroup' => $usergroup_id), $config_options)) {
        foreach(
$config_options as $config_option) {
            
$param_value $config_option['value'];

            
// Prepare the value since everything is stored as a string
            
if (is_numeric($param_value) && '' !== $param_value) {
                
$param_value = (int) $param_value;
                }

            
$GLOBALS[$config_option['parameter']] = $param_value;
        }
    }

    
// If the user doesn't have the ability to set his/her own preferences, then don't load it either
    
if (!is_null($user_id) && !$user_preferences) {
        return;
    }

    if (
$user_id === 0) {
        
# Special case to only load user group preferences.
        
return;
    }

    
# Processing for user / system preferences.
    
if (is_null($user_id)) {
        
$system_or_user = array(); # System preference required.
    
} else {
        
$system_or_user = array('user' => $user_id);
    }
    if (
get_config_options($system_or_user$config_options)) {
        foreach(
$config_options as $config_option) {
            
$param_value $config_option['value'];

            
// Prepare the value since everything is stored as a string
            
if (is_numeric($param_value) && '' !== $param_value) {
                
$param_value = (int) $param_value;
                }

            
$GLOBALS[$config_option['parameter']] = $param_value;
        }
    }
}

This article was last updated 14th April 2025 21:35 Europe/London time based on the source file dated 10th April 2025 10:35 Europe/London time.