Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
core_adminpresets\helper Class Reference

Admin presets helper class. More...

Static Public Member Functions

static add_item (int $presetid, string $name, string $value, ?string $plugin='none', ?string $advname=null, ?string $advvalue=null)
 Helper method to add a setting item to a preset.
 
static add_plugin (int $presetid, string $plugin, string $name, int $enabled)
 Helper method to add a plugin to a preset.
 
static change_default_preset (string $presetnameorfile)
 Apply the given preset.
 
static create_default_presets ()
 Helper method to create default site admin presets and initialize them.
 
static create_preset (array $data)
 Create an empty preset.
 

Detailed Description

Admin presets helper class.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ add_item()

static core_adminpresets\helper::add_item ( int $presetid,
string $name,
string $value,
?string $plugin = 'none',
?string $advname = null,
?string $advvalue = null )
static

Helper method to add a setting item to a preset.

Parameters
int$presetidPreset identifier where the item will belong.
string$nameItem name.
string$valueItem value.
string | null$pluginItem plugin.
string | null$advnameIf the item is an advanced setting, the name of the advanced setting should be specified here.
string | null$advvalueIf the item is an advanced setting, the value of the advanced setting should be specified here.
Return values
intThe item identificator.

◆ add_plugin()

static core_adminpresets\helper::add_plugin ( int $presetid,
string $plugin,
string $name,
int $enabled )
static

Helper method to add a plugin to a preset.

Parameters
int$presetidPreset identifier where the item will belong.
string$pluginPlugin type.
string$namePlugin name.
int$enabledWhether the plugin will be enabled or not.
Return values
intThe plugin identificator.

◆ change_default_preset()

static core_adminpresets\helper::change_default_preset ( string $presetnameorfile)
static

Apply the given preset.

If it's a filename, the preset will be imported and then applied.

Parameters
string$presetnameorfileThe preset name to be applied or a valid preset file to be imported and applied.
Return values
int|nullThe preset identifier that has been applied or null if the given value was not valid.

◆ create_preset()

static core_adminpresets\helper::create_preset ( array $data)
static

Create an empty preset.

Parameters
array$dataPreset data. Supported values:
  • name. To define the preset name.
  • comments. To change the comments field.
  • author. To update the author field.
  • iscore. Whether the preset is a core preset or not. Valid values on core_adminpresets\manager class.
Return values
intThe identifier of the preset created.

The documentation for this class was generated from the following file: