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

set_plugin_config()

Description

Store a plugin's configuration in the database.

Serializes the $config parameter and stores in the config
and config_json columns of the plugins table.
<code>
<?php
$plugin_config['a'] = 1;
$plugin_config['b'] = 2;
set_plugin_config('myplugin', $plugin_config);
?>
</code>

@see get_plugin_config

Parameters

ColumnTypeDefaultDescription
$plugin_name string Plugin name
$config mixed Configuration variable to store.

Location

include/plugin_functions.php lines 346 to 367

Definition

 
function set_plugin_config($plugin_name$config)
    {
    global 
$db$mysql_charset;
    
$config config_clean($config);
    
$config_ser_bin =  base64_encode(serialize($config));
    
$config_ser_json config_json_encode($config);
    if (!isset(
$mysql_charset))
        {
        
$config_ser_json iconv('UTF-8''ISO-8859-1//TRANSLIT'$config_ser_json);
        }

    
// We record the activity before running the query because log_activity() is trying to be clever and figure out the old value
    // which will make the new value also show up (incorrectly) as the old value.
    
log_activity(nullLOG_CODE_EDITED$config_ser_json'plugins''config_json'$plugin_name'name'nullnulltrue);

    
ps_query("UPDATE plugins SET config = ?, config_json = ? WHERE name = ?", array("s"$config_ser_bin"s"$config_ser_json"s"$plugin_name));

    
// Clear query cache
    
clear_query_cache("plugins");

    return 
true;
    }

This article was last updated 17th November 2024 15:05 Europe/London time based on the source file dated 8th November 2024 11:50 Europe/London time.