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

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 257 to 291

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"preferences");

    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 9th November 2024 17:05 Europe/London time based on the source file dated 7th November 2024 17:40 Europe/London time.