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

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

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.

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.
return: int The item identificator.

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

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.
return: int The plugin identificator.

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

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

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