Admin tool presets manager class.
More...
|
| apply_preset (int $presetid, bool $simulate=false) |
| Apply a given preset.
|
|
| delete_preset (int $presetid) |
| Delete given preset.
|
|
| download_preset (int $presetid) |
| Create the XML content for a given preset.
|
|
| export_preset (stdClass $data) |
| Create a preset with the current settings and plugins information.
|
|
| get_setting ($settingdata, $currentvalue) |
| Returns the class type object.
|
|
| get_settings (array $dbsettings, bool $sitedbvalues=false, array $settings=[], $children=false) |
| Constructs an array with all the system settings.
|
|
| get_settings_from_db (array $dbsettings) |
| Gets the standarized settings array from DB records.
|
|
| get_site_settings () |
| Gets the system settings.
|
|
| import_preset (string $xmlcontent, ?string $presetname=null) |
| Import a given XML preset.
|
|
| revert_preset (int $presetappid) |
| Revert a given preset applied previously.
|
|
|
static | get_settings_class (string $classname) |
| Returns the settings class mapped to the defined $classname or null if it doesn't exist any associated class.
|
|
|
int const | FULL_PRESET = 2 |
| Full preset.
|
|
int const | NONCORE_PRESET = 0 |
| Non-core preset.
|
|
int const | STARTER_PRESET = 1 |
| Starter preset.
|
|
|
| apply_plugins (int $presetid, bool $simulate=false, ?int $adminpresetapplyid=null) |
| Apply plugins from a preset.
|
|
| apply_settings (int $presetid, bool $simulate=false, ?int $adminpresetapplyid=null) |
| Apply settings from a preset.
|
|
|
static array | $dbxmlrelations |
| Relation between database fields and XML files.
|
|
static array | $settingclassesmap |
| Setting classes mapping, to associated the local/setting class that should be used when there is no specific class.
|
|
Admin tool presets manager class.
- Copyright
- 2021 Pimenko suppo.nosp@m.rt@p.nosp@m.imenk.nosp@m.o.co.nosp@m.m<pimenko.com>
- Author
- Jordan Kesraoui | Sylvain Revenu | Pimenko based on David MonllaĆ³ david.nosp@m..mon.nosp@m.llao@.nosp@m.urv..nosp@m.cat code
- License
- http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
◆ apply_plugins()
core_adminpresets\manager::apply_plugins |
( |
int | $presetid, |
|
|
bool | $simulate = false, |
|
|
?int | $adminpresetapplyid = null ) |
|
protected |
Apply plugins from a preset.
- Parameters
-
int | $presetid | The preset identifier to apply. |
bool | $simulate | Whether this is a simulation or not. |
int | null | $adminpresetapplyid | The identifier of the adminpresetapply or null if it hasn't been created previously. |
- Return values
-
array | List with an array with the applied settings, another with the skipped ones and the adminpresetapplyid. |
◆ apply_preset()
core_adminpresets\manager::apply_preset |
( |
int | $presetid, |
|
|
bool | $simulate = false ) |
Apply a given preset.
- Parameters
-
int | $presetid | The preset identifier to apply. |
bool | $simulate | Whether this is a simulation or not. |
- Return values
-
array | List with an array with the applied settings and another with the skipped ones. |
◆ apply_settings()
core_adminpresets\manager::apply_settings |
( |
int | $presetid, |
|
|
bool | $simulate = false, |
|
|
?int | $adminpresetapplyid = null ) |
|
protected |
Apply settings from a preset.
- Parameters
-
int | $presetid | The preset identifier to apply. |
bool | $simulate | Whether this is a simulation or not. |
int | null | $adminpresetapplyid | The identifier of the adminpresetapply or null if it hasn't been created previously. |
- Return values
-
array | List with an array with the applied settings, another with the skipped ones and the adminpresetapplyid. |
◆ delete_preset()
core_adminpresets\manager::delete_preset |
( |
int | $presetid | ) |
|
Delete given preset.
- Parameters
-
int | $presetid | Preset identifier to delete. |
- Return values
-
◆ download_preset()
core_adminpresets\manager::download_preset |
( |
int | $presetid | ) |
|
Create the XML content for a given preset.
- Parameters
-
int | $presetid | The preset to download. |
- Return values
-
array | List with the XML content (string) and a filename proposal based on the preset name (string). |
◆ export_preset()
core_adminpresets\manager::export_preset |
( |
stdClass | $data | ) |
|
Create a preset with the current settings and plugins information.
- Parameters
-
stdClass | $data | Preset info, such as name or description, to be used when creating the preset with the current settings and plugins. |
- Return values
-
array | List with an the presetid created (int), a boolean to define if any setting has been found and another boolean to specify if any plugin has been found. |
◆ get_setting()
core_adminpresets\manager::get_setting |
( |
| $settingdata, |
|
|
| $currentvalue ) |
Returns the class type object.
- Parameters
-
object | $settingdata | Setting data |
mixed | $currentvalue | |
- Return values
-
◆ get_settings()
core_adminpresets\manager::get_settings |
( |
array | $dbsettings, |
|
|
bool | $sitedbvalues = false, |
|
|
array | $settings = [], |
|
|
| $children = false ) |
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.
- Parameters
-
array | $dbsettings | Standarized array, format $array['plugin']['name'] = obj('name'=>'settingname', 'value'=>'settingvalue') |
boolean | $sitedbvalues | Indicates if $dbsettings comes from the site db or not |
array | $settings | Array format $array['plugin']['settingname'] = settings_types child class |
array | false | $children | Array of admin_category children or false |
- Return values
-
core_adminpresets\local\setting\adminpresets_setting[][] | Array format $array['plugin']['settingname'] = adminpresets_setting child class |
◆ get_settings_class()
static core_adminpresets\manager::get_settings_class |
( |
string | $classname | ) |
|
|
static |
Returns the settings class mapped to the defined $classname or null if it doesn't exist any associated class.
- Parameters
-
string | $classname | The classname to get the mapped class. |
- Return values
-
◆ get_settings_from_db()
core_adminpresets\manager::get_settings_from_db |
( |
array | $dbsettings | ) |
|
Gets the standarized settings array from DB records.
- Parameters
-
array | $dbsettings | Array of objects |
- Return values
-
array | Standarized array, format $array['plugin']['name'] = obj('name'=>'settingname', 'value'=>'settingvalue') |
◆ get_site_settings()
core_adminpresets\manager::get_site_settings |
( |
| ) |
|
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 values
-
array\$settings | Array format $array['plugin']['settingname'] = settings_types child class |
◆ import_preset()
core_adminpresets\manager::import_preset |
( |
string | $xmlcontent, |
|
|
?string | $presetname = null ) |
Import a given XML preset.
- Parameters
-
string | $xmlcontent | The XML context with the preset to be imported. |
string | null | $presetname | The preset name that will overwrite the one given in the XML file. |
- Return values
-
array | List with an the XML element (SimpleXMLElement|null), the imported preset (stdClass|null), a boolean to define if any setting has been found and another boolean to specify if any plugin has been found. |
◆ revert_preset()
core_adminpresets\manager::revert_preset |
( |
int | $presetappid | ) |
|
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.
- Parameters
-
int | $presetappid | The appplied preset identifier to be reverted. |
- Return values
-
array | List with the presetapp removed (or null if there was some error), an array with the rollback settings/plugins changed and an array with the failures. |
◆ $dbxmlrelations
array core_adminpresets\manager::$dbxmlrelations |
|
staticprotected |
Initial value:= [
'name' => 'NAME',
'comments' => 'COMMENTS',
'timecreated' => 'PRESET_DATE',
'site' => 'SITE_URL',
'author' => 'AUTHOR',
'moodleversion' => 'MOODLE_VERSION',
'moodlerelease' => 'MOODLE_RELEASE'
]
Relation between database fields and XML files.
The documentation for this class was generated from the following file: