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: 390 lines (20 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

helper:: (5 methods):
  create_preset()
  add_item()
  add_plugin()
  change_default_preset()
  create_default_presets()


Class: helper  - X-Ref

Admin presets helper class.

create_preset(array $data)   X-Ref
Create an empty preset.

return: int The identifier of the preset created.
param: array $data Preset data. Supported values:

add_item(int $presetid, string $name, string $value, ?string $plugin = 'none',?string $advname = null, ?string $advvalue = null)   X-Ref
Helper method to add a setting item to a preset.

return: int The item identificator.
param: int $presetid Preset identifier where the item will belong.
param: string $name Item name.
param: string $value Item value.
param: string|null $plugin Item plugin.
param: string|null $advname If the item is an advanced setting, the name of the advanced setting should be specified here.
param: string|null $advvalue If the item is an advanced setting, the value of the advanced setting should be specified here.

add_plugin(int $presetid, string $plugin, string $name, int $enabled)   X-Ref
Helper method to add a plugin to a preset.

return: int The plugin identificator.
param: int $presetid Preset identifier where the item will belong.
param: string $plugin Plugin type.
param: string $name Plugin name.
param: int $enabled Whether the plugin will be enabled or not.

change_default_preset(string $presetnameorfile)   X-Ref
Apply the given preset. If it's a filename, the preset will be imported and then applied.

return: int|null The preset identifier that has been applied or null if the given value was not valid.
param: string $presetnameorfile The preset name to be applied or a valid preset file to be imported and applied.

create_default_presets()   X-Ref
Helper method to create default site admin presets and initialize them.