Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 400 and 402] [Versions 400 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.

return: array Array format $array['plugin']['settingname'] = settings_types child class
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

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

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

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.

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

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

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

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

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

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

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

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

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

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

return: array List with an the XML element (SimpleXMLElement|null), the imported preset (stdClass|null), a boolean
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.

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

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

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.

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

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

return: array List with an array with the applied settings, another with the skipped ones and the adminpresetapplyid.
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.

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

return: array List with an array with the applied settings, another with the skipped ones and the adminpresetapplyid.
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.