Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

get_config_option()

Description

Get config option value from the database (system wide -or- a user preference).

IMPORTANT: it falls back (defaults) to the globally scoped config option value if
there's nothing in the database.
global setting e.g. for checking admin resource preferences

Parameters

ColumnTypeDefaultDescription
$user_id ?integer Current user ID. Use NULL to get the system wide setting.
$name string Parameter name
&$returned_value
$default mixed null Optionally used to set a default that may not be the current
$returned_value string The config value will be returned through this parameter which is passed by reference.

Return

boolean Indicates if the config option was found in the database or not.

Location

include/config_functions.php lines 256 to 290

Definition

 
function get_config_option($user_id$name, &$returned_value$default null)
    {
    if(
trim($name) === '')
        {
        return 
false;
        }

    if(
is_null($user_id))
        {
        
$user_query 'user IS NULL';
        }
    else    
        {
        
$user_query 'user = ?';
        
$params[] = 'i'$params[] = $user_id;
        }

    
$query "SELECT `value` FROM user_preferences WHERE "$user_query ." AND parameter = ?";
    
$params[] = "s"$params[] = $name;
    
$config_option ps_value($query,$paramsnull);

    if(
is_null($default) && isset($GLOBALS[$name]))
        {
        
$default $GLOBALS[$name];
        }

     if(
is_null($config_option))
        {
        
$returned_value $default;
        return 
false;
        }

    
$returned_value unescape($config_option);
    return 
true;
    }

This article was last updated 19th March 2024 06:35 Europe/London time based on the source file dated 15th March 2024 17:00 Europe/London time.