SugarCRM SupportProduct GuidesSugar DeveloperSugar Developer Guide 10.3ArchitectureAdministration
This release is only available for SugarCloud customers.

Administration

Overview

The Administration class is used to manage settings stored in the database config table.

The Administration Class

The Administration class is located in ./modules/Administration/Administration.php. Settings modified using this class are written to the config table.

Creating / Updating Settings

To create or update a specific setting, you can specify the new value using the saveSetting() function as shown here:

require_once 'modules/Administration/Administration.php';

$administrationObj = new Administration();

//save the setting
$administrationObj->saveSetting("MyCategory", "MySetting", 'MySettingsValue');

Retrieving Settings

You can access the config settings by using the retrieveSettings() function. You can filter the settings by category by passing in a filter parameter. If no value is passed to retrieveSettings(), all settings will be returned. An example is shown here:

require_once 'modules/Administration/Administration.php';

$administrationObj = new Administration();

//Retrieve all settings in the category of 'MyCategory'.
//This parameter can be left empty to retrieve all settings.
$administrationObj->retrieveSettings('MyCategory');

//Use a specific setting
$MySetting = $administrationObj->settings['MyCategory_MySetting'];

Considerations

The Administration class will store the settings in the config table, and the config table is cached using SugarCache as the admin_settings_cache. This class should be used for storing dynamic settings for a module, connector or the system as a whole, such as the last run date (for a scheduler) or an expiring token (for a connector). You should not use the Administration class to store User-based settings, settings that are frequently changing or being written to via the API, or excessively large values, as this can degrade the performance of the instance since all settings are loaded into the admin_settings_cache, which is used throughout the system.

Alternatively, you can use the Configurator class, located in ./modules/Configurator/Configurator.php, to store the settings in the ./config_override.php file if the settings are not dynamic or not changing programmatically. It is important to note that settings stored using the configurator will cause a metadata hash refresh that may lead to users being logged out of the system.

Last modified: 2021-01-06 23:28:41