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

delete_config_option()

Description

Delete entry from the user_preferences table completely (instead of setting to blank via set_config_option).
Used by system preferences page when deleting a file to allow fallback to value (if set) in config.php instead
of replacing it with blank from user_preference value.

array() - Supply an empty array to delete a system config value.
array('user' => 1) - Supply 'user' with the integer user reference to delete a user config value.
array('usergroup' => 2) - Supply 'user' with the integer user reference to delete a user group config value.

Parameters

ColumnTypeDefaultDescription
$config_type array The type of config to delete supplied as an array. The following are possible:
$param_name string Parameter name

Return

bool True if preference was deleted else false.

Location

include/config_functions.php lines 227 to 273

Definition

 
function delete_config_option(array $config_typestring $param_name) : bool
    
{
    if(empty(
$param_name)) {
        return 
false;
    }

    if (isset(
$config_type['user']) && isset($config_type['usergroup'])) {
        return 
false# Both user and usergroup cannot be supplied.
    
}

    foreach(
$config_type as $type_value) {
        if (!
is_int_loose($type_value)) {
            return 
false;
        }
    }

    
$current_param_value null;
    if(
get_config_option($config_type$param_name$current_param_value)) {
        if(isset(
$config_type['usergroup'])) {
            
$user_query 'usergroup = ?';
            
$params[] = 'i'$params[] = $config_type['usergroup'];
        }
        elseif (isset(
$config_type['user'])) {
            
$user_query 'user = ?';
            
$params[] = 'i'$params[] = $config_type['user'];
        } else {
            
$user_query 'user IS NULL';
        }

        
$query "DELETE FROM user_preferences WHERE "$user_query ." AND parameter = ?";
        
$params[] = "s"$params[] = $param_name;

        if (
count($config_type) === 0) {
            
// only log activity for system changes, i.e. when user not specified
            
log_activity(nullLOG_CODE_DELETEDnull'user_preferences''value'"parameter='" $param_name "'"null$current_param_value);
        }

        
ps_query($query,$params);

        
// Clear disk cache
        
clear_query_cache("preferences");

        return 
true;
    }

    return 
false;
    }

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.