Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 401 and 402] [Versions 401 and 403]

(no description)

File Size: 1183 lines (56 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes

manager:: (0 methods):

that:: (13 methods):
  get_site_settings()
  get_settings()
  get_setting()
  get_settings_class()
  get_settings_from_db()
  apply_preset()
  export_preset()
  download_preset()
  import_preset()
  delete_preset()
  revert_preset()
  apply_settings()
  apply_plugins()


Class: manager  - X-Ref

Admin tool presets manager class.

Class: that  - X-Ref

get_site_settings()   X-Ref
Gets the system settings

Loads the DB $CFG->prefix.'config' values and the
$CFG->prefix.'config_plugins' values and redirects
the flow through $this->get_settings()

return: array $settings Array format $array['plugin']['settingname'] = settings_types child class

get_settings(array $dbsettings, bool $sitedbvalues = false, array $settings = [], $children = false)   X-Ref
Constructs an array with all the system settings

If a setting value can't be found on the DB it considers
the default value as the setting value

Settings without plugin are marked as 'none' in the plugin field

Returns an standarized settings array format.

param: array $dbsettings Standarized array,
param: boolean $sitedbvalues Indicates if $dbsettings comes from the site db or not
param: array $settings Array format $array['plugin']['settingname'] = settings_types child class
param: array|false $children Array of admin_category children or false
return: array Array format $array['plugin']['settingname'] = settings_types child class

get_setting($settingdata, $currentvalue)   X-Ref
Returns the class type object

param: object $settingdata Setting data
param: mixed $currentvalue
return: mixed

get_settings_class(string $classname)   X-Ref
Returns the settings class mapped to the defined $classname or null if it doesn't exist any associated class.

param: string $classname The classname to get the mapped class.
return: string|null

get_settings_from_db(array $dbsettings)   X-Ref
Gets the standarized settings array from DB records

param: array $dbsettings Array of objects
return: array Standarized array,

apply_preset(int $presetid, bool $simulate = false)   X-Ref
Apply a given preset.

param: int $presetid The preset identifier to apply.
param: bool $simulate Whether this is a simulation or not.
return: array List with an array with the applied settings and another with the skipped ones.

export_preset(stdClass $data)   X-Ref
Create a preset with the current settings and plugins information.

param: \stdClass $data Preset info, such as name or description, to be used when creating the preset with the current
return: array List with an the presetid created (int), a boolean to define if any setting has been found and

download_preset(int $presetid)   X-Ref
Create the XML content for a given preset.

param: int $presetid The preset to download.
return: array List with the XML content (string) and a filename proposal based on the preset name (string).

import_preset(string $xmlcontent, ?string $presetname = null)   X-Ref
Import a given XML preset.

param: string $xmlcontent The XML context with the preset to be imported.
param: string|null $presetname The preset name that will overwrite the one given in the XML file.
return: array List with an the XML element (SimpleXMLElement|null), the imported preset (stdClass|null), a boolean

delete_preset(int $presetid)   X-Ref
Delete given preset.

param: int $presetid Preset identifier to delete.
return: void

revert_preset(int $presetappid)   X-Ref
Revert a given preset applied previously.
It backs settings and plugins to their original state before applying the presset and removes
the applied preset information from DB.

param: int $presetappid The appplied preset identifier to be reverted.
return: array List with the presetapp removed (or null if there was some error), an array with the rollback settings/plugins

apply_settings(int $presetid, bool $simulate = false, ?int $adminpresetapplyid = null)   X-Ref
Apply settings from a preset.

param: int $presetid The preset identifier to apply.
param: bool $simulate Whether this is a simulation or not.
param: int|null $adminpresetapplyid The identifier of the adminpresetapply or null if it hasn't been created previously.
return: array List with an array with the applied settings, another with the skipped ones and the adminpresetapplyid.

apply_plugins(int $presetid, bool $simulate = false, ?int $adminpresetapplyid = null)   X-Ref
Apply plugins from a preset.

param: int $presetid The preset identifier to apply.
param: bool $simulate Whether this is a simulation or not.
param: int|null $adminpresetapplyid The identifier of the adminpresetapply or null if it hasn't been created previously.
return: array List with an array with the applied settings, another with the skipped ones and the adminpresetapplyid.