diff --git a/admin/index.php b/admin/index.php
index 1ca034bcfb4..943fea85259 100644
--- a/admin/index.php
+++ b/admin/index.php
@@ -722,7 +722,7 @@ if (during_initial_install()) {
// Apply default preset, if it is defined in $CFG and has a valid value.
if (!empty($CFG->setsitepresetduringinstall)) {
- \tool_admin_presets\helper::change_default_preset($CFG->setsitepresetduringinstall);
+ \core_adminpresets\helper::change_default_preset($CFG->setsitepresetduringinstall);
}
// we need this redirect to setup proper session
diff --git a/admin/settings/security.php b/admin/settings/security.php
index 91fb9a2cced..aa20b5e7834 100644
--- a/admin/settings/security.php
+++ b/admin/settings/security.php
@@ -141,11 +141,24 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
$temp->add(new admin_setting_configcheckbox('emailchangeconfirmation', new lang_string('emailchangeconfirmation', 'admin'), new lang_string('configemailchangeconfirmation', 'admin'), 1));
$temp->add(new admin_setting_configselect('rememberusername', new lang_string('rememberusername','admin'), new lang_string('rememberusername_desc','admin'), 2, array(1=>new lang_string('yes'), 0=>new lang_string('no'), 2=>new lang_string('optional'))));
$temp->add(new admin_setting_configcheckbox('strictformsrequired', new lang_string('strictformsrequired', 'admin'), new lang_string('configstrictformsrequired', 'admin'), 0));
+
+ $temp->add(new admin_setting_heading('adminpresets', new lang_string('siteadminpresetspluginname', 'core_adminpresets'), ''));
+ $sensiblesettingsdefault = 'recaptchapublickey@@none, recaptchaprivatekey@@none, googlemapkey3@@none, ';
+ $sensiblesettingsdefault .= 'secretphrase@@url, cronremotepassword@@none, smtpuser@@none, ';
+ $sensiblesettingsdefault .= 'smtppass@none, proxypassword@@none, quizpassword@@quiz, allowedip@@none, blockedip@@none, ';
+ $sensiblesettingsdefault .= 'dbpass@@logstore_database, messageinbound_hostpass@@none, ';
+ $sensiblesettingsdefault .= 'bind_pw@@auth_cas, pass@@auth_db, bind_pw@@auth_ldap, ';
+ $sensiblesettingsdefault .= 'dbpass@@enrol_database, bind_pw@@enrol_ldap, ';
+ $sensiblesettingsdefault .= 'server_password@@search_solr, ssl_keypassword@@search_solr, ';
+ $sensiblesettingsdefault .= 'alternateserver_password@@search_solr, alternatessl_keypassword@@search_solr, ';
+ $sensiblesettingsdefault .= 'test_password@@cachestore_redis, password@@mlbackend_python';
+ $temp->add(new admin_setting_configtextarea('adminpresets/sensiblesettings',
+ get_string('sensiblesettings', 'core_adminpresets'),
+ get_string('sensiblesettingstext', 'core_adminpresets'),
+ $sensiblesettingsdefault, PARAM_TEXT));
+
$ADMIN->add('security', $temp);
-
-
-
// "httpsecurity" settingpage
$temp = new admin_settingpage('httpsecurity', new lang_string('httpsecurity', 'admin'));
diff --git a/admin/tool/admin_presets/classes/event/preset_deleted.php b/admin/tool/admin_presets/classes/event/preset_deleted.php
index ecc47f1f237..a7027059da7 100644
--- a/admin/tool/admin_presets/classes/event/preset_deleted.php
+++ b/admin/tool/admin_presets/classes/event/preset_deleted.php
@@ -43,6 +43,6 @@ class preset_deleted extends base {
protected function init(): void {
$this->data['crud'] = 'd';
$this->data['edulevel'] = self::LEVEL_OTHER;
- $this->data['objecttable'] = 'tool_admin_presets';
+ $this->data['objecttable'] = 'adminpresets';
}
}
diff --git a/admin/tool/admin_presets/classes/event/preset_downloaded.php b/admin/tool/admin_presets/classes/event/preset_downloaded.php
index 48dc39e57a0..1db591aa9b0 100644
--- a/admin/tool/admin_presets/classes/event/preset_downloaded.php
+++ b/admin/tool/admin_presets/classes/event/preset_downloaded.php
@@ -44,6 +44,6 @@ class preset_downloaded extends base {
protected function init(): void {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
- $this->data['objecttable'] = 'tool_admin_presets';
+ $this->data['objecttable'] = 'adminpresets';
}
}
diff --git a/admin/tool/admin_presets/classes/event/preset_exported.php b/admin/tool/admin_presets/classes/event/preset_exported.php
index 8e5c926121b..810b58c6c1e 100644
--- a/admin/tool/admin_presets/classes/event/preset_exported.php
+++ b/admin/tool/admin_presets/classes/event/preset_exported.php
@@ -48,6 +48,6 @@ class preset_exported extends base {
protected function init(): void {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
- $this->data['objecttable'] = 'tool_admin_presets';
+ $this->data['objecttable'] = 'adminpresets';
}
}
diff --git a/admin/tool/admin_presets/classes/event/preset_imported.php b/admin/tool/admin_presets/classes/event/preset_imported.php
index 7e1b198b5a4..81835117890 100644
--- a/admin/tool/admin_presets/classes/event/preset_imported.php
+++ b/admin/tool/admin_presets/classes/event/preset_imported.php
@@ -48,6 +48,6 @@ class preset_imported extends base {
protected function init(): void {
$this->data['crud'] = 'c';
$this->data['edulevel'] = self::LEVEL_OTHER;
- $this->data['objecttable'] = 'tool_admin_presets';
+ $this->data['objecttable'] = 'adminpresets';
}
}
diff --git a/admin/tool/admin_presets/classes/event/preset_loaded.php b/admin/tool/admin_presets/classes/event/preset_loaded.php
index 2e8830a821d..86c87dc0c50 100644
--- a/admin/tool/admin_presets/classes/event/preset_loaded.php
+++ b/admin/tool/admin_presets/classes/event/preset_loaded.php
@@ -48,6 +48,6 @@ class preset_loaded extends base {
protected function init(): void {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
- $this->data['objecttable'] = 'tool_admin_presets';
+ $this->data['objecttable'] = 'adminpresets';
}
}
diff --git a/admin/tool/admin_presets/classes/event/preset_previewed.php b/admin/tool/admin_presets/classes/event/preset_previewed.php
index 3c66c59f7d8..dea2208a49a 100644
--- a/admin/tool/admin_presets/classes/event/preset_previewed.php
+++ b/admin/tool/admin_presets/classes/event/preset_previewed.php
@@ -44,6 +44,6 @@ class preset_previewed extends base {
protected function init(): void {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
- $this->data['objecttable'] = 'tool_admin_presets';
+ $this->data['objecttable'] = 'adminpresets';
}
}
diff --git a/admin/tool/admin_presets/classes/event/preset_reverted.php b/admin/tool/admin_presets/classes/event/preset_reverted.php
index 5f83eaac8b3..f7503cf47d4 100644
--- a/admin/tool/admin_presets/classes/event/preset_reverted.php
+++ b/admin/tool/admin_presets/classes/event/preset_reverted.php
@@ -43,6 +43,6 @@ class preset_reverted extends base {
protected function init(): void {
$this->data['crud'] = 'u';
$this->data['edulevel'] = self::LEVEL_OTHER;
- $this->data['objecttable'] = 'tool_admin_presets';
+ $this->data['objecttable'] = 'adminpresets';
}
}
diff --git a/admin/tool/admin_presets/classes/event/presets_listed.php b/admin/tool/admin_presets/classes/event/presets_listed.php
index 2b50877490e..650b6eee53e 100644
--- a/admin/tool/admin_presets/classes/event/presets_listed.php
+++ b/admin/tool/admin_presets/classes/event/presets_listed.php
@@ -47,6 +47,6 @@ class presets_listed extends base {
protected function init(): void {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_OTHER;
- $this->data['objecttable'] = 'tool_admin_presets';
+ $this->data['objecttable'] = 'adminpresets';
}
}
diff --git a/admin/tool/admin_presets/classes/helper.php b/admin/tool/admin_presets/classes/helper.php
deleted file mode 100644
index 6e65815c669..00000000000
--- a/admin/tool/admin_presets/classes/helper.php
+++ /dev/null
@@ -1,162 +0,0 @@
-.
-
-namespace tool_admin_presets;
-
-/**
- * Admin tool presets helper class.
- *
- * @package tool_admin_presets
- * @copyright 2021 Sara Arjona (sara@moodle.com)
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-class helper {
-
- /**
- * Create an empty preset.
- *
- * @param array $data Preset 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.
- * @return int The identifier of the preset created.
- */
- public static function create_preset(array $data): int {
- global $CFG, $USER, $DB;
-
- $name = array_key_exists('name', $data) ? $data['name'] : '';
- $comments = array_key_exists('comments', $data) ? $data['comments'] : '';
- $author = array_key_exists('author', $data) ? $data['author'] : fullname($USER);
- $iscore = array_key_exists('iscore', $data) ? $data['iscore'] : 0;
-
- $preset = [
- 'userid' => $USER->id,
- 'name' => $name,
- 'comments' => $comments,
- 'site' => $CFG->wwwroot,
- 'author' => $author,
- 'moodleversion' => $CFG->version,
- 'moodlerelease' => $CFG->release,
- 'iscore' => $iscore,
- 'timecreated' => time(),
- 'timeimported' => 0,
- ];
-
- $presetid = $DB->insert_record('tool_admin_presets', $preset);
- return $presetid;
- }
-
- /**
- * 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.
- */
- public static function add_item(int $presetid, string $name, string $value, ?string $plugin = 'none',
- ?string $advname = null, ?string $advvalue = null): int {
- global $DB;
-
- $presetitem = [
- 'adminpresetid' => $presetid,
- 'plugin' => $plugin,
- 'name' => $name,
- 'value' => $value,
- ];
- $itemid = $DB->insert_record('tool_admin_presets_it', $presetitem);
-
- if (!empty($advname)) {
- $presetadv = [
- 'itemid' => $itemid,
- 'name' => $advname,
- 'value' => $advvalue,
- ];
- $DB->insert_record('tool_admin_presets_it_a', $presetadv);
- }
-
- return $itemid;
- }
-
- /**
- * 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.
- */
- public static function add_plugin(int $presetid, string $plugin, string $name, int $enabled): int {
- global $DB;
-
- $pluginentry = [
- 'adminpresetid' => $presetid,
- 'plugin' => $plugin,
- 'name' => $name,
- 'enabled' => $enabled,
- ];
- $pluginid = $DB->insert_record('tool_admin_presets_plug', $pluginentry);
-
- return $pluginid;
- }
-
- /**
- * 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.
- */
- public static function change_default_preset(string $presetnameorfile): ?int {
- global $DB;
-
- $presetid = null;
-
- // Check if the given variable points to a valid preset file to be imported and applied.
- if (is_readable($presetnameorfile)) {
- $xmlcontent = file_get_contents($presetnameorfile);
- $manager = new manager();
- list($xmlnotused, $preset) = $manager->import_preset($xmlcontent);
- if (!is_null($preset)) {
- list($applied) = $manager->apply_preset($preset->id);
- if (!empty($applied)) {
- $presetid = $preset->id;
- }
- }
- } else {
- // Check if the given preset exists; if that's the case, it will be applied.
- $stringmanager = get_string_manager();
- if ($stringmanager->string_exists($presetnameorfile . 'preset', 'tool_admin_presets')) {
- $params = ['name' => get_string($presetnameorfile . 'preset', 'tool_admin_presets')];
- } else {
- $params = ['name' => $presetnameorfile];
- }
- if ($preset = $DB->get_record('tool_admin_presets', $params)) {
- $manager = new manager();
- list($applied) = $manager->apply_preset($preset->id);
- if (!empty($applied)) {
- $presetid = $preset->id;
- }
- }
- }
-
- return $presetid;
- }
-}
diff --git a/admin/tool/admin_presets/classes/local/action/base.php b/admin/tool/admin_presets/classes/local/action/base.php
index 5b0fe88a415..e4cadfff8c0 100644
--- a/admin/tool/admin_presets/classes/local/action/base.php
+++ b/admin/tool/admin_presets/classes/local/action/base.php
@@ -18,7 +18,7 @@ namespace tool_admin_presets\local\action;
use context_system;
use moodle_url;
-use tool_admin_presets\manager;
+use core_adminpresets\manager;
use tool_admin_presets\output\presets_list;
use tool_admin_presets\output\export_import;
@@ -84,7 +84,7 @@ class base {
$options = new export_import();
$this->outputs = $OUTPUT->render($options);
- $presets = $DB->get_records('tool_admin_presets');
+ $presets = $DB->get_records('adminpresets');
$list = new presets_list($presets, true);
$this->outputs .= $OUTPUT->render($list);
}
diff --git a/admin/tool/admin_presets/classes/local/action/delete.php b/admin/tool/admin_presets/classes/local/action/delete.php
index 488508fbd95..1ab72109531 100644
--- a/admin/tool/admin_presets/classes/local/action/delete.php
+++ b/admin/tool/admin_presets/classes/local/action/delete.php
@@ -35,7 +35,7 @@ class delete extends base {
global $DB, $OUTPUT;
// Getting the preset name.
- $presetdata = $DB->get_record('tool_admin_presets', ['id' => $this->id], 'name');
+ $presetdata = $DB->get_record('adminpresets', ['id' => $this->id], 'name');
if ($presetdata) {
$deletetext = get_string('deletepreset', 'tool_admin_presets', $presetdata->name);
@@ -46,7 +46,7 @@ class delete extends base {
$cancelurl = new \moodle_url('/admin/tool/admin_presets/index.php');
// If the preset was applied add a warning text.
- if ($DB->get_records('tool_admin_presets_app', ['adminpresetid' => $this->id])) {
+ if ($DB->get_records('adminpresets_app', ['adminpresetid' => $this->id])) {
$deletetext .= '
' .
get_string("deletepreviouslyapplied", "tool_admin_presets") . '
';
}
@@ -56,7 +56,7 @@ class delete extends base {
];
$this->outputs = $OUTPUT->confirm($deletetext, $confirmurl, $cancelurl, $displayoptions);
} else {
- throw new moodle_exception('errordeleting', 'tool_admin_presets');
+ throw new moodle_exception('errordeleting', 'core_adminpresets');
}
}
diff --git a/admin/tool/admin_presets/classes/local/action/load.php b/admin/tool/admin_presets/classes/local/action/load.php
index dd1679fc4dd..76f41a52e69 100644
--- a/admin/tool/admin_presets/classes/local/action/load.php
+++ b/admin/tool/admin_presets/classes/local/action/load.php
@@ -100,8 +100,8 @@ class load extends base {
$data->id = $this->id;
// Preset data.
- if (!$preset = $DB->get_record('tool_admin_presets', ['id' => $data->id])) {
- throw new moodle_exception('errornopreset', 'tool_admin_presets');
+ if (!$preset = $DB->get_record('adminpresets', ['id' => $data->id])) {
+ throw new moodle_exception('errornopreset', 'core_adminpresets');
}
// Print preset basic data.
diff --git a/admin/tool/admin_presets/classes/local/action/rollback.php b/admin/tool/admin_presets/classes/local/action/rollback.php
index 9a37f057920..18ff777b583 100644
--- a/admin/tool/admin_presets/classes/local/action/rollback.php
+++ b/admin/tool/admin_presets/classes/local/action/rollback.php
@@ -36,11 +36,11 @@ class rollback extends base {
global $DB, $OUTPUT;
// Preset data.
- $preset = $DB->get_record('tool_admin_presets', ['id' => $this->id]);
+ $preset = $DB->get_record('adminpresets', ['id' => $this->id]);
// Applications data.
$context = new stdClass();
- $applications = $DB->get_records('tool_admin_presets_app', ['adminpresetid' => $this->id], 'time DESC');
+ $applications = $DB->get_records('adminpresets_app', ['adminpresetid' => $this->id], 'time DESC');
$context->noapplications = !empty($applications);
$context->applications = [];
foreach ($applications as $application) {
@@ -106,7 +106,7 @@ class rollback extends base {
global $DB;
$title = '';
- if ($preset = $DB->get_record('tool_admin_presets', ['id' => $this->id])) {
+ if ($preset = $DB->get_record('adminpresets', ['id' => $this->id])) {
$title = get_string($this->action . $this->mode, 'tool_admin_presets', $preset->name);
}
diff --git a/admin/tool/admin_presets/classes/output/presets_list.php b/admin/tool/admin_presets/classes/output/presets_list.php
index 0691b547916..c1dc56bb990 100644
--- a/admin/tool/admin_presets/classes/output/presets_list.php
+++ b/admin/tool/admin_presets/classes/output/presets_list.php
@@ -118,7 +118,7 @@ class presets_list implements renderable, templatable {
}
// Look for preset applications.
- if ($DB->get_records('tool_admin_presets_app', ['adminpresetid' => $preset->id])) {
+ if ($DB->get_records('adminpresets_app', ['adminpresetid' => $preset->id])) {
$params = ['action' => 'rollback', 'id' => $preset->id];
$rollbacklink = new \moodle_url('/admin/tool/admin_presets/index.php', $params);
$actionsmenu->add(new \action_menu_link_secondary(
diff --git a/admin/tool/admin_presets/classes/privacy/provider.php b/admin/tool/admin_presets/classes/privacy/provider.php
index 26266050499..d276964067c 100644
--- a/admin/tool/admin_presets/classes/privacy/provider.php
+++ b/admin/tool/admin_presets/classes/privacy/provider.php
@@ -16,12 +16,6 @@
namespace tool_admin_presets\privacy;
-use core_privacy\local\metadata\collection;
-use core_privacy\local\request\approved_contextlist;
-use core_privacy\local\request\approved_userlist;
-use core_privacy\local\request\contextlist;
-use core_privacy\local\request\userlist;
-
/**
* Admin tool presets this file handle privacy provider.
*
@@ -30,96 +24,14 @@ use core_privacy\local\request\userlist;
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class provider implements
- \core_privacy\local\metadata\provider,
- \core_privacy\local\request\subsystem\provider,
- \core_privacy\local\request\core_userlist_provider {
-
+class provider implements \core_privacy\local\metadata\null_provider {
/**
- * Returns information about the user data stored in this component.
+ * Get the language string identifier with the component's language
+ * file to explain why this plugin stores no data.
*
- * @param collection $collection A list of information about this component
- * @return collection The collection object filled out with information about this component.
+ * @return string
*/
- public static function get_metadata(collection $collection) : collection {
- // These tables are really data about site configuration and not user data.
-
- // The tool_admin_presets includes information about which user performed a configuration change using the admin_presets
- // tool.
- // This is not considered to be user data.
- $collection->add_database_table('tool_admin_presets', [
- 'userid' => 'privacy:metadata:admin_presets:userid',
- 'name' => 'privacy:metadata:admin_presets:name',
- 'comments' => 'privacy:metadata:admin_presets:comments',
- 'site' => 'privacy:metadata:admin_presets:site',
- 'moodlerelease' => 'privacy:metadata:admin_presets:moodlerelease',
- 'timecreated' => 'privacy:metadata:admin_presets:timecreated',
- ], 'privacy:metadata:admin_presets');
-
- // The tool_admin_presets_app includes information about which user performed configuration change using the admin_presets
- // tool.
- // This is not considered to be user data.
- $collection->add_database_table('tool_admin_presets_app', [
- 'adminpresetid' => 'privacy:metadata:tool_admin_presets_app:adminpresetid',
- 'userid' => 'privacy:metadata:tool_admin_presets_app:userid',
- 'time' => 'privacy:metadata:tool_admin_presets_app:time',
- ], 'privacy:metadata:tool_admin_presets_app');
-
- return $collection;
- }
-
- /**
- * Get the list of contexts that contain user information for the specified user.
- *
- * @param int $userid The user to search.
- * @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin.
- */
- public static function get_contexts_for_userid(int $userid) : contextlist {
- return new contextlist();
- }
-
- /**
- * Get the list of users who have data within a context.
- *
- * @param userlist $userlist The userlist containing the list of users who have data in this context/plugin combination.
- */
- public static function get_users_in_context(userlist $userlist) {
- // Don't add any user.
- }
-
- /**
- * Export all user data for the specified user, in the specified contexts.
- *
- * @param approved_contextlist $contextlist The approved contexts to export information for.
- */
- public static function export_user_data(approved_contextlist $contextlist) {
- // None of the core tables should be exported.
- }
-
- /**
- * Delete all data for all users in the specified context.
- *
- * @param context $context The specific context to delete data for.
- */
- public static function delete_data_for_all_users_in_context(\context $context) {
- // None of the the data from these tables should be deleted.
- }
-
- /**
- * Delete all user data for the specified user, in the specified contexts.
- *
- * @param approved_contextlist $contextlist The approved contexts and user information to delete information for.
- */
- public static function delete_data_for_user(approved_contextlist $contextlist) {
- // None of the the data from these tables should be deleted.
- }
-
- /**
- * Delete multiple users within a single context.
- *
- * @param approved_userlist $userlist The approved context and user information to delete information for.
- */
- public static function delete_data_for_users(approved_userlist $userlist) {
- // None of the the data from these tables should be deleted.
+ public static function get_reason() : string {
+ return 'privacy:metadata';
}
}
diff --git a/admin/tool/admin_presets/db/install.php b/admin/tool/admin_presets/db/install.php
deleted file mode 100644
index e05e5119a93..00000000000
--- a/admin/tool/admin_presets/db/install.php
+++ /dev/null
@@ -1,253 +0,0 @@
-.
-
-/**
- * Install code for Admin tool presets plugin.
- *
- * @package tool_admin_presets
- * @copyright 2021 Sara Arjona (sara@moodle.com)
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die;
-
-use tool_admin_presets\helper;
-
-/**
- * Perform the post-install procedures.
- */
-function xmldb_tool_admin_presets_install() {
-
- // Create the "Starter" site admin preset.
- $data = [
- 'name' => get_string('starterpreset', 'tool_admin_presets'),
- 'comments' => get_string('starterpresetdescription', 'tool_admin_presets'),
- 'iscore' => 1,
- ];
- $presetid = helper::create_preset($data);
-
- // Add settings to the "Starter" site admin preset.
- helper::add_item($presetid, 'usecomments', '0');
- helper::add_item($presetid, 'usetags', '0');
- helper::add_item($presetid, 'enablenotes', '0');
- helper::add_item($presetid, 'enableblogs', '0');
- helper::add_item($presetid, 'enablebadges', '0');
- helper::add_item($presetid, 'enableanalytics', '0');
- helper::add_item($presetid, 'enabled', '0', 'core_competency');
- helper::add_item($presetid, 'pushcourseratingstouserplans', '0', 'core_competency');
-
- helper::add_item($presetid, 'showdataretentionsummary', '0', 'tool_dataprivacy');
- helper::add_item($presetid, 'forum_maxattachments', '3');
- helper::add_item($presetid, 'customusermenuitems', 'profile,moodle|/user/profile.php
-grades,grades|/grade/report/mygrades.php
-calendar,core_calendar|/calendar/view.php?view=month
-privatefiles,moodle|/user/files.php');
-
- // Modules: Hide chat, database, external tool (lti), IMS content package (imscp), lesson, SCORM, survey, wiki, workshop.
- helper::add_plugin($presetid, 'mod', 'chat', false);
- helper::add_plugin($presetid, 'mod', 'data', false);
- helper::add_plugin($presetid, 'mod', 'lti', false);
- helper::add_plugin($presetid, 'mod', 'imscp', false);
- helper::add_plugin($presetid, 'mod', 'lesson', false);
- helper::add_plugin($presetid, 'mod', 'scorm', false);
- helper::add_plugin($presetid, 'mod', 'survey', false);
- helper::add_plugin($presetid, 'mod', 'wiki', false);
- helper::add_plugin($presetid, 'mod', 'workshop', false);
-
- // Availability restrictions: Hide Grouping, User profile.
- helper::add_plugin($presetid, 'availability', 'grouping', false);
- helper::add_plugin($presetid, 'availability', 'profile', false);
-
- // Blocks: Disable Activities, Blog menu, Blog tags, Comments, Course completion status, Course/site summary, Courses, Flickr,
- // Global search, Latest badges, Learning plans, Logged in user, Login, Main menu, Mentees, Network servers, Private files,
- // Recent blog entries, RSS feeds, Search forums, Section links,Self completion, Social activities, Tags, YouTube.
- helper::add_plugin($presetid, 'block', 'activity_modules', false);
- helper::add_plugin($presetid, 'block', 'blog_menu', false);
- helper::add_plugin($presetid, 'block', 'blog_tags', false);
- helper::add_plugin($presetid, 'block', 'comments', false);
- helper::add_plugin($presetid, 'block', 'completionstatus', false);
- helper::add_plugin($presetid, 'block', 'course_summary', false);
- helper::add_plugin($presetid, 'block', 'course_list', false);
- helper::add_plugin($presetid, 'block', 'tag_flickr', false);
- helper::add_plugin($presetid, 'block', 'globalsearch', false);
- helper::add_plugin($presetid, 'block', 'badges', false);
- helper::add_plugin($presetid, 'block', 'lp', false);
- helper::add_plugin($presetid, 'block', 'myprofile', false);
- helper::add_plugin($presetid, 'block', 'login', false);
- helper::add_plugin($presetid, 'block', 'site_main_menu', false);
- helper::add_plugin($presetid, 'block', 'mentees', false);
- helper::add_plugin($presetid, 'block', 'mnet_hosts', false);
- helper::add_plugin($presetid, 'block', 'private_files', false);
- helper::add_plugin($presetid, 'block', 'blog_recent', false);
- helper::add_plugin($presetid, 'block', 'rss_client', false);
- helper::add_plugin($presetid, 'block', 'search_forums', false);
- helper::add_plugin($presetid, 'block', 'section_links', false);
- helper::add_plugin($presetid, 'block', 'selfcompletion', false);
- helper::add_plugin($presetid, 'block', 'social_activities', false);
- helper::add_plugin($presetid, 'block', 'tags', false);
- helper::add_plugin($presetid, 'block', 'tag_youtube', false);
- helper::add_plugin($presetid, 'block', 'feedback', false);
-
- // Course formats: Disable Social format.
- helper::add_plugin($presetid, 'format', 'social', false);
-
- // Data formats: Disable Javascript Object Notation (.json).
- helper::add_plugin($presetid, 'dataformat', 'json', false);
-
- // Enrolments: Disable Cohort sync.
- helper::add_plugin($presetid, 'enrol', 'cohort', false);
-
- // Filter: Disable MathJax, Activity names auto-linking.
- helper::add_plugin($presetid, 'filter', 'mathjaxloader', TEXTFILTER_DISABLED);
- helper::add_plugin($presetid, 'filter', 'activitynames', TEXTFILTER_DISABLED);
-
- // Question behaviours: Disable Adaptive mode (no penalties), Deferred feedback with CBM, Immediate feedback with CBM.
- helper::add_plugin($presetid, 'qbehaviour', 'adaptivenopenalty', false);
- helper::add_plugin($presetid, 'qbehaviour', 'deferredcbm', false);
- helper::add_plugin($presetid, 'qbehaviour', 'immediatecbm', false);
-
- // Question types: Disable Calculated, Calculated multichoice, Calculated simple, Description, Drag and drop markers,
- // Drag and drop onto image, Embedded answers (Cloze), Essay, Numerical, Random short-answer matching.
- helper::add_plugin($presetid, 'qtype', 'calculated', false);
- helper::add_plugin($presetid, 'qtype', 'calculatedmulti', false);
- helper::add_plugin($presetid, 'qtype', 'calculatedsimple', false);
- helper::add_plugin($presetid, 'qtype', 'description', false);
- helper::add_plugin($presetid, 'qtype', 'ddmarker', false);
- helper::add_plugin($presetid, 'qtype', 'ddimageortext', false);
- helper::add_plugin($presetid, 'qtype', 'multianswer', false);
- helper::add_plugin($presetid, 'qtype', 'essay', false);
- helper::add_plugin($presetid, 'qtype', 'numerical', false);
- helper::add_plugin($presetid, 'qtype', 'randomsamatch', false);
-
- // Repositories: Disable Server files, URL downloader, Wikimedia.
- helper::add_plugin($presetid, 'repository', 'local', false);
- helper::add_plugin($presetid, 'repository', 'url', false);
- helper::add_plugin($presetid, 'repository', 'wikimedia', false);
-
- // Text editors: Disable TinyMCE HTML editor.
- helper::add_plugin($presetid, 'editor', 'tinymce', false);
-
- // Create the "Full" site admin preset.
- $data = [
- 'name' => get_string('fullpreset', 'tool_admin_presets'),
- 'comments' => get_string('fullpresetdescription', 'tool_admin_presets'),
- 'iscore' => 1,
- ];
- $presetid = helper::create_preset($data);
-
- // Add settings to the "Full" site admin preset.
- helper::add_item($presetid, 'usecomments', '1');
- helper::add_item($presetid, 'usetags', '1');
- helper::add_item($presetid, 'enablenotes', '1');
- helper::add_item($presetid, 'enableblogs', '1');
- helper::add_item($presetid, 'enablebadges', '1');
- helper::add_item($presetid, 'enableanalytics', '1');
- helper::add_item($presetid, 'enabled', '1', 'core_competency');
- helper::add_item($presetid, 'pushcourseratingstouserplans', '1', 'core_competency');
-
- helper::add_item($presetid, 'showdataretentionsummary', '1', 'tool_dataprivacy');
- helper::add_item($presetid, 'forum_maxattachments', '9');
- // In that case, the indentation coding style can't follow the rules to guarantee the setting value is created properly.
- helper::add_item($presetid, 'customusermenuitems', 'profile,moodle|/user/profile.php
-grades,grades|/grade/report/mygrades.php
-calendar,core_calendar|/calendar/view.php?view=month
-privatefiles,moodle|/user/files.php'
- );
-
- // Modules: Enable chat, database, external tool (lti), IMS content package (imscp), lesson, SCORM, survey, wiki, workshop.
- helper::add_plugin($presetid, 'mod', 'chat', true);
- helper::add_plugin($presetid, 'mod', 'data', true);
- helper::add_plugin($presetid, 'mod', 'lti', true);
- helper::add_plugin($presetid, 'mod', 'imscp', true);
- helper::add_plugin($presetid, 'mod', 'lesson', true);
- helper::add_plugin($presetid, 'mod', 'scorm', true);
- helper::add_plugin($presetid, 'mod', 'survey', true);
- helper::add_plugin($presetid, 'mod', 'wiki', true);
- helper::add_plugin($presetid, 'mod', 'workshop', true);
-
- // Availability restrictions: Enable Grouping, User profile.
- helper::add_plugin($presetid, 'availability', 'grouping', true);
- helper::add_plugin($presetid, 'availability', 'profile', true);
-
- // Blocks: Enable Activities, Blog menu, Blog tags, Comments, Course completion status, Course/site summary, Courses, Flickr,
- // Global search, Latest badges, Learning plans, Logged in user, Login, Main menu, Mentees, Network servers, Private files,
- // Recent blog entries, RSS feeds, Search forums, Section links,Self completion, Social activities, Tags, YouTube.
- helper::add_plugin($presetid, 'block', 'activity_modules', true);
- helper::add_plugin($presetid, 'block', 'blog_menu', true);
- helper::add_plugin($presetid, 'block', 'blog_tags', true);
- helper::add_plugin($presetid, 'block', 'comments', true);
- helper::add_plugin($presetid, 'block', 'completionstatus', true);
- helper::add_plugin($presetid, 'block', 'course_summary', true);
- helper::add_plugin($presetid, 'block', 'course_list', true);
- helper::add_plugin($presetid, 'block', 'tag_flickr', true);
- helper::add_plugin($presetid, 'block', 'globalsearch', true);
- helper::add_plugin($presetid, 'block', 'badges', true);
- helper::add_plugin($presetid, 'block', 'lp', true);
- helper::add_plugin($presetid, 'block', 'myprofile', true);
- helper::add_plugin($presetid, 'block', 'login', true);
- helper::add_plugin($presetid, 'block', 'site_main_menu', true);
- helper::add_plugin($presetid, 'block', 'mentees', true);
- helper::add_plugin($presetid, 'block', 'mnet_hosts', true);
- helper::add_plugin($presetid, 'block', 'private_files', true);
- helper::add_plugin($presetid, 'block', 'blog_recent', true);
- helper::add_plugin($presetid, 'block', 'rss_client', true);
- helper::add_plugin($presetid, 'block', 'search_forums', true);
- helper::add_plugin($presetid, 'block', 'section_links', true);
- helper::add_plugin($presetid, 'block', 'selfcompletion', true);
- helper::add_plugin($presetid, 'block', 'social_activities', true);
- helper::add_plugin($presetid, 'block', 'tags', true);
- helper::add_plugin($presetid, 'block', 'feedback', true);
-
- // Course formats: Enable Social format.
- helper::add_plugin($presetid, 'format', 'social', true);
-
- // Data formats: Enable Javascript Object Notation (.json).
- helper::add_plugin($presetid, 'dataformat', 'json', true);
-
- // Enrolments: Enable Cohort sync.
- helper::add_plugin($presetid, 'enrol', 'cohort', true);
-
- // Filter: Enable MathJax, Activity names auto-linking.
- helper::add_plugin($presetid, 'filter', 'mathjaxloader', TEXTFILTER_ON);
- helper::add_plugin($presetid, 'filter', 'activitynames', TEXTFILTER_ON);
-
- // Question behaviours: Enable Adaptive mode (no penalties), Deferred feedback with CBM, Immediate feedback with CBM.
- helper::add_plugin($presetid, 'qbehaviour', 'adaptivenopenalty', true);
- helper::add_plugin($presetid, 'qbehaviour', 'deferredcbm', true);
- helper::add_plugin($presetid, 'qbehaviour', 'immediatecbm', true);
-
- // Question types: Enable Calculated, Calculated multichoice, Calculated simple, Description, Drag and drop markers,
- // Drag and drop onto image, Embedded answers (Cloze), Essay, Numerical, Random short-answer matching.
- helper::add_plugin($presetid, 'qtype', 'calculated', true);
- helper::add_plugin($presetid, 'qtype', 'calculatedmulti', true);
- helper::add_plugin($presetid, 'qtype', 'calculatedsimple', true);
- helper::add_plugin($presetid, 'qtype', 'description', true);
- helper::add_plugin($presetid, 'qtype', 'ddmarker', true);
- helper::add_plugin($presetid, 'qtype', 'ddimageortext', true);
- helper::add_plugin($presetid, 'qtype', 'multianswer', true);
- helper::add_plugin($presetid, 'qtype', 'essay', true);
- helper::add_plugin($presetid, 'qtype', 'numerical', true);
- helper::add_plugin($presetid, 'qtype', 'randomsamatch', true);
-
- // Repositories: Enable Server files, URL downloader, Wikimedia.
- helper::add_plugin($presetid, 'repository', 'local', true);
- helper::add_plugin($presetid, 'repository', 'url', true);
- helper::add_plugin($presetid, 'repository', 'wikimedia', true);
-
- // Text editors: Enable TinyMCE HTML editor.
- helper::add_plugin($presetid, 'editor', 'tinymce', true);
-
-}
diff --git a/admin/tool/admin_presets/db/install.xml b/admin/tool/admin_presets/db/install.xml
deleted file mode 100644
index de81e87d88c..00000000000
--- a/admin/tool/admin_presets/db/install.xml
+++ /dev/null
@@ -1,173 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/admin/tool/admin_presets/db/upgrade.php b/admin/tool/admin_presets/db/upgrade.php
deleted file mode 100644
index 0c8774ef204..00000000000
--- a/admin/tool/admin_presets/db/upgrade.php
+++ /dev/null
@@ -1,38 +0,0 @@
-.
-
-/**
- * Admin tool presets plugin to load some settings.
- *
- * @package tool_admin_presets
- * @copyright 2021 Pimenko
- * @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
- * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- */
-
-defined('MOODLE_INTERNAL') || die();
-
-
-/**
- * Function to upgrade tool_admin_presets.
- *
- * @param int $oldversion the version we are upgrading from
- * @return bool result
- */
-function xmldb_tool_admin_presets_upgrade($oldversion): bool {
-
- return true;
-}
diff --git a/admin/tool/admin_presets/lang/en/tool_admin_presets.php b/admin/tool/admin_presets/lang/en/tool_admin_presets.php
index 9367b64b947..570f7c917f6 100644
--- a/admin/tool/admin_presets/lang/en/tool_admin_presets.php
+++ b/admin/tool/admin_presets/lang/en/tool_admin_presets.php
@@ -37,12 +37,6 @@ $string['deletepreset'] = 'Are you sure you want to delete "{$a}" site admin pre
$string['deletepreviouslyapplied'] = 'This preset has been previously applied. Deleting a preset removes it from your site completely. You will not be able to revert your settings to how they were before applying this preset';
$string['deletepresettitle'] = 'Delete {$a} preset?';
$string['deleteshow'] = 'Delete site admin preset';
-$string['disabled'] = 'Disabled';
-$string['disabledwithvalue'] = 'Disabled ({$a})';
-$string['enabled'] = 'Enabled';
-$string['errordeleting'] = 'Error deleting from database.';
-$string['errorinserting'] = 'Error inserting into database.';
-$string['errornopreset'] = 'It doesn\'t exists a preset with that name.';
$string['eventpresetdeleted'] = 'Preset deleted';
$string['eventpresetdownloaded'] = 'Preset downloaded';
$string['eventpresetexported'] = 'Preset created';
@@ -55,8 +49,6 @@ $string['exportdescription'] = 'Save all your current site admin settings as a p
$string['exportshow'] = 'Create site admin preset';
$string['falseaction'] = 'Action not supported in this version.';
$string['falsemode'] = 'Mode not supported in this version.';
-$string['fullpreset'] = 'Full';
-$string['fullpresetdescription'] = 'All the Starter features plus External (LTI) tool, SCORM, Workshop, Analytics, Badges, Competencies, Learning plans and lots more.';
$string['import'] = 'Import';
$string['imported'] = 'Imported';
$string['importdescription'] = 'Import site admin settings as a preset to apply to your site.';
@@ -64,19 +56,11 @@ $string['importexecute'] = 'Import site admin preset';
$string['importshow'] = 'Import site admin preset';
$string['includesensiblesettings'] = 'Include settings with passwords';
$string['includesensiblesettings_help'] = 'Settings with passwords contain sensitive information specific to your site. Only include these settings if you are creating a preset to reuse on your site. You can find the list of settings with passwords in Site admin preset settings in the Site administration';
-$string['starterpreset'] = 'Starter';
-$string['starterpresetdescription'] = 'Moodle with all of the most popular features, including Assignment, Feedback, Forum, H5P, Quiz and Completion tracking.';
$string['loaddescription'] = 'Review the setting changes before applying this preset.';
$string['loadexecute'] = 'Site admin preset applied';
$string['loadpreview'] = 'Preview site admin preset';
$string['loadselected'] = 'Apply';
$string['loadshow'] = 'Apply site admin preset';
-$string['markedasadvanced'] = 'marked as advanced';
-$string['markedasforced'] = 'marked as forced';
-$string['markedaslocked'] = 'marked as locked';
-$string['markedasnonadvanced'] = 'marked as non advanced';
-$string['markedasnonforced'] = 'marked as non forced';
-$string['markedasnonlocked'] = 'marked as non locked';
$string['newvalue'] = 'New value';
$string['nopresets'] = 'You don\'t have any site admin preset.';
$string['nosettingswillbeapplied'] = 'These settings are the same as the current settings; there are no changes to apply.';
@@ -91,17 +75,7 @@ $string['presetmoodlerelease'] = 'Moodle release';
$string['presetname'] = 'Preset name';
$string['presetsettings'] = 'Preset settings';
$string['previewpreset'] = 'Preview preset';
-$string['privacy:metadata:admin_presets'] = 'The list of configuration presets.';
-$string['privacy:metadata:admin_presets:comments'] = 'A description about the preset.';
-$string['privacy:metadata:admin_presets:moodlerelease'] = 'The Moodle release version where the preset is based on.';
-$string['privacy:metadata:admin_presets:name'] = 'The name of the preset.';
-$string['privacy:metadata:admin_presets:site'] = 'The Moodle site where this preset was created.';
-$string['privacy:metadata:admin_presets:timecreated'] = 'The time that the change was made.';
-$string['privacy:metadata:admin_presets:userid'] = 'The user who create the preset.';
-$string['privacy:metadata:tool_admin_presets_app'] = 'The configuration presets that have been applied.';
-$string['privacy:metadata:tool_admin_presets_app:adminpresetid'] = 'The id of the preset applied.';
-$string['privacy:metadata:tool_admin_presets_app:time'] = 'The time that the preset was applied.';
-$string['privacy:metadata:tool_admin_presets_app:userid'] = 'The user who applied the preset.';
+$string['privacy:metadata'] = 'The Site admin presets tool does not store any personal data.';
$string['renamepreset'] = 'Name (optional)';
$string['rollback'] = 'Restore this version';
$string['rollbackdescription'] = 'Use the \'Restore this version\' link to revert to the settings just before the preset was applied.';
@@ -110,8 +84,6 @@ $string['rollbackfailures'] = 'The following settings can not be restored, the a
$string['rollbackresults'] = 'Settings successfully restored';
$string['rollbackshow'] = '{$a} preset version history';
$string['selectfile'] = 'Select file';
-$string['sensiblesettings'] = 'Settings with passwords';
-$string['sensiblesettingstext'] = 'Settings with passwords or other sensitive information can be excluded when creating a site admin preset. Enter additional settings with format SETTINGNAME@@PLUGINNAME separated by commas.';
$string['settingname'] = 'Setting name';
$string['settingsapplied'] = 'Setting changes';
$string['settingsappliednotification'] = 'Review the following setting changes which have been applied.
@@ -124,4 +96,3 @@ $string['site'] = 'Site';
$string['skippedchanges'] = 'Skipped settings table';
$string['timeapplied'] = 'Date';
$string['wrongfile'] = 'Wrong file';
-$string['wrongid'] = 'Wrong id';
diff --git a/admin/tool/admin_presets/settings.php b/admin/tool/admin_presets/settings.php
index 7dc63082f0f..25a7e7c8ba4 100644
--- a/admin/tool/admin_presets/settings.php
+++ b/admin/tool/admin_presets/settings.php
@@ -26,27 +26,7 @@
defined('MOODLE_INTERNAL') || die();
if ($hassiteconfig) {
-
$ADMIN->add('root', new admin_externalpage('tool_admin_presets',
get_string('pluginname', 'tool_admin_presets'),
new moodle_url('/admin/tool/admin_presets/index.php')));
-
- $settings = new admin_settingpage('tool_admin_presets_settings', get_string('pluginname', 'tool_admin_presets'));
- $ADMIN->add('tools', $settings);
-
- $sensiblesettingsdefault = 'recaptchapublickey@@none, recaptchaprivatekey@@none, googlemapkey3@@none, ';
- $sensiblesettingsdefault .= 'secretphrase@@url, cronremotepassword@@none, smtpuser@@none, ';
- $sensiblesettingsdefault .= 'smtppass@none, proxypassword@@none, quizpassword@@quiz, allowedip@@none, blockedip@@none, ';
- $sensiblesettingsdefault .= 'dbpass@@logstore_database, messageinbound_hostpass@@none, ';
- $sensiblesettingsdefault .= 'bind_pw@@auth_cas, pass@@auth_db, bind_pw@@auth_ldap, ';
- $sensiblesettingsdefault .= 'dbpass@@enrol_database, bind_pw@@enrol_ldap, ';
- $sensiblesettingsdefault .= 'server_password@@search_solr, ssl_keypassword@@search_solr, ';
- $sensiblesettingsdefault .= 'alternateserver_password@@search_solr, alternatessl_keypassword@@search_solr, ';
- $sensiblesettingsdefault .= 'test_password@@cachestore_redis, password@@mlbackend_python';
-
- $settings->add(new admin_setting_configtextarea('tool_admin_presets/sensiblesettings',
- get_string('sensiblesettings', 'tool_admin_presets'),
- get_string('sensiblesettingstext', 'tool_admin_presets'),
- $sensiblesettingsdefault, PARAM_TEXT));
-
}
diff --git a/admin/tool/admin_presets/styles.css b/admin/tool/admin_presets/styles.css
index 9cdf9207edf..25f20739c8b 100644
--- a/admin/tool/admin_presets/styles.css
+++ b/admin/tool/admin_presets/styles.css
@@ -1,12 +1,3 @@
-.admin_presets_tree_name {
- padding: 0 0 4px 2px;
-}
-
-.admin_presets_tree_value {
- border: 1px solid #ccc;
- padding: 0 0 4px 2px;
-}
-
.admin_presets_error {
color: red;
text-align: center;
diff --git a/admin/tool/admin_presets/tests/behat/import_file.feature b/admin/tool/admin_presets/tests/behat/import_file.feature
index 3ba22921ad5..c378d8676cd 100644
--- a/admin/tool/admin_presets/tests/behat/import_file.feature
+++ b/admin/tool/admin_presets/tests/behat/import_file.feature
@@ -10,7 +10,7 @@ Feature: I can upload a preset file
Given I should see "Import site admin preset"
And I click on "Import" "button"
And I should see "You must supply a value here"
- And I upload "admin/tool/admin_presets/tests/fixtures/import_settings_plugins.xml" file to "Select file" filemanager
+ And I upload "adminpresets/tests/fixtures/import_settings_plugins.xml" file to "Select file" filemanager
And I click on "Import" "button"
And I should see "Setting changes"
And I should see "Imported preset"
@@ -31,7 +31,7 @@ Feature: I can upload a preset file
Scenario: Rename imported settings
Given I should see "Import site admin preset"
And I set the field "Name" to "Renamed preset"
- And I upload "admin/tool/admin_presets/tests/fixtures/import_settings_plugins.xml" file to "Select file" filemanager
+ And I upload "adminpresets/tests/fixtures/import_settings_plugins.xml" file to "Select file" filemanager
And I click on "Import" "button"
And I should not see "Imported preset"
And I should see "Renamed preset"
@@ -42,7 +42,7 @@ Feature: I can upload a preset file
Scenario: Import settings from an invalid XML file
Given I set the field "Name" to "Renamed preset"
- And I upload "admin/tool/admin_presets/tests/fixtures/invalid_xml_file.xml" file to "Select file" filemanager
+ And I upload "adminpresets/tests/fixtures/invalid_xml_file.xml" file to "Select file" filemanager
When I click on "Import" "button"
Then I should see "Wrong file"
And I should not see "Setting changes"
@@ -51,7 +51,7 @@ Feature: I can upload a preset file
Scenario: Import unexisting settings category
Given I set the field "Name" to "Renamed preset"
- And I upload "admin/tool/admin_presets/tests/fixtures/unexisting_category.xml" file to "Select file" filemanager
+ And I upload "adminpresets/tests/fixtures/unexisting_category.xml" file to "Select file" filemanager
When I click on "Import" "button"
Then I should see "No valid settings"
And I should not see "Setting changes"
@@ -63,7 +63,7 @@ Feature: I can upload a preset file
| debug | 0 |
| debugdisplay | 0 |
And I set the field "Name" to "Renamed preset"
- And I upload "admin/tool/admin_presets/tests/fixtures/import_settings_with_unexisting_setting.xml" file to "Select file" filemanager
+ And I upload "adminpresets/tests/fixtures/import_settings_with_unexisting_setting.xml" file to "Select file" filemanager
When I click on "Import" "button"
And I should see "Setting changes"
And I should see "Enable portfolios" in the "core" "table_row"
diff --git a/admin/tool/admin_presets/tests/event/preset_deleted_test.php b/admin/tool/admin_presets/tests/event/preset_deleted_test.php
index 251c201bf3a..03d7194eee8 100644
--- a/admin/tool/admin_presets/tests/event/preset_deleted_test.php
+++ b/admin/tool/admin_presets/tests/event/preset_deleted_test.php
@@ -35,7 +35,7 @@ class preset_deleted_test extends \advanced_testcase {
$this->setAdminUser();
// Create a preset.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset();
$params = [
diff --git a/admin/tool/admin_presets/tests/event/preset_downloaded_test.php b/admin/tool/admin_presets/tests/event/preset_downloaded_test.php
index 0162a5f2635..c00cda2d9ff 100644
--- a/admin/tool/admin_presets/tests/event/preset_downloaded_test.php
+++ b/admin/tool/admin_presets/tests/event/preset_downloaded_test.php
@@ -35,7 +35,7 @@ class preset_downloaded_test extends \advanced_testcase {
$this->setAdminUser();
// Create a preset.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset();
$params = [
diff --git a/admin/tool/admin_presets/tests/event/preset_exported_test.php b/admin/tool/admin_presets/tests/event/preset_exported_test.php
index 4f05e40814e..39e28a49b0a 100644
--- a/admin/tool/admin_presets/tests/event/preset_exported_test.php
+++ b/admin/tool/admin_presets/tests/event/preset_exported_test.php
@@ -35,7 +35,7 @@ class preset_exported_test extends \advanced_testcase {
$this->setAdminUser();
// Create a preset.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset();
$params = [
diff --git a/admin/tool/admin_presets/tests/event/preset_imported_test.php b/admin/tool/admin_presets/tests/event/preset_imported_test.php
index 005522fec65..7823de06074 100644
--- a/admin/tool/admin_presets/tests/event/preset_imported_test.php
+++ b/admin/tool/admin_presets/tests/event/preset_imported_test.php
@@ -35,7 +35,7 @@ class preset_imported_test extends \advanced_testcase {
$this->setAdminUser();
// Create a preset.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset();
$params = [
diff --git a/admin/tool/admin_presets/tests/event/preset_loaded_test.php b/admin/tool/admin_presets/tests/event/preset_loaded_test.php
index 82be1dda449..160081f86be 100644
--- a/admin/tool/admin_presets/tests/event/preset_loaded_test.php
+++ b/admin/tool/admin_presets/tests/event/preset_loaded_test.php
@@ -35,7 +35,7 @@ class preset_loaded_test extends \advanced_testcase {
$this->setAdminUser();
// Create a preset.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset();
$params = [
diff --git a/admin/tool/admin_presets/tests/event/preset_previewed_test.php b/admin/tool/admin_presets/tests/event/preset_previewed_test.php
index 1e275a091bf..c9aa8d236ff 100644
--- a/admin/tool/admin_presets/tests/event/preset_previewed_test.php
+++ b/admin/tool/admin_presets/tests/event/preset_previewed_test.php
@@ -35,7 +35,7 @@ class preset_previewed_test extends \advanced_testcase {
$this->setAdminUser();
// Create a preset.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset();
$params = [
diff --git a/admin/tool/admin_presets/tests/event/preset_reverted_test.php b/admin/tool/admin_presets/tests/event/preset_reverted_test.php
index 86bfba97b47..66ddcd827d7 100644
--- a/admin/tool/admin_presets/tests/event/preset_reverted_test.php
+++ b/admin/tool/admin_presets/tests/event/preset_reverted_test.php
@@ -35,7 +35,7 @@ class preset_reverted_test extends \advanced_testcase {
$this->setAdminUser();
// Create a preset.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset();
$params = [
diff --git a/admin/tool/admin_presets/tests/event/presets_listed_test.php b/admin/tool/admin_presets/tests/event/presets_listed_test.php
index a306ad205c9..4c519691bab 100644
--- a/admin/tool/admin_presets/tests/event/presets_listed_test.php
+++ b/admin/tool/admin_presets/tests/event/presets_listed_test.php
@@ -35,7 +35,7 @@ class presets_listed_test extends \advanced_testcase {
$this->setAdminUser();
// Create a preset.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset();
$params = [
diff --git a/admin/tool/admin_presets/tests/generator/lib.php b/admin/tool/admin_presets/tests/generator/lib.php
index 79667e4a926..ec0de517717 100644
--- a/admin/tool/admin_presets/tests/generator/lib.php
+++ b/admin/tool/admin_presets/tests/generator/lib.php
@@ -16,12 +16,8 @@
defined('MOODLE_INTERNAL') || die();
-use tool_admin_presets\local\setting\admin_preset_setting;
-use tool_admin_presets\manager;
-use tool_admin_presets\helper;
-
global $CFG;
-require_once($CFG->libdir . '/adminlib.php');
+require_once($CFG->dirroot . '/adminpresets/tests/generator/lib.php');
/**
* Data generator the admin_presets tool.
@@ -31,215 +27,6 @@ require_once($CFG->libdir . '/adminlib.php');
* @copyright 2021 Sara Arjona (sara@moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class tool_admin_presets_generator extends \component_generator_base {
+class tool_admin_presets_generator extends \core_adminpresets_generator {
- /**
- * Create a preset. This preset will have only 3 settings and 3 plugins.
- * Settings:
- * - none.enablebadges = 0
- * - none.allowemojipicker = 1
- * - mod_lesson.mediawidth = 900
- * - mod_lesson.maxanswers = 2 with advanced disabled.
- * Plugins:
- * - enrol_guest = 0
- * - mod_glossary = 0
- * - qtype_truefalse = 1
- *
- * @param array $data Preset data. Supported values:
- * - name. To define the preset name.
- * - comments. To change the comments field.
- * - author. To set the author.
- * - applypreset. Whether the preset should be applied too or not.
- * @return int Identifier of the preset created.
- */
- public function create_preset(array $data = []): int {
- global $DB, $USER, $CFG;
-
- if (!isset($data['name'])) {
- $data['name'] = 'Preset default name';
- }
- if (!isset($data['comments'])) {
- $data['comments'] = 'Preset default comment';
- }
- if (!isset($data['author'])) {
- $data['author'] = 'Default author';
- }
-
- $preset = [
- 'userid' => $USER->id,
- 'name' => $data['name'],
- 'comments' => $data['comments'],
- 'site' => $CFG->wwwroot,
- 'author' => $data['author'],
- 'moodleversion' => $CFG->version,
- 'moodlerelease' => $CFG->release,
- 'timecreated' => time(),
- 'timeimported' => 0,
- ];
-
- $presetid = $DB->insert_record('tool_admin_presets', $preset);
- $preset['id'] = $presetid;
-
- // Setting: enablebadges = 0.
- helper::add_item($presetid, 'enablebadges', '0');
- // Setting: allowemojipicker = 1.
- helper::add_item($presetid, 'allowemojipicker', '1');
- // Setting: mediawidth = 900.
- helper::add_item($presetid, 'mediawidth', '900', 'mod_lesson');
- // Setting: maxanswers = 2 (with advanced disabled).
- helper::add_item($presetid, 'maxanswers', '2', 'mod_lesson', 'maxanswers_adv', 0);
-
- // Plugin: enrol_guest = 0.
- helper::add_plugin($presetid, 'enrol', 'guest', 0);
- // Plugin: mod_glossary = 0.
- helper::add_plugin($presetid, 'mod', 'glossary', 0);
- // Plugin: qtype_truefalse.
- helper::add_plugin($presetid, 'qtype', 'truefalse', 1);
-
- // Check if the preset should be created as applied preset too, to fill in the rest of the tables.
- $applypreset = isset($data['applypreset']) && $data['applypreset'];
- if ($applypreset) {
- $presetapp = [
- 'adminpresetid' => $presetid,
- 'userid' => $USER->id,
- 'time' => time(),
- ];
- $appid = $DB->insert_record('tool_admin_presets_app', $presetapp);
-
- $this->apply_setting($appid, 'enablebadges', '1', '0');
- // The allowemojipicker setting shouldn't be applied because the value matches the current one.
- $this->apply_setting($appid, 'mediawidth', '640', '900', 'mod_lesson');
- $this->apply_setting($appid, 'maxanswers', '5', '2', 'mod_lesson');
- $this->apply_setting($appid, 'maxanswers_adv', '1', '0', 'mod_lesson', 'maxanswers');
-
- $this->apply_plugin($appid, 'enrol', 'guest', 1, 0);
- $this->apply_plugin($appid, 'mod', 'glossary', 1, 0);
- // The qtype_truefalse plugin shouldn't be applied because the value matches the current one.
- }
-
- return $presetid;
- }
-
- /**
- * Helper method to create an applied setting item.
- *
- * @param int $appid The applied preset identifier.
- * @param string $name The setting name.
- * @param string $oldvalue The setting old value.
- * @param string $newvalue The setting new value.
- * @param string|null $plugin The setting plugin (or null if none).
- * @param string|null $itemname Whether it should be treated as advanced item or not.
- *
- * @return bool|int true or new id.
- */
- private function apply_setting(int $appid, string $name, string $oldvalue, string $newvalue, ?string $plugin = null,
- ?string $itemname = null) {
- global $DB;
-
- set_config($name, $newvalue, $plugin);
- $configlogid = $this->add_to_config_log($name, $oldvalue, $newvalue, $plugin);
- $presetappitem = [
- 'adminpresetapplyid' => $appid,
- 'configlogid' => $configlogid,
- ];
- $table = 'tool_admin_presets_app_it';
- if (!is_null($itemname)) {
- $table = 'tool_admin_presets_app_it_a';
- $presetappitem['itemname'] = $itemname;
- }
- $appitemid = $DB->insert_record($table, $presetappitem);
-
- return $appitemid;
-
- }
-
- /**
- * Helper method to create an applied plugin.
- *
- * @param int $appid The applied preset identifier.
- * @param string $plugin The plugin type.
- * @param string $name The plugin name.
- * @param int $oldvalue The setting old value.
- * @param int $newvalue The setting new value.
- *
- * @return bool|int true or new id.
- */
- private function apply_plugin(int $appid, string $plugin, string $name, int $oldvalue, int $newvalue) {
- global $DB;
-
- // Change plugin visibility.
- $pluginclass = \core_plugin_manager::resolve_plugininfo_class($plugin);
- $pluginclass::enable_plugin($name, $newvalue);
-
- // Create entry in applied plugins table.
- $presetappplug = [
- 'adminpresetapplyid' => $appid,
- 'plugin' => $plugin,
- 'name' => $name,
- 'value' => $newvalue,
- 'oldvalue' => $oldvalue,
- ];
- $appplugid = $DB->insert_record('tool_admin_presets_app_plug', $presetappplug);
-
- return $appplugid;
- }
-
- /**
- * Helper method to add entry in config_log.
- *
- * @param string $name The setting name.
- * @param string $oldvalue The setting old value.
- * @param string $value The setting new value.
- * @param string|null $plugin The setting plugin (or null if the setting doesn't belong to any plugin).
- * @return int The id of the config_log entry created.
- */
- private function add_to_config_log(string $name, string $oldvalue, string $value, ?string $plugin = null): int {
- global $DB, $USER;
-
- $log = new stdClass();
- $log->userid = $USER->id;
- $log->timemodified = time();
- $log->name = $name;
- $log->oldvalue = $oldvalue;
- $log->value = $value;
- $log->plugin = $plugin;
- $id = $DB->insert_record('config_log', $log);
-
- return $id;
- }
-
- /**
- * Helper method to access to a protected property.
- *
- * @param string|object $object The class.
- * @param string $property The private/protected property in $object to access.
- * @return mixed The current value of the property.
- */
- public function access_protected($object, string $property) {
- $reflection = new ReflectionClass($object);
- $property = $reflection->getProperty($property);
- $property->setAccessible(true);
- return $property->getValue($object);
- }
-
-
- /**
- * Given a tree category and setting name, it gets the admin_preset_setting class.
- *
- * @param string $category Tree category name where the setting is located.
- * @param string $settingname Setting name to get the class.
- * @return admin_preset_setting
- */
- public function get_admin_preset_setting(string $category, string $settingname): admin_preset_setting {
- $adminroot = admin_get_root();
-
- // Set method accessibility.
- $method = new ReflectionMethod(manager::class, 'get_setting');
- $method->setAccessible(true);
-
- // Get the proper admin_preset_setting instance.
- $settingpage = $adminroot->locate($category);
- $settingdata = $settingpage->settings->$settingname;
- return $method->invokeArgs(new manager(), [$settingdata, '']);
- }
}
diff --git a/admin/tool/admin_presets/tests/local/action/base_test.php b/admin/tool/admin_presets/tests/local/action/base_test.php
index 84125847526..2cf069cc361 100644
--- a/admin/tool/admin_presets/tests/local/action/base_test.php
+++ b/admin/tool/admin_presets/tests/local/action/base_test.php
@@ -16,9 +16,6 @@
namespace tool_admin_presets\local\action;
-use ReflectionMethod;
-use stdClass;
-
/**
* Tests for the base class.
*
diff --git a/admin/tool/admin_presets/tests/local/action/delete_test.php b/admin/tool/admin_presets/tests/local/action/delete_test.php
index a3b269a8316..4b808394102 100644
--- a/admin/tool/admin_presets/tests/local/action/delete_test.php
+++ b/admin/tool/admin_presets/tests/local/action/delete_test.php
@@ -39,23 +39,23 @@ class delete_test extends \advanced_testcase {
$this->setAdminUser();
// Create some presets.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid1 = $generator->create_preset(['name' => 'Preset 1', 'applypreset' => true]);
$presetid2 = $generator->create_preset(['name' => 'Preset 2']);
- $currentpresets = $DB->count_records('tool_admin_presets');
- $currentitems = $DB->count_records('tool_admin_presets_it');
- $currentadvitems = $DB->count_records('tool_admin_presets_it_a');
- $currentplugins = $DB->count_records('tool_admin_presets_plug');
+ $currentpresets = $DB->count_records('adminpresets');
+ $currentitems = $DB->count_records('adminpresets_it');
+ $currentadvitems = $DB->count_records('adminpresets_it_a');
+ $currentplugins = $DB->count_records('adminpresets_plug');
// Only preset1 has been applied.
- $this->assertCount(1, $DB->get_records('tool_admin_presets_app'));
+ $this->assertCount(1, $DB->get_records('adminpresets_app'));
// Only the preset1 settings that have changed: enablebadges, mediawidth and maxanswers.
- $this->assertCount(3, $DB->get_records('tool_admin_presets_app_it'));
+ $this->assertCount(3, $DB->get_records('adminpresets_app_it'));
// Only the preset1 advanced settings that have changed: maxanswers_adv.
- $this->assertCount(1, $DB->get_records('tool_admin_presets_app_it_a'));
+ $this->assertCount(1, $DB->get_records('adminpresets_app_it_a'));
// Only the preset1 plugins that have changed: enrol_guest and mod_glossary.
- $this->assertCount(2, $DB->get_records('tool_admin_presets_app_plug'));
+ $this->assertCount(2, $DB->get_records('adminpresets_app_plug'));
// Initialise the parameters and create the delete class.
$_POST['action'] = 'delete';
@@ -73,23 +73,23 @@ class delete_test extends \advanced_testcase {
$this->assertInstanceOf(\moodle_exception::class, $e);
} finally {
// Check the preset data has been removed.
- $presets = $DB->get_records('tool_admin_presets');
+ $presets = $DB->get_records('adminpresets');
$this->assertCount($currentpresets - 1, $presets);
$preset = reset($presets);
$this->assertArrayHasKey($presetid2, $presets);
// Check preset items.
- $this->assertCount($currentitems - 4, $DB->get_records('tool_admin_presets_it'));
- $this->assertCount(0, $DB->get_records('tool_admin_presets_it', ['adminpresetid' => $presetid1]));
+ $this->assertCount($currentitems - 4, $DB->get_records('adminpresets_it'));
+ $this->assertCount(0, $DB->get_records('adminpresets_it', ['adminpresetid' => $presetid1]));
// Check preset advanced items.
- $this->assertCount($currentadvitems - 1, $DB->get_records('tool_admin_presets_it_a'));
+ $this->assertCount($currentadvitems - 1, $DB->get_records('adminpresets_it_a'));
// Check preset plugins.
- $this->assertCount($currentplugins - 3, $DB->get_records('tool_admin_presets_plug'));
- $this->assertCount(0, $DB->get_records('tool_admin_presets_plug', ['adminpresetid' => $presetid1]));
+ $this->assertCount($currentplugins - 3, $DB->get_records('adminpresets_plug'));
+ $this->assertCount(0, $DB->get_records('adminpresets_plug', ['adminpresetid' => $presetid1]));
// Check preset applied tables are empty now.
- $this->assertCount(0, $DB->get_records('tool_admin_presets_app'));
- $this->assertCount(0, $DB->get_records('tool_admin_presets_app_it'));
- $this->assertCount(0, $DB->get_records('tool_admin_presets_app_it_a'));
- $this->assertCount(0, $DB->get_records('tool_admin_presets_app_plug'));
+ $this->assertCount(0, $DB->get_records('adminpresets_app'));
+ $this->assertCount(0, $DB->get_records('adminpresets_app_it'));
+ $this->assertCount(0, $DB->get_records('adminpresets_app_it_a'));
+ $this->assertCount(0, $DB->get_records('adminpresets_app_plug'));
// Check the delete event has been raised.
$events = $sink->get_events();
@@ -110,7 +110,7 @@ class delete_test extends \advanced_testcase {
$this->setAdminUser();
// Create some presets.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset(['name' => 'Preset 1']);
// Initialise the parameters and create the delete class.
@@ -135,7 +135,7 @@ class delete_test extends \advanced_testcase {
$this->setAdminUser();
// Create some presets.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset(['name' => 'Preset 1']);
// Initialise the parameters and create the delete class.
diff --git a/admin/tool/admin_presets/tests/local/action/export_test.php b/admin/tool/admin_presets/tests/local/action/export_test.php
index 4b385d54fb3..b529d2197a7 100644
--- a/admin/tool/admin_presets/tests/local/action/export_test.php
+++ b/admin/tool/admin_presets/tests/local/action/export_test.php
@@ -16,8 +16,6 @@
namespace tool_admin_presets\local\action;
-use tool_admin_presets\helper;
-
/**
* Tests for the export class.
*
@@ -44,8 +42,8 @@ class export_test extends \advanced_testcase {
$this->setAdminUser();
// Get current presets and items.
- $currentpresets = $DB->count_records('tool_admin_presets');
- $currentadvitems = $DB->count_records('tool_admin_presets_it_a');
+ $currentpresets = $DB->count_records('adminpresets');
+ $currentadvitems = $DB->count_records('adminpresets_it_a');
// Initialise some settings (to compare their values have been exported as expected).
set_config('recaptchapublickey', 'abcde');
@@ -81,9 +79,9 @@ class export_test extends \advanced_testcase {
$this->assertInstanceOf(\moodle_exception::class, $e);
} finally {
// Check the preset record has been created.
- $presets = $DB->get_records('tool_admin_presets');
+ $presets = $DB->get_records('adminpresets');
$this->assertCount($currentpresets + 1, $presets);
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->access_protected($action, 'id');
$this->assertArrayHasKey($presetid, $presets);
$preset = $presets[$presetid];
@@ -91,31 +89,31 @@ class export_test extends \advanced_testcase {
$this->assertEquals(0, $preset->iscore);
// Check the items, advanced attributes and plugins have been created.
- $this->assertGreaterThan(0, $DB->count_records('tool_admin_presets_it', ['adminpresetid' => $presetid]));
- $this->assertGreaterThan($currentadvitems, $DB->count_records('tool_admin_presets_it_a'));
- $this->assertGreaterThan(0, $DB->count_records('tool_admin_presets_plug', ['adminpresetid' => $presetid]));
+ $this->assertGreaterThan(0, $DB->count_records('adminpresets_it', ['adminpresetid' => $presetid]));
+ $this->assertGreaterThan($currentadvitems, $DB->count_records('adminpresets_it_a'));
+ $this->assertGreaterThan(0, $DB->count_records('adminpresets_plug', ['adminpresetid' => $presetid]));
// Check settings have been created with the expected values.
$params = ['adminpresetid' => $presetid, 'plugin' => 'none', 'name' => 'enablebadges'];
- $setting = $DB->get_record('tool_admin_presets_it', $params);
+ $setting = $DB->get_record('adminpresets_it', $params);
$this->assertEquals('0', $setting->value);
$params = ['adminpresetid' => $presetid, 'plugin' => 'mod_lesson', 'name' => 'mediawidth'];
- $setting = $DB->get_record('tool_admin_presets_it', $params);
+ $setting = $DB->get_record('adminpresets_it', $params);
$this->assertEquals('900', $setting->value);
$params = ['adminpresetid' => $presetid, 'plugin' => 'mod_lesson', 'name' => 'maxanswers'];
- $setting = $DB->get_record('tool_admin_presets_it', $params);
+ $setting = $DB->get_record('adminpresets_it', $params);
$this->assertEquals('2', $setting->value);
$params = ['itemid' => $setting->id, 'name' => 'maxanswers_adv'];
- $setting = $DB->get_record('tool_admin_presets_it_a', $params);
+ $setting = $DB->get_record('adminpresets_it_a', $params);
$this->assertEquals('0', $setting->value);
$params = ['adminpresetid' => $presetid, 'plugin' => 'mod_lesson', 'name' => 'defaultfeedback'];
- $setting = $DB->get_record('tool_admin_presets_it', $params);
+ $setting = $DB->get_record('adminpresets_it', $params);
$this->assertEquals('0', $setting->value);
$params = ['itemid' => $setting->id, 'name' => 'defaultfeedback_adv'];
- $setting = $DB->get_record('tool_admin_presets_it_a', $params);
+ $setting = $DB->get_record('adminpresets_it_a', $params);
$this->assertEquals('1', $setting->value);
// Check plugins have been created with the expected values.
@@ -125,16 +123,16 @@ class export_test extends \advanced_testcase {
$enabledplugins = $manager->get_enabled_plugins($plugintype);
foreach ($plugins as $pluginname => $unused) {
$params = ['adminpresetid' => $presetid, 'plugin' => $plugintype, 'name' => $pluginname];
- $plugin = $DB->get_record('tool_admin_presets_plug', $params);
+ $plugin = $DB->get_record('adminpresets_plug', $params);
$enabled = (!empty($enabledplugins) && array_key_exists($pluginname, $enabledplugins));
$this->assertEquals($enabled, (bool) $plugin->enabled);
}
// Check whether sensible settings have been exported or not.
$params = ['adminpresetid' => $presetid, 'plugin' => 'none', 'name' => 'recaptchapublickey'];
- $recaptchasetting = $DB->get_record('tool_admin_presets_it', $params);
+ $recaptchasetting = $DB->get_record('adminpresets_it', $params);
$params = ['adminpresetid' => $presetid, 'plugin' => 'none', 'name' => 'cronremotepassword'];
- $cronsetting = $DB->get_record('tool_admin_presets_it', $params);
+ $cronsetting = $DB->get_record('adminpresets_it', $params);
if ($includesensible) {
$this->assertEquals('abcde', $recaptchasetting->value);
$this->assertNotFalse($cronsetting);
diff --git a/admin/tool/admin_presets/tests/local/action/import_test.php b/admin/tool/admin_presets/tests/local/action/import_test.php
index e1c7cf7bb2e..10403ee49bf 100644
--- a/admin/tool/admin_presets/tests/local/action/import_test.php
+++ b/admin/tool/admin_presets/tests/local/action/import_test.php
@@ -49,9 +49,9 @@ class import_test extends \advanced_testcase {
$this->resetAfterTest();
$this->setAdminUser();
- $currentpresets = $DB->count_records('tool_admin_presets');
- $currentitems = $DB->count_records('tool_admin_presets_it');
- $currentadvitems = $DB->count_records('tool_admin_presets_it_a');
+ $currentpresets = $DB->count_records('adminpresets');
+ $currentitems = $DB->count_records('adminpresets_it');
+ $currentadvitems = $DB->count_records('adminpresets_it_a');
// Create draft file to import.
$draftid = file_get_unused_draft_itemid();
@@ -95,9 +95,9 @@ class import_test extends \advanced_testcase {
if ($expectedpreset) {
// Check the preset record has been created.
- $presets = $DB->get_records('tool_admin_presets');
+ $presets = $DB->get_records('adminpresets');
$this->assertCount($currentpresets + 1, $presets);
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->access_protected($action, 'id');
$this->assertArrayHasKey($presetid, $presets);
$preset = $presets[$presetid];
@@ -108,7 +108,7 @@ class import_test extends \advanced_testcase {
if ($expectedsettings) {
// Check the items have been created.
- $items = $DB->get_records('tool_admin_presets_it', ['adminpresetid' => $presetid]);
+ $items = $DB->get_records('adminpresets_it', ['adminpresetid' => $presetid]);
$this->assertCount(4, $items);
$presetitems = [
'none' => [
@@ -127,7 +127,7 @@ class import_test extends \advanced_testcase {
}
// Check the advanced attributes have been created.
- $advitems = $DB->get_records('tool_admin_presets_it_a');
+ $advitems = $DB->get_records('adminpresets_it_a');
$this->assertCount($currentadvitems + 1, $advitems);
$advitemfound = false;
foreach ($advitems as $advitem) {
@@ -141,7 +141,7 @@ class import_test extends \advanced_testcase {
if ($expectedplugins) {
// Check the plugins have been created.
- $plugins = $DB->get_records('tool_admin_presets_plug', ['adminpresetid' => $presetid]);
+ $plugins = $DB->get_records('adminpresets_plug', ['adminpresetid' => $presetid]);
$this->assertCount(6, $plugins);
$presetplugins = [
'atto' => [
@@ -165,9 +165,9 @@ class import_test extends \advanced_testcase {
}
} else {
// Check the preset nor the items are not created.
- $this->assertCount($currentpresets, $DB->get_records('tool_admin_presets'));
- $this->assertCount($currentitems, $DB->get_records('tool_admin_presets_it'));
- $this->assertCount($currentadvitems, $DB->get_records('tool_admin_presets_it_a'));
+ $this->assertCount($currentpresets, $DB->get_records('adminpresets'));
+ $this->assertCount($currentitems, $DB->get_records('adminpresets_it'));
+ $this->assertCount($currentadvitems, $DB->get_records('adminpresets_it_a'));
}
// Check the export event has been raised.
@@ -189,25 +189,27 @@ class import_test extends \advanced_testcase {
* @return array
*/
public function import_execute_provider(): array {
+ $fixturesfolder = __DIR__ . '/../../../../../../adminpresets/tests/fixtures/';
+
return [
'Import settings from an empty file' => [
'filecontents' => '',
'expectedpreset' => false,
],
'Import settings and plugins from a valid XML file' => [
- 'filecontents' => file_get_contents(__DIR__ . '/../../fixtures/import_settings_plugins.xml'),
+ 'filecontents' => file_get_contents($fixturesfolder . 'import_settings_plugins.xml'),
'expectedpreset' => true,
'expectedsettings' => true,
'expectedplugins' => true,
],
'Import only settings from a valid XML file' => [
- 'filecontents' => file_get_contents(__DIR__ . '/../../fixtures/import_settings.xml'),
+ 'filecontents' => file_get_contents($fixturesfolder . 'import_settings.xml'),
'expectedpreset' => true,
'expectedsettings' => true,
'expectedplugins' => false,
],
'Import settings and plugins from a valid XML file with Starter name, which will be marked as non-core' => [
- 'filecontents' => file_get_contents(__DIR__ . '/../../fixtures/import_starter_name.xml'),
+ 'filecontents' => file_get_contents($fixturesfolder . 'import_starter_name.xml'),
'expectedpreset' => true,
'expectedsettings' => true,
'expectedplugins' => true,
@@ -216,7 +218,7 @@ class import_test extends \advanced_testcase {
'expectedpresetname' => 'Starter',
],
'Import settings from an invalid XML file' => [
- 'filecontents' => file_get_contents(__DIR__ . '/../../fixtures/invalid_xml_file.xml'),
+ 'filecontents' => file_get_contents($fixturesfolder . 'invalid_xml_file.xml'),
'expectedpreset' => false,
'expectedsettings' => false,
'expectedplugins' => false,
@@ -224,20 +226,20 @@ class import_test extends \advanced_testcase {
'expectedexception' => \Exception::class,
],
'Import unexisting settings category' => [
- 'filecontents' => file_get_contents(__DIR__ . '/../../fixtures/unexisting_category.xml'),
+ 'filecontents' => file_get_contents($fixturesfolder . 'unexisting_category.xml'),
'expectedpreset' => false,
'expectedsettings' => false,
'expectedplugins' => false,
],
'Import unexisting setting' => [
- 'filecontents' => file_get_contents(__DIR__ . '/../../fixtures/unexisting_setting.xml'),
+ 'filecontents' => file_get_contents($fixturesfolder . 'unexisting_setting.xml'),
'expectedpreset' => false,
'expectedsettings' => false,
'expectedplugins' => false,
'expecteddebugging' => true,
],
'Import valid settings with one unexisting setting too' => [
- 'filecontents' => file_get_contents(__DIR__ . '/../../fixtures/import_settings_with_unexisting_setting.xml'),
+ 'filecontents' => file_get_contents($fixturesfolder . 'import_settings_with_unexisting_setting.xml'),
'expectedpreset' => true,
'expectedsettings' => false,
'expectedplugins' => false,
diff --git a/admin/tool/admin_presets/tests/local/action/load_test.php b/admin/tool/admin_presets/tests/local/action/load_test.php
index 2eb191d3bd3..ac081e54f41 100644
--- a/admin/tool/admin_presets/tests/local/action/load_test.php
+++ b/admin/tool/admin_presets/tests/local/action/load_test.php
@@ -38,7 +38,7 @@ class load_test extends \advanced_testcase {
$this->setAdminUser();
// Create some presets.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset();
// Initialise the parameters and create the load class.
@@ -63,17 +63,17 @@ class load_test extends \advanced_testcase {
$this->setAdminUser();
// Create a preset.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset();
- $currentpresets = $DB->count_records('tool_admin_presets');
- $currentitems = $DB->count_records('tool_admin_presets_it');
- $currentadvitems = $DB->count_records('tool_admin_presets_it_a');
- $currentplugins = $DB->count_records('tool_admin_presets_plug');
- $currentapppresets = $DB->count_records('tool_admin_presets_app');
- $currentappitems = $DB->count_records('tool_admin_presets_app_it');
- $currentappadvitems = $DB->count_records('tool_admin_presets_app_it_a');
- $currentappplugins = $DB->count_records('tool_admin_presets_app_plug');
+ $currentpresets = $DB->count_records('adminpresets');
+ $currentitems = $DB->count_records('adminpresets_it');
+ $currentadvitems = $DB->count_records('adminpresets_it_a');
+ $currentplugins = $DB->count_records('adminpresets_plug');
+ $currentapppresets = $DB->count_records('adminpresets_app');
+ $currentappitems = $DB->count_records('adminpresets_app_it');
+ $currentappadvitems = $DB->count_records('adminpresets_app_it_a');
+ $currentappplugins = $DB->count_records('adminpresets_app_plug');
// Set the config values (to confirm they change after applying the preset).
set_config('enablebadges', 1);
@@ -102,18 +102,18 @@ class load_test extends \advanced_testcase {
$action->execute();
// Check the preset applied has been added to database.
- $this->assertCount($currentapppresets + 1, $DB->get_records('tool_admin_presets_app'));
+ $this->assertCount($currentapppresets + 1, $DB->get_records('adminpresets_app'));
// Applied items: enablebadges@none, mediawitdh@mod_lesson and maxanswers@@mod_lesson.
- $this->assertCount($currentappitems + 3, $DB->get_records('tool_admin_presets_app_it'));
+ $this->assertCount($currentappitems + 3, $DB->get_records('adminpresets_app_it'));
// Applied advanced items: maxanswers_adv@mod_lesson.
- $this->assertCount($currentappadvitems + 1, $DB->get_records('tool_admin_presets_app_it_a'));
+ $this->assertCount($currentappadvitems + 1, $DB->get_records('adminpresets_app_it_a'));
// Applied plugins: enrol_guest and mod_glossary.
- $this->assertCount($currentappplugins + 2, $DB->get_records('tool_admin_presets_app_plug'));
+ $this->assertCount($currentappplugins + 2, $DB->get_records('adminpresets_app_plug'));
// Check no new preset has been created.
- $this->assertCount($currentpresets, $DB->get_records('tool_admin_presets'));
- $this->assertCount($currentitems, $DB->get_records('tool_admin_presets_it'));
- $this->assertCount($currentadvitems, $DB->get_records('tool_admin_presets_it_a'));
- $this->assertCount($currentplugins, $DB->get_records('tool_admin_presets_plug'));
+ $this->assertCount($currentpresets, $DB->get_records('adminpresets'));
+ $this->assertCount($currentitems, $DB->get_records('adminpresets_it'));
+ $this->assertCount($currentadvitems, $DB->get_records('adminpresets_it_a'));
+ $this->assertCount($currentplugins, $DB->get_records('adminpresets_plug'));
// Check the setting values have changed accordingly with the ones defined in the preset.
$this->assertEquals(0, get_config('core', 'enablebadges'));
diff --git a/admin/tool/admin_presets/tests/local/action/rollback_test.php b/admin/tool/admin_presets/tests/local/action/rollback_test.php
index 60ca9cc9cb6..52cb6e49f97 100644
--- a/admin/tool/admin_presets/tests/local/action/rollback_test.php
+++ b/admin/tool/admin_presets/tests/local/action/rollback_test.php
@@ -48,18 +48,18 @@ class rollback_test extends \advanced_testcase {
set_config('usecomments', 0);
// Create a preset and apply it.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset(['applypreset' => true]);
- $presetappid = $DB->get_field('tool_admin_presets_app', 'id', ['adminpresetid' => $presetid]);
+ $presetappid = $DB->get_field('adminpresets_app', 'id', ['adminpresetid' => $presetid]);
- $currentpresets = $DB->count_records('tool_admin_presets');
- $currentitems = $DB->count_records('tool_admin_presets_it');
- $currentadvitems = $DB->count_records('tool_admin_presets_it_a');
- $currentplugins = $DB->count_records('tool_admin_presets_plug');
- $this->assertCount(1, $DB->get_records('tool_admin_presets_app'));
- $this->assertCount(3, $DB->get_records('tool_admin_presets_app_it'));
- $this->assertCount(1, $DB->get_records('tool_admin_presets_app_it_a'));
- $this->assertCount(2, $DB->get_records('tool_admin_presets_app_plug'));
+ $currentpresets = $DB->count_records('adminpresets');
+ $currentitems = $DB->count_records('adminpresets_it');
+ $currentadvitems = $DB->count_records('adminpresets_it_a');
+ $currentplugins = $DB->count_records('adminpresets_plug');
+ $this->assertCount(1, $DB->get_records('adminpresets_app'));
+ $this->assertCount(3, $DB->get_records('adminpresets_app_it'));
+ $this->assertCount(1, $DB->get_records('adminpresets_app_it_a'));
+ $this->assertCount(2, $DB->get_records('adminpresets_app_plug'));
// Check the setttings have changed accordingly after applying the preset.
$this->assertEquals(0, get_config('core', 'enablebadges'));
@@ -88,15 +88,15 @@ class rollback_test extends \advanced_testcase {
$action->execute();
// Check the preset applied has been reverted (so the records in _appXX tables have been removed).
- $this->assertCount(0, $DB->get_records('tool_admin_presets_app'));
- $this->assertCount(0, $DB->get_records('tool_admin_presets_app_it'));
- $this->assertCount(0, $DB->get_records('tool_admin_presets_app_it_a'));
- $this->assertCount(0, $DB->get_records('tool_admin_presets_app_plug'));
+ $this->assertCount(0, $DB->get_records('adminpresets_app'));
+ $this->assertCount(0, $DB->get_records('adminpresets_app_it'));
+ $this->assertCount(0, $DB->get_records('adminpresets_app_it_a'));
+ $this->assertCount(0, $DB->get_records('adminpresets_app_plug'));
// Check the preset data hasn't changed.
- $this->assertCount($currentpresets, $DB->get_records('tool_admin_presets'));
- $this->assertCount($currentitems, $DB->get_records('tool_admin_presets_it'));
- $this->assertCount($currentadvitems, $DB->get_records('tool_admin_presets_it_a'));
- $this->assertCount($currentplugins, $DB->get_records('tool_admin_presets_plug'));
+ $this->assertCount($currentpresets, $DB->get_records('adminpresets'));
+ $this->assertCount($currentitems, $DB->get_records('adminpresets_it'));
+ $this->assertCount($currentadvitems, $DB->get_records('adminpresets_it_a'));
+ $this->assertCount($currentplugins, $DB->get_records('adminpresets_plug'));
// Check the setting values have been reverted accordingly.
$this->assertEquals(1, get_config('core', 'enablebadges'));
@@ -130,9 +130,9 @@ class rollback_test extends \advanced_testcase {
$this->setAdminUser();
// Create a preset and apply it.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset(['applypreset' => true]);
- $presetappid = $DB->get_field('tool_admin_presets_app', 'id', ['adminpresetid' => $presetid]);
+ $presetappid = $DB->get_field('adminpresets_app', 'id', ['adminpresetid' => $presetid]);
// Initialise the parameters.
$_POST['action'] = 'rollback';
diff --git a/adminpresets/classes/helper.php b/adminpresets/classes/helper.php
new file mode 100644
index 00000000000..67b7c798a45
--- /dev/null
+++ b/adminpresets/classes/helper.php
@@ -0,0 +1,388 @@
+.
+
+namespace core_adminpresets;
+
+/**
+ * Admin presets helper class.
+ *
+ * @package core_adminpresets
+ * @copyright 2021 Sara Arjona (sara@moodle.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class helper {
+
+ /**
+ * Create an empty preset.
+ *
+ * @param array $data Preset 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.
+ * @return int The identifier of the preset created.
+ */
+ public static function create_preset(array $data): int {
+ global $CFG, $USER, $DB;
+
+ $name = array_key_exists('name', $data) ? $data['name'] : '';
+ $comments = array_key_exists('comments', $data) ? $data['comments'] : '';
+ $author = array_key_exists('author', $data) ? $data['author'] : fullname($USER);
+ $iscore = array_key_exists('iscore', $data) ? $data['iscore'] : 0;
+
+ $preset = [
+ 'userid' => $USER->id,
+ 'name' => $name,
+ 'comments' => $comments,
+ 'site' => $CFG->wwwroot,
+ 'author' => $author,
+ 'moodleversion' => $CFG->version,
+ 'moodlerelease' => $CFG->release,
+ 'iscore' => $iscore,
+ 'timecreated' => time(),
+ 'timeimported' => 0,
+ ];
+
+ $presetid = $DB->insert_record('adminpresets', $preset);
+ return $presetid;
+ }
+
+ /**
+ * 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.
+ */
+ public static function add_item(int $presetid, string $name, string $value, ?string $plugin = 'none',
+ ?string $advname = null, ?string $advvalue = null): int {
+ global $DB;
+
+ $presetitem = [
+ 'adminpresetid' => $presetid,
+ 'plugin' => $plugin,
+ 'name' => $name,
+ 'value' => $value,
+ ];
+ $itemid = $DB->insert_record('adminpresets_it', $presetitem);
+
+ if (!empty($advname)) {
+ $presetadv = [
+ 'itemid' => $itemid,
+ 'name' => $advname,
+ 'value' => $advvalue,
+ ];
+ $DB->insert_record('adminpresets_it_a', $presetadv);
+ }
+
+ return $itemid;
+ }
+
+ /**
+ * 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.
+ */
+ public static function add_plugin(int $presetid, string $plugin, string $name, int $enabled): int {
+ global $DB;
+
+ $pluginentry = [
+ 'adminpresetid' => $presetid,
+ 'plugin' => $plugin,
+ 'name' => $name,
+ 'enabled' => $enabled,
+ ];
+ $pluginid = $DB->insert_record('adminpresets_plug', $pluginentry);
+
+ return $pluginid;
+ }
+
+ /**
+ * 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.
+ */
+ public static function change_default_preset(string $presetnameorfile): ?int {
+ global $DB;
+
+ $presetid = null;
+
+ // Check if the given variable points to a valid preset file to be imported and applied.
+ if (is_readable($presetnameorfile)) {
+ $xmlcontent = file_get_contents($presetnameorfile);
+ $manager = new manager();
+ list($xmlnotused, $preset) = $manager->import_preset($xmlcontent);
+ if (!is_null($preset)) {
+ list($applied) = $manager->apply_preset($preset->id);
+ if (!empty($applied)) {
+ $presetid = $preset->id;
+ }
+ }
+ } else {
+ // Check if the given preset exists; if that's the case, it will be applied.
+ $stringmanager = get_string_manager();
+ if ($stringmanager->string_exists($presetnameorfile . 'preset', 'core_adminpresets')) {
+ $params = ['name' => get_string($presetnameorfile . 'preset', 'core_adminpresets')];
+ } else {
+ $params = ['name' => $presetnameorfile];
+ }
+ if ($preset = $DB->get_record('adminpresets', $params)) {
+ $manager = new manager();
+ list($applied) = $manager->apply_preset($preset->id);
+ if (!empty($applied)) {
+ $presetid = $preset->id;
+ }
+ }
+ }
+
+ return $presetid;
+ }
+
+ /**
+ * Helper method to create default site admin presets and initialize them.
+ */
+ public static function create_default_presets(): void {
+ // Create the "Starter" site admin preset.
+ $data = [
+ 'name' => get_string('starterpreset', 'core_adminpresets'),
+ 'comments' => get_string('starterpresetdescription', 'core_adminpresets'),
+ 'iscore' => 1,
+ ];
+ $presetid = static::create_preset($data);
+
+ // Add settings to the "Starter" site admin preset.
+ static::add_item($presetid, 'usecomments', '0');
+ static::add_item($presetid, 'usetags', '0');
+ static::add_item($presetid, 'enablenotes', '0');
+ static::add_item($presetid, 'enableblogs', '0');
+ static::add_item($presetid, 'enablebadges', '0');
+ static::add_item($presetid, 'enableanalytics', '0');
+ static::add_item($presetid, 'enabled', '0', 'core_competency');
+ static::add_item($presetid, 'pushcourseratingstouserplans', '0', 'core_competency');
+
+ static::add_item($presetid, 'showdataretentionsummary', '0', 'tool_dataprivacy');
+ static::add_item($presetid, 'forum_maxattachments', '3');
+ static::add_item($presetid, 'customusermenuitems', 'profile,moodle|/user/profile.php
+grades,grades|/grade/report/mygrades.php
+calendar,core_calendar|/calendar/view.php?view=month
+privatefiles,moodle|/user/files.php');
+
+ // Modules: Hide chat, database, external tool (lti), IMS content package (imscp), lesson, SCORM, survey, wiki, workshop.
+ static::add_plugin($presetid, 'mod', 'chat', false);
+ static::add_plugin($presetid, 'mod', 'data', false);
+ static::add_plugin($presetid, 'mod', 'lti', false);
+ static::add_plugin($presetid, 'mod', 'imscp', false);
+ static::add_plugin($presetid, 'mod', 'lesson', false);
+ static::add_plugin($presetid, 'mod', 'scorm', false);
+ static::add_plugin($presetid, 'mod', 'survey', false);
+ static::add_plugin($presetid, 'mod', 'wiki', false);
+ static::add_plugin($presetid, 'mod', 'workshop', false);
+
+ // Availability restrictions: Hide Grouping, User profile.
+ static::add_plugin($presetid, 'availability', 'grouping', false);
+ static::add_plugin($presetid, 'availability', 'profile', false);
+
+ // Blocks: Disable Activities, Blog menu, Blog tags, Comments, Course completion status, Course/site summary, Courses,
+ // Flickr, Global search, Latest badges, Learning plans, Logged in user, Login, Main menu, Mentees, Network servers,
+ // Private files, Recent blog entries, RSS feeds, Search forums, Section links,Self completion, Social activities,
+ // Tags, YouTube.
+ static::add_plugin($presetid, 'block', 'activity_modules', false);
+ static::add_plugin($presetid, 'block', 'blog_menu', false);
+ static::add_plugin($presetid, 'block', 'blog_tags', false);
+ static::add_plugin($presetid, 'block', 'comments', false);
+ static::add_plugin($presetid, 'block', 'completionstatus', false);
+ static::add_plugin($presetid, 'block', 'course_summary', false);
+ static::add_plugin($presetid, 'block', 'course_list', false);
+ static::add_plugin($presetid, 'block', 'tag_flickr', false);
+ static::add_plugin($presetid, 'block', 'globalsearch', false);
+ static::add_plugin($presetid, 'block', 'badges', false);
+ static::add_plugin($presetid, 'block', 'lp', false);
+ static::add_plugin($presetid, 'block', 'myprofile', false);
+ static::add_plugin($presetid, 'block', 'login', false);
+ static::add_plugin($presetid, 'block', 'site_main_menu', false);
+ static::add_plugin($presetid, 'block', 'mentees', false);
+ static::add_plugin($presetid, 'block', 'mnet_hosts', false);
+ static::add_plugin($presetid, 'block', 'private_files', false);
+ static::add_plugin($presetid, 'block', 'blog_recent', false);
+ static::add_plugin($presetid, 'block', 'rss_client', false);
+ static::add_plugin($presetid, 'block', 'search_forums', false);
+ static::add_plugin($presetid, 'block', 'section_links', false);
+ static::add_plugin($presetid, 'block', 'selfcompletion', false);
+ static::add_plugin($presetid, 'block', 'social_activities', false);
+ static::add_plugin($presetid, 'block', 'tags', false);
+ static::add_plugin($presetid, 'block', 'tag_youtube', false);
+ static::add_plugin($presetid, 'block', 'feedback', false);
+
+ // Course formats: Disable Social format.
+ static::add_plugin($presetid, 'format', 'social', false);
+
+ // Data formats: Disable Javascript Object Notation (.json).
+ static::add_plugin($presetid, 'dataformat', 'json', false);
+
+ // Enrolments: Disable Cohort sync.
+ static::add_plugin($presetid, 'enrol', 'cohort', false);
+
+ // Filter: Disable MathJax, Activity names auto-linking.
+ static::add_plugin($presetid, 'filter', 'mathjaxloader', TEXTFILTER_DISABLED);
+ static::add_plugin($presetid, 'filter', 'activitynames', TEXTFILTER_DISABLED);
+
+ // Question behaviours: Disable Adaptive mode (no penalties), Deferred feedback with CBM, Immediate feedback with CBM.
+ static::add_plugin($presetid, 'qbehaviour', 'adaptivenopenalty', false);
+ static::add_plugin($presetid, 'qbehaviour', 'deferredcbm', false);
+ static::add_plugin($presetid, 'qbehaviour', 'immediatecbm', false);
+
+ // Question types: Disable Calculated, Calculated multichoice, Calculated simple, Description, Drag and drop markers,
+ // Drag and drop onto image, Embedded answers (Cloze), Essay, Numerical, Random short-answer matching.
+ static::add_plugin($presetid, 'qtype', 'calculated', false);
+ static::add_plugin($presetid, 'qtype', 'calculatedmulti', false);
+ static::add_plugin($presetid, 'qtype', 'calculatedsimple', false);
+ static::add_plugin($presetid, 'qtype', 'description', false);
+ static::add_plugin($presetid, 'qtype', 'ddmarker', false);
+ static::add_plugin($presetid, 'qtype', 'ddimageortext', false);
+ static::add_plugin($presetid, 'qtype', 'multianswer', false);
+ static::add_plugin($presetid, 'qtype', 'essay', false);
+ static::add_plugin($presetid, 'qtype', 'numerical', false);
+ static::add_plugin($presetid, 'qtype', 'randomsamatch', false);
+
+ // Repositories: Disable Server files, URL downloader, Wikimedia.
+ static::add_plugin($presetid, 'repository', 'local', false);
+ static::add_plugin($presetid, 'repository', 'url', false);
+ static::add_plugin($presetid, 'repository', 'wikimedia', false);
+
+ // Text editors: Disable TinyMCE HTML editor.
+ static::add_plugin($presetid, 'editor', 'tinymce', false);
+
+ // Create the "Full" site admin preset.
+ $data = [
+ 'name' => get_string('fullpreset', 'core_adminpresets'),
+ 'comments' => get_string('fullpresetdescription', 'core_adminpresets'),
+ 'iscore' => 1,
+ ];
+ $presetid = static::create_preset($data);
+
+ // Add settings to the "Full" site admin preset.
+ static::add_item($presetid, 'usecomments', '1');
+ static::add_item($presetid, 'usetags', '1');
+ static::add_item($presetid, 'enablenotes', '1');
+ static::add_item($presetid, 'enableblogs', '1');
+ static::add_item($presetid, 'enablebadges', '1');
+ static::add_item($presetid, 'enableanalytics', '1');
+ static::add_item($presetid, 'enabled', '1', 'core_competency');
+ static::add_item($presetid, 'pushcourseratingstouserplans', '1', 'core_competency');
+
+ static::add_item($presetid, 'showdataretentionsummary', '1', 'tool_dataprivacy');
+ static::add_item($presetid, 'forum_maxattachments', '9');
+ // In that case, the indentation coding style can't follow the rules to guarantee the setting value is created properly.
+ static::add_item($presetid, 'customusermenuitems', 'profile,moodle|/user/profile.php
+grades,grades|/grade/report/mygrades.php
+calendar,core_calendar|/calendar/view.php?view=month
+privatefiles,moodle|/user/files.php'
+ );
+
+ // Modules: Enable chat, database, external tool (lti), IMS content package (imscp), lesson, SCORM, survey, wiki, workshop.
+ static::add_plugin($presetid, 'mod', 'chat', true);
+ static::add_plugin($presetid, 'mod', 'data', true);
+ static::add_plugin($presetid, 'mod', 'lti', true);
+ static::add_plugin($presetid, 'mod', 'imscp', true);
+ static::add_plugin($presetid, 'mod', 'lesson', true);
+ static::add_plugin($presetid, 'mod', 'scorm', true);
+ static::add_plugin($presetid, 'mod', 'survey', true);
+ static::add_plugin($presetid, 'mod', 'wiki', true);
+ static::add_plugin($presetid, 'mod', 'workshop', true);
+
+ // Availability restrictions: Enable Grouping, User profile.
+ static::add_plugin($presetid, 'availability', 'grouping', true);
+ static::add_plugin($presetid, 'availability', 'profile', true);
+
+ // Blocks: Enable Activities, Blog menu, Blog tags, Comments, Course completion status, Course/site summary, Courses,
+ // Flickr, Global search, Latest badges, Learning plans, Logged in user, Login, Main menu, Mentees, Network servers,
+ // Private files, Recent blog entries, RSS feeds, Search forums, Section links,Self completion, Social activities,
+ // Tags, YouTube.
+ static::add_plugin($presetid, 'block', 'activity_modules', true);
+ static::add_plugin($presetid, 'block', 'blog_menu', true);
+ static::add_plugin($presetid, 'block', 'blog_tags', true);
+ static::add_plugin($presetid, 'block', 'comments', true);
+ static::add_plugin($presetid, 'block', 'completionstatus', true);
+ static::add_plugin($presetid, 'block', 'course_summary', true);
+ static::add_plugin($presetid, 'block', 'course_list', true);
+ static::add_plugin($presetid, 'block', 'tag_flickr', true);
+ static::add_plugin($presetid, 'block', 'globalsearch', true);
+ static::add_plugin($presetid, 'block', 'badges', true);
+ static::add_plugin($presetid, 'block', 'lp', true);
+ static::add_plugin($presetid, 'block', 'myprofile', true);
+ static::add_plugin($presetid, 'block', 'login', true);
+ static::add_plugin($presetid, 'block', 'site_main_menu', true);
+ static::add_plugin($presetid, 'block', 'mentees', true);
+ static::add_plugin($presetid, 'block', 'mnet_hosts', true);
+ static::add_plugin($presetid, 'block', 'private_files', true);
+ static::add_plugin($presetid, 'block', 'blog_recent', true);
+ static::add_plugin($presetid, 'block', 'rss_client', true);
+ static::add_plugin($presetid, 'block', 'search_forums', true);
+ static::add_plugin($presetid, 'block', 'section_links', true);
+ static::add_plugin($presetid, 'block', 'selfcompletion', true);
+ static::add_plugin($presetid, 'block', 'social_activities', true);
+ static::add_plugin($presetid, 'block', 'tags', true);
+ static::add_plugin($presetid, 'block', 'feedback', true);
+
+ // Course formats: Enable Social format.
+ static::add_plugin($presetid, 'format', 'social', true);
+
+ // Data formats: Enable Javascript Object Notation (.json).
+ static::add_plugin($presetid, 'dataformat', 'json', true);
+
+ // Enrolments: Enable Cohort sync.
+ static::add_plugin($presetid, 'enrol', 'cohort', true);
+
+ // Filter: Enable MathJax, Activity names auto-linking.
+ static::add_plugin($presetid, 'filter', 'mathjaxloader', TEXTFILTER_ON);
+ static::add_plugin($presetid, 'filter', 'activitynames', TEXTFILTER_ON);
+
+ // Question behaviours: Enable Adaptive mode (no penalties), Deferred feedback with CBM, Immediate feedback with CBM.
+ static::add_plugin($presetid, 'qbehaviour', 'adaptivenopenalty', true);
+ static::add_plugin($presetid, 'qbehaviour', 'deferredcbm', true);
+ static::add_plugin($presetid, 'qbehaviour', 'immediatecbm', true);
+
+ // Question types: Enable Calculated, Calculated multichoice, Calculated simple, Description, Drag and drop markers,
+ // Drag and drop onto image, Embedded answers (Cloze), Essay, Numerical, Random short-answer matching.
+ static::add_plugin($presetid, 'qtype', 'calculated', true);
+ static::add_plugin($presetid, 'qtype', 'calculatedmulti', true);
+ static::add_plugin($presetid, 'qtype', 'calculatedsimple', true);
+ static::add_plugin($presetid, 'qtype', 'description', true);
+ static::add_plugin($presetid, 'qtype', 'ddmarker', true);
+ static::add_plugin($presetid, 'qtype', 'ddimageortext', true);
+ static::add_plugin($presetid, 'qtype', 'multianswer', true);
+ static::add_plugin($presetid, 'qtype', 'essay', true);
+ static::add_plugin($presetid, 'qtype', 'numerical', true);
+ static::add_plugin($presetid, 'qtype', 'randomsamatch', true);
+
+ // Repositories: Enable Server files, URL downloader, Wikimedia.
+ static::add_plugin($presetid, 'repository', 'local', true);
+ static::add_plugin($presetid, 'repository', 'url', true);
+ static::add_plugin($presetid, 'repository', 'wikimedia', true);
+
+ // Text editors: Enable TinyMCE HTML editor.
+ static::add_plugin($presetid, 'editor', 'tinymce', true);
+ }
+}
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_bloglevel.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_bloglevel.php
similarity index 92%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_bloglevel.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_bloglevel.php
index d7680df6e0e..3e69dd02d57 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_bloglevel.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_bloglevel.php
@@ -14,17 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
/**
* Select setting for blog's bloglevel setting.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_bloglevel extends admin_preset_admin_setting_configselect {
+class adminpresets_admin_setting_bloglevel extends adminpresets_admin_setting_configselect {
/**
* Extended to change the block visibility.
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configcheckbox.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_configcheckbox.php
similarity index 89%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configcheckbox.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_configcheckbox.php
index 139cd0eac4e..f58145f8b72 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configcheckbox.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_configcheckbox.php
@@ -14,17 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
/**
* Checkbox setting.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_configcheckbox extends admin_preset_setting {
+class adminpresets_admin_setting_configcheckbox extends adminpresets_setting {
protected function set_value($value) {
$this->value = clean_param($value, PARAM_BOOL);
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configcheckbox_with_advanced.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_configcheckbox_with_advanced.php
similarity index 89%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configcheckbox_with_advanced.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_configcheckbox_with_advanced.php
index cdf48595d90..dcf0ef64461 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configcheckbox_with_advanced.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_configcheckbox_with_advanced.php
@@ -14,19 +14,19 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
use admin_setting;
/**
* Checkbox with an advanced checkbox that controls an additional $name.'_adv' config setting.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_configcheckbox_with_advanced extends admin_preset_admin_setting_configcheckbox {
+class adminpresets_admin_setting_configcheckbox_with_advanced extends adminpresets_admin_setting_configcheckbox {
public function __construct(admin_setting $settingdata, $dbsettingvalue) {
// To look for other values.
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configcheckbox_with_lock.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_configcheckbox_with_lock.php
similarity index 89%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configcheckbox_with_lock.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_configcheckbox_with_lock.php
index 6ab7d21d132..f387ca4f60a 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configcheckbox_with_lock.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_configcheckbox_with_lock.php
@@ -14,19 +14,19 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
use admin_setting;
/**
* Checkbox with an advanced checkbox that controls an additional $name.'_locked' config setting.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_configcheckbox_with_lock extends admin_preset_admin_setting_configcheckbox {
+class adminpresets_admin_setting_configcheckbox_with_lock extends adminpresets_admin_setting_configcheckbox {
public function __construct(admin_setting $settingdata, $dbsettingvalue) {
// To look for other values.
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configiplist.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_configiplist.php
similarity index 87%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configiplist.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_configiplist.php
index abf845354af..8bdd571d1e3 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configiplist.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_configiplist.php
@@ -14,17 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
/**
* Used to validate a textarea used for ip addresses.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_configiplist extends admin_preset_admin_setting_configtext {
+class adminpresets_admin_setting_configiplist extends adminpresets_admin_setting_configtext {
protected function set_value($value) {
// Check ip format.
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configmulticheckbox.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_configmulticheckbox.php
similarity index 85%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configmulticheckbox.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_configmulticheckbox.php
index 801e5e02e33..bfc35c9143e 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configmulticheckbox.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_configmulticheckbox.php
@@ -14,17 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
/**
* Class to be extended by multicheckbox settings.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_configmulticheckbox extends admin_preset_admin_setting_configmultiselect {
+class adminpresets_admin_setting_configmulticheckbox extends adminpresets_admin_setting_configmultiselect {
public function set_behaviors() {
$this->behaviors['loadchoices'] = &$this->settingdata;
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configmultiselect.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_configmultiselect.php
similarity index 93%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configmultiselect.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_configmultiselect.php
index 69cc409e050..2052ac5c054 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configmultiselect.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_configmultiselect.php
@@ -14,17 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
/**
* Extends the base class and lists the selected values separated by comma.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_configmultiselect extends admin_preset_setting {
+class adminpresets_admin_setting_configmultiselect extends adminpresets_setting {
/**
* Ensure that the $value values are setting choices.
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configmultiselect_with_loader.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_configmultiselect_with_loader.php
similarity index 84%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configmultiselect_with_loader.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_configmultiselect_with_loader.php
index 5860c36ca1d..c0e42c6d866 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configmultiselect_with_loader.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_configmultiselect_with_loader.php
@@ -14,17 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
/**
* Generalizes a configmultipleselect with load_choices().
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_configmultiselect_with_loader extends admin_preset_admin_setting_configmultiselect {
+class adminpresets_admin_setting_configmultiselect_with_loader extends adminpresets_admin_setting_configmultiselect {
public function set_behaviors() {
$this->behaviors['loadchoices'] = &$this->settingdata;
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configselect.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_configselect.php
similarity index 93%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configselect.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_configselect.php
index 589c892a87a..17a4ed7c698 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configselect.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_configselect.php
@@ -14,17 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
/**
* Select one value from list.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_configselect extends admin_preset_setting {
+class adminpresets_admin_setting_configselect extends adminpresets_setting {
/**
* Sets the setting value cleaning it.
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configselect_with_advanced.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_configselect_with_advanced.php
similarity index 91%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configselect_with_advanced.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_configselect_with_advanced.php
index 9b9e25605e8..55d82ab90c1 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configselect_with_advanced.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_configselect_with_advanced.php
@@ -14,19 +14,19 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
use admin_setting;
/**
* Adds support for the "advanced" attribute.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_configselect_with_advanced extends admin_preset_admin_setting_configselect {
+class adminpresets_admin_setting_configselect_with_advanced extends adminpresets_admin_setting_configselect {
/** @var string Name of the advanced setting. **/
protected $advancedkey;
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configtext.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_configtext.php
similarity index 92%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configtext.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_configtext.php
index 7672b400eeb..fbac4c15a8c 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configtext.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_configtext.php
@@ -14,17 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
/**
* Basic text setting, cleans the param using the admin_setting paramtext attribute.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_configtext extends admin_preset_setting {
+class adminpresets_admin_setting_configtext extends adminpresets_setting {
/**
* Validates the value using paramtype attribute
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configtext_with_advanced.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_configtext_with_advanced.php
similarity index 89%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configtext_with_advanced.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_configtext_with_advanced.php
index 5417977d42c..c7538b64d49 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configtext_with_advanced.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_configtext_with_advanced.php
@@ -14,19 +14,19 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
use admin_setting;
/**
* Adds the advanced attribute.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_configtext_with_advanced extends admin_preset_admin_setting_configtext {
+class adminpresets_admin_setting_configtext_with_advanced extends adminpresets_admin_setting_configtext {
public function __construct(admin_setting $settingdata, $dbsettingvalue) {
// To look for other values.
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configtime.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_configtime.php
similarity index 92%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configtime.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_configtime.php
index a7d12c1fe56..da45019b714 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_configtime.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_configtime.php
@@ -14,17 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
/**
* Time selector.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_configtime extends admin_preset_setting {
+class adminpresets_admin_setting_configtime extends adminpresets_setting {
/**
* To check that the value is one of the options
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_devicedetectregex.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_devicedetectregex.php
similarity index 88%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_devicedetectregex.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_devicedetectregex.php
index 33c1660fa1a..0ff584f6873 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_devicedetectregex.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_devicedetectregex.php
@@ -14,17 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
/**
* Reimplementation to allow human friendly view of the selected regexps.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_devicedetectregex extends admin_preset_admin_setting_configtext {
+class adminpresets_admin_setting_devicedetectregex extends adminpresets_admin_setting_configtext {
public function set_visiblevalue() {
$values = json_decode($this->get_value());
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_gradecat_combo.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_gradecat_combo.php
similarity index 92%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_gradecat_combo.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_gradecat_combo.php
index 773112004d3..e31a590ec51 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_gradecat_combo.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_gradecat_combo.php
@@ -14,19 +14,19 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
use admin_setting;
/**
* A select with force and advanced options
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_gradecat_combo extends admin_preset_admin_setting_configselect {
+class adminpresets_admin_setting_gradecat_combo extends adminpresets_admin_setting_configselect {
/**
* One db value for two setting attributes
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_sitesettext.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_sitesettext.php
similarity index 92%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_sitesettext.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_sitesettext.php
index 4e3979404b1..01e96d71e28 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_sitesettext.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_sitesettext.php
@@ -14,17 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
/**
* Reimplemented to store values in course table, not in config or config_plugins.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_sitesettext extends admin_preset_admin_setting_configtext {
+class adminpresets_admin_setting_sitesettext extends adminpresets_admin_setting_configtext {
/**
* Overwritten to store the value in the course table
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_special_backupdays.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_special_backupdays.php
similarity index 91%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_special_backupdays.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_special_backupdays.php
index 255c8aa3a87..a40df998bc5 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_special_backupdays.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_special_backupdays.php
@@ -14,19 +14,19 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
/**
* Special control for selecting days to backup.
*
* It doesn't specify loadchoices behavior because is set_visiblevalue who needs it.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_special_backupdays extends admin_preset_setting {
+class adminpresets_admin_setting_special_backupdays extends adminpresets_setting {
protected function set_value($value) {
$this->value = clean_param($value, PARAM_SEQUENCE);
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_special_calendar_weekend.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_special_calendar_weekend.php
similarity index 89%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_special_calendar_weekend.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_special_calendar_weekend.php
index 96a7cb58537..f848d0584f6 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_special_calendar_weekend.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_special_calendar_weekend.php
@@ -14,17 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
/**
* Special admin control for calendar weekend.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_special_calendar_weekend extends admin_preset_setting {
+class adminpresets_admin_setting_special_calendar_weekend extends adminpresets_setting {
protected function set_visiblevalue() {
if (!$this->value) {
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_users_with_capability.php b/adminpresets/classes/local/setting/adminpresets_admin_setting_users_with_capability.php
similarity index 87%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_users_with_capability.php
rename to adminpresets/classes/local/setting/adminpresets_admin_setting_users_with_capability.php
index 3e4516ce758..e46db3afbad 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_admin_setting_users_with_capability.php
+++ b/adminpresets/classes/local/setting/adminpresets_admin_setting_users_with_capability.php
@@ -14,17 +14,17 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
/**
* Extends configselect to reuse set_valuevisible.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_admin_setting_users_with_capability extends admin_preset_admin_setting_configmultiselect {
+class adminpresets_admin_setting_users_with_capability extends adminpresets_admin_setting_configmultiselect {
protected function set_behaviors() {
$this->behaviors['loadchoices'] = &$this->settingdata;
diff --git a/admin/tool/admin_presets/classes/local/setting/admin_preset_setting.php b/adminpresets/classes/local/setting/adminpresets_setting.php
similarity index 88%
rename from admin/tool/admin_presets/classes/local/setting/admin_preset_setting.php
rename to adminpresets/classes/local/setting/adminpresets_setting.php
index 21c49303d86..0b508d2f1b7 100644
--- a/admin/tool/admin_presets/classes/local/setting/admin_preset_setting.php
+++ b/adminpresets/classes/local/setting/adminpresets_setting.php
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
use admin_setting;
use moodle_exception;
@@ -23,12 +23,12 @@ use stdClass;
/**
* Admin tool presets plugin to load some settings.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_setting {
+class adminpresets_setting {
/**
* @var admin_setting
@@ -54,13 +54,6 @@ class admin_preset_setting {
*/
protected $visiblevalue;
- /**
- * Text to display on the TreeView
- *
- * @var string
- */
- protected $text;
-
/**
* For multiple value settings, used to look for the other values
*
@@ -106,7 +99,7 @@ class admin_preset_setting {
/**
* Applies the children class specific behaviors
*
- * See admin_presets_delegation() for the available extra behaviors
+ * See delegation class for the available extra behaviors
*/
protected function apply_behaviors() {
if (!empty($this->behaviors)) {
@@ -173,24 +166,6 @@ class admin_preset_setting {
return $encoded;
}
- public function get_text() {
- return $this->encode_string($this->text);
- }
-
- /**
- * Sets the text to display on the settings tree
- *
- * Default format: I'm a setting visible name (setting value: "VALUE")
- */
- public function set_text() {
- $this->set_visiblevalue();
-
- $namediv = '' . $this->settingdata->visiblename . '
';
- $valuediv = '' . $this->visiblevalue . '
';
-
- $this->text = $namediv . $valuediv . '
';
- }
-
public function get_attributes() {
return $this->attributes;
}
@@ -303,7 +278,7 @@ class admin_preset_setting {
// Getting the inserted config_log id.
if (!$id = $DB->insert_record('config_log', $log)) {
- throw new moodle_exception('errorinserting', 'tool_admin_presets');
+ throw new moodle_exception('errorinserting', 'core_adminpresets');
}
return $id;
diff --git a/admin/tool/admin_presets/classes/local/setting/delegation.php b/adminpresets/classes/local/setting/delegation.php
similarity index 87%
rename from admin/tool/admin_presets/classes/local/setting/delegation.php
rename to adminpresets/classes/local/setting/delegation.php
index 343f3259f8e..25cf42af27f 100644
--- a/admin/tool/admin_presets/classes/local/setting/delegation.php
+++ b/adminpresets/classes/local/setting/delegation.php
@@ -14,14 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
use admin_setting;
/**
* Cross-class methods
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -38,9 +38,9 @@ class delegation {
public function extra_set_visiblevalue(bool $value, string $type): string {
// Adding the advanced value to the text string if present.
if ($value) {
- $string = get_string('markedas' . $type, 'tool_admin_presets');
+ $string = get_string('markedas' . $type, 'core_adminpresets');
} else {
- $string = get_string('markedasnon' . $type, 'tool_admin_presets');
+ $string = get_string('markedasnon' . $type, 'core_adminpresets');
}
// Adding the advanced state.
diff --git a/admin/tool/admin_presets/classes/manager.php b/adminpresets/classes/manager.php
similarity index 75%
rename from admin/tool/admin_presets/classes/manager.php
rename to adminpresets/classes/manager.php
index a691bac488d..1fcb43a3c7e 100644
--- a/admin/tool/admin_presets/classes/manager.php
+++ b/adminpresets/classes/manager.php
@@ -14,11 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets;
+namespace core_adminpresets;
use memory_xml_output;
use moodle_exception;
-use SimpleXMLElement;
use stdClass;
use xml_writer;
@@ -30,7 +29,7 @@ require_once($CFG->libdir . '/adminlib.php');
/**
* Admin tool presets manager class.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @copyright 2021 Pimenko
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
@@ -43,75 +42,75 @@ class manager {
/** @var array Setting classes mapping, to associated the local/setting class that should be used when there is
* no specific class. */
protected static $settingclassesmap = [
- 'admin_preset_admin_setting_agedigitalconsentmap' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_configcolourpicker' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_configdirectory' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_configduration_with_advanced' => 'admin_preset_admin_setting_configtext_with_advanced',
- 'admin_preset_admin_setting_configduration' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_configempty' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_configexecutable' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_configfile' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_confightmleditor' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_configmixedhostiplist' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_configmultiselect_modules' => 'admin_preset_admin_setting_configmultiselect_with_loader',
- 'admin_preset_admin_setting_configpasswordunmask' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_configportlist' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_configselect_with_lock' => 'admin_preset_admin_setting_configselect',
- 'admin_preset_admin_setting_configtext_trim_lower' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_configtext_with_maxlength' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_configtextarea' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_configthemepreset' => 'admin_preset_admin_setting_configselect',
- 'admin_preset_admin_setting_countrycodes' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_courselist_frontpage' => 'admin_preset_admin_setting_configmultiselect_with_loader',
- 'admin_preset_admin_setting_description' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_enablemobileservice' => 'admin_preset_admin_setting_configcheckbox',
- 'admin_preset_admin_setting_filetypes' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_forcetimezone' => 'admin_preset_admin_setting_configselect',
- 'admin_preset_admin_setting_grade_profilereport' => 'admin_preset_admin_setting_configmultiselect_with_loader',
- 'admin_preset_admin_setting_langlist' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_my_grades_report' => 'admin_preset_admin_setting_configselect',
- 'admin_preset_admin_setting_pickroles' => 'admin_preset_admin_setting_configmulticheckbox',
- 'admin_preset_admin_setting_question_behaviour' => 'admin_preset_admin_setting_configmultiselect_with_loader',
- 'admin_preset_admin_setting_regradingcheckbox' => 'admin_preset_admin_setting_configcheckbox',
- 'admin_preset_admin_setting_scsscode' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_servertimezone' => 'admin_preset_admin_setting_configselect',
- 'admin_preset_admin_setting_sitesetcheckbox' => 'admin_preset_admin_setting_configcheckbox',
- 'admin_preset_admin_setting_sitesetselect' => 'admin_preset_admin_setting_configselect',
- 'admin_preset_admin_setting_special_adminseesall' => 'admin_preset_admin_setting_configcheckbox',
- 'admin_preset_admin_setting_special_backup_auto_destination' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_special_coursecontact' => 'admin_preset_admin_setting_configmulticheckbox',
- 'admin_preset_admin_setting_special_coursemanager' => 'admin_preset_admin_setting_configmulticheckbox',
- 'admin_preset_admin_setting_special_debug' => 'admin_preset_admin_setting_configmultiselect_with_loader',
- 'admin_preset_admin_setting_special_frontpagedesc' => 'admin_preset_admin_setting_sitesettext',
- 'admin_preset_admin_setting_special_gradebookroles' => 'admin_preset_admin_setting_configmulticheckbox',
- 'admin_preset_admin_setting_special_gradeexport' => 'admin_preset_admin_setting_configmulticheckbox',
- 'admin_preset_admin_setting_special_gradelimiting' => 'admin_preset_admin_setting_configcheckbox',
- 'admin_preset_admin_setting_special_grademinmaxtouse' => 'admin_preset_admin_setting_configselect',
- 'admin_preset_admin_setting_special_gradepointdefault' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_special_gradepointmax' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_admin_setting_special_registerauth' => 'admin_preset_admin_setting_configmultiselect_with_loader',
- 'admin_preset_admin_setting_special_selectsetup' => 'admin_preset_admin_setting_configselect',
- 'admin_preset_admin_settings_country_select' => 'admin_preset_admin_setting_configmultiselect_with_loader',
- 'admin_preset_admin_settings_coursecat_select' => 'admin_preset_admin_setting_configmultiselect_with_loader',
- 'admin_preset_admin_settings_h5plib_handler_select' => 'admin_preset_admin_setting_configselect',
- 'admin_preset_admin_settings_num_course_sections' => 'admin_preset_admin_setting_configmultiselect_with_loader',
- 'admin_preset_admin_settings_sitepolicy_handler_select' => 'admin_preset_admin_setting_configselect',
- 'admin_preset_antivirus_clamav_pathtounixsocket_setting' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_antivirus_clamav_runningmethod_setting' => 'admin_preset_admin_setting_configselect',
- 'admin_preset_antivirus_clamav_tcpsockethost_setting' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_auth_db_admin_setting_special_auth_configtext' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_auth_ldap_admin_setting_special_lowercase_configtext' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_auth_ldap_admin_setting_special_ntlm_configtext' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_auth_shibboleth_admin_setting_convert_data' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_auth_shibboleth_admin_setting_special_idp_configtextarea' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_auth_shibboleth_admin_setting_special_wayf_select' => 'admin_preset_admin_setting_configselect',
- 'admin_preset_editor_atto_toolbar_setting' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_editor_tinymce_json_setting_textarea' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_enrol_database_admin_setting_category' => 'admin_preset_admin_setting_configselect',
- 'admin_preset_enrol_flatfile_role_setting' => 'admin_preset_admin_setting_configtext',
- 'admin_preset_enrol_ldap_admin_setting_category' => 'admin_preset_admin_setting_configselect',
- 'admin_preset_format_singleactivity_admin_setting_activitytype' => 'admin_preset_admin_setting_configselect',
- 'admin_preset_qtype_multichoice_admin_setting_answernumbering' => 'admin_preset_admin_setting_configselect',
+ 'adminpresets_admin_setting_agedigitalconsentmap' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_configcolourpicker' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_configdirectory' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_configduration_with_advanced' => 'adminpresets_admin_setting_configtext_with_advanced',
+ 'adminpresets_admin_setting_configduration' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_configempty' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_configexecutable' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_configfile' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_confightmleditor' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_configmixedhostiplist' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_configmultiselect_modules' => 'adminpresets_admin_setting_configmultiselect_with_loader',
+ 'adminpresets_admin_setting_configpasswordunmask' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_configportlist' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_configselect_with_lock' => 'adminpresets_admin_setting_configselect',
+ 'adminpresets_admin_setting_configtext_trim_lower' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_configtext_with_maxlength' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_configtextarea' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_configthemepreset' => 'adminpresets_admin_setting_configselect',
+ 'adminpresets_admin_setting_countrycodes' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_courselist_frontpage' => 'adminpresets_admin_setting_configmultiselect_with_loader',
+ 'adminpresets_admin_setting_description' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_enablemobileservice' => 'adminpresets_admin_setting_configcheckbox',
+ 'adminpresets_admin_setting_filetypes' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_forcetimezone' => 'adminpresets_admin_setting_configselect',
+ 'adminpresets_admin_setting_grade_profilereport' => 'adminpresets_admin_setting_configmultiselect_with_loader',
+ 'adminpresets_admin_setting_langlist' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_my_grades_report' => 'adminpresets_admin_setting_configselect',
+ 'adminpresets_admin_setting_pickroles' => 'adminpresets_admin_setting_configmulticheckbox',
+ 'adminpresets_admin_setting_question_behaviour' => 'adminpresets_admin_setting_configmultiselect_with_loader',
+ 'adminpresets_admin_setting_regradingcheckbox' => 'adminpresets_admin_setting_configcheckbox',
+ 'adminpresets_admin_setting_scsscode' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_servertimezone' => 'adminpresets_admin_setting_configselect',
+ 'adminpresets_admin_setting_sitesetcheckbox' => 'adminpresets_admin_setting_configcheckbox',
+ 'adminpresets_admin_setting_sitesetselect' => 'adminpresets_admin_setting_configselect',
+ 'adminpresets_admin_setting_special_adminseesall' => 'adminpresets_admin_setting_configcheckbox',
+ 'adminpresets_admin_setting_special_backup_auto_destination' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_special_coursecontact' => 'adminpresets_admin_setting_configmulticheckbox',
+ 'adminpresets_admin_setting_special_coursemanager' => 'adminpresets_admin_setting_configmulticheckbox',
+ 'adminpresets_admin_setting_special_debug' => 'adminpresets_admin_setting_configmultiselect_with_loader',
+ 'adminpresets_admin_setting_special_frontpagedesc' => 'adminpresets_admin_setting_sitesettext',
+ 'adminpresets_admin_setting_special_gradebookroles' => 'adminpresets_admin_setting_configmulticheckbox',
+ 'adminpresets_admin_setting_special_gradeexport' => 'adminpresets_admin_setting_configmulticheckbox',
+ 'adminpresets_admin_setting_special_gradelimiting' => 'adminpresets_admin_setting_configcheckbox',
+ 'adminpresets_admin_setting_special_grademinmaxtouse' => 'adminpresets_admin_setting_configselect',
+ 'adminpresets_admin_setting_special_gradepointdefault' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_special_gradepointmax' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_admin_setting_special_registerauth' => 'adminpresets_admin_setting_configmultiselect_with_loader',
+ 'adminpresets_admin_setting_special_selectsetup' => 'adminpresets_admin_setting_configselect',
+ 'adminpresets_admin_settings_country_select' => 'adminpresets_admin_setting_configmultiselect_with_loader',
+ 'adminpresets_admin_settings_coursecat_select' => 'adminpresets_admin_setting_configmultiselect_with_loader',
+ 'adminpresets_admin_settings_h5plib_handler_select' => 'adminpresets_admin_setting_configselect',
+ 'adminpresets_admin_settings_num_course_sections' => 'adminpresets_admin_setting_configmultiselect_with_loader',
+ 'adminpresets_admin_settings_sitepolicy_handler_select' => 'adminpresets_admin_setting_configselect',
+ 'adminpresets_antivirus_clamav_pathtounixsocket_setting' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_antivirus_clamav_runningmethod_setting' => 'adminpresets_admin_setting_configselect',
+ 'adminpresets_antivirus_clamav_tcpsockethost_setting' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_auth_db_admin_setting_special_auth_configtext' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_auth_ldap_admin_setting_special_lowercase_configtext' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_auth_ldap_admin_setting_special_ntlm_configtext' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_auth_shibboleth_admin_setting_convert_data' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_auth_shibboleth_admin_setting_special_idp_configtextarea' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_auth_shibboleth_admin_setting_special_wayf_select' => 'adminpresets_admin_setting_configselect',
+ 'adminpresets_editor_atto_toolbar_setting' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_editor_tinymce_json_setting_textarea' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_enrol_database_admin_setting_category' => 'adminpresets_admin_setting_configselect',
+ 'adminpresets_enrol_flatfile_role_setting' => 'adminpresets_admin_setting_configtext',
+ 'adminpresets_enrol_ldap_admin_setting_category' => 'adminpresets_admin_setting_configselect',
+ 'adminpresets_format_singleactivity_admin_setting_activitytype' => 'adminpresets_admin_setting_configselect',
+ 'adminpresets_qtype_multichoice_admin_setting_answernumbering' => 'adminpresets_admin_setting_configselect',
];
/** @var array Relation between database fields and XML files. **/
@@ -248,7 +247,7 @@ class manager {
// Look for settings attributes if it is a presets.
if (!$sitedbvalues) {
$itemid = $dbsettings[$values->plugin][$settingname]->itemid;
- $attrs = $DB->get_records('tool_admin_presets_it_a',
+ $attrs = $DB->get_records('adminpresets_it_a',
['itemid' => $itemid], '', 'name, value');
}
foreach ($attributes as $defaultvarname => $varname) {
@@ -280,9 +279,6 @@ class manager {
}
}
- // Setting the text.
- $setting->set_text();
-
// Adding to general settings array.
$settings[$values->plugin][$settingname] = $setting;
}
@@ -314,15 +310,15 @@ class manager {
$plugins = \core_component::get_plugin_list($plugindata[0]);
if (array_key_exists($plugindata[1], $plugins)) {
// Check if there is a specific class for this plugin admin setting.
- $settingname = 'admin_preset_' . $settingtype;
- $classname = "\\$plugindata[0]_$plugindata[1]\\local\\setting\\$settingname";
+ $settingname = 'adminpresets_' . $settingtype;
+ $classname = "\\$plugindata[0]_$plugindata[1]\\adminpresets\\$settingname";
if (!class_exists($classname)) {
$classname = null;
}
}
} else {
- $settingname = 'admin_preset_' . $settingtype;
- $classname = '\\tool_admin_presets\\local\\setting\\' . $settingname;
+ $settingname = 'adminpresets_' . $settingtype;
+ $classname = '\\core_adminpresets\\local\\setting\\' . $settingname;
if (!class_exists($classname)) {
// Check if there is some mapped class that should be used for this setting.
$classname = self::get_settings_class($settingname);
@@ -331,7 +327,7 @@ class manager {
if (is_null($classname)) {
// Return the default setting class if there is no specific class for this setting.
- $classname = '\\tool_admin_presets\\local\\setting\\admin_preset_setting';
+ $classname = '\\core_adminpresets\\local\\setting\\adminpresets_setting';
}
return new $classname($settingdata, $currentvalue);
@@ -345,7 +341,7 @@ class manager {
*/
public static function get_settings_class(string $classname): ?string {
if (array_key_exists($classname, self::$settingclassesmap)) {
- return '\\tool_admin_presets\\local\\setting\\' . self::$settingclassesmap[$classname];
+ return '\\core_adminpresets\\local\\setting\\' . self::$settingclassesmap[$classname];
}
return null;
@@ -386,8 +382,8 @@ class manager {
public function apply_preset(int $presetid, bool $simulate = false): array {
global $DB;
- if (!$DB->get_record('tool_admin_presets', ['id' => $presetid])) {
- throw new moodle_exception('errornopreset', 'tool_admin_presets');
+ if (!$DB->get_record('adminpresets', ['id' => $presetid])) {
+ throw new moodle_exception('errornopreset', 'core_adminpresets');
}
// Apply preset settings.
@@ -401,7 +397,7 @@ class manager {
if (!$simulate) {
// Store it in a config setting as the last preset applied.
- set_config('lastpresetapplied', $presetid, 'tool_admin_presets');
+ set_config('lastpresetapplied', $presetid, 'adminpresets');
}
return [$applied, $skipped];
@@ -425,7 +421,7 @@ class manager {
'author' => $data->author ?? '',
];
if (!$presetid = helper::create_preset($presetdata)) {
- throw new moodle_exception('errorinserting', 'tool_admin_presets');
+ throw new moodle_exception('errorinserting', 'core_adminpresets');
}
// Store settings.
@@ -435,7 +431,7 @@ class manager {
$sitesettings = $this->get_site_settings();
// Sensible settings.
- $sensiblesettings = explode(',', str_replace(' ', '', get_config('tool_admin_presets', 'sensiblesettings')));
+ $sensiblesettings = explode(',', str_replace(' ', '', get_config('adminpresets', 'sensiblesettings')));
$sensiblesettings = array_combine($sensiblesettings, $sensiblesettings);
foreach ($sitesettings as $plugin => $pluginsettings) {
foreach ($pluginsettings as $settingname => $sitesetting) {
@@ -449,8 +445,8 @@ class manager {
$setting->plugin = $plugin;
$setting->name = $settingname;
$setting->value = $sitesetting->get_value();
- if (!$setting->id = $DB->insert_record('tool_admin_presets_it', $setting)) {
- throw new moodle_exception('errorinserting', 'tool_admin_presets');
+ if (!$setting->id = $DB->insert_record('adminpresets_it', $setting)) {
+ throw new moodle_exception('errorinserting', 'core_adminpresets');
}
// Setting attributes must also be exported.
@@ -461,7 +457,7 @@ class manager {
$attr->name = $attname;
$attr->value = $attvalue;
- $DB->insert_record('tool_admin_presets_it_a', $attr);
+ $DB->insert_record('adminpresets_it_a', $attr);
}
}
$settingsfound = true;
@@ -483,7 +479,7 @@ class manager {
$entry->name = $pluginname;
$entry->enabled = $pluginclass::get_enabled_plugin($pluginname);
- $DB->insert_record('tool_admin_presets_plug', $entry);
+ $DB->insert_record('adminpresets_plug', $entry);
$pluginsfound = true;
}
}
@@ -491,7 +487,7 @@ class manager {
// If there are no settings nor plugins, the admin preset record should be removed.
if (!$settingsfound && !$pluginsfound) {
- $DB->delete_records('tool_admin_presets', ['id' => $presetid]);
+ $DB->delete_records('adminpresets', ['id' => $presetid]);
$presetid = null;
}
@@ -507,8 +503,8 @@ class manager {
public function download_preset(int $presetid): array {
global $DB;
- if (!$preset = $DB->get_record('tool_admin_presets', ['id' => $presetid])) {
- throw new moodle_exception('errornopreset', 'tool_admin_presets');
+ if (!$preset = $DB->get_record('adminpresets', ['id' => $presetid])) {
+ throw new moodle_exception('errornopreset', 'core_adminpresets');
}
// Start.
@@ -523,7 +519,7 @@ class manager {
}
// We ride through the settings array.
- $items = $DB->get_records('tool_admin_presets_it', ['adminpresetid' => $preset->id]);
+ $items = $DB->get_records('adminpresets_it', ['adminpresetid' => $preset->id]);
$allsettings = $this->get_settings_from_db($items);
if ($allsettings) {
$xmlwriter->begin_tag('ADMIN_SETTINGS');
@@ -546,7 +542,7 @@ class manager {
$attributes = [];
// Getting setting attributes, if present.
- $attrs = $DB->get_records('tool_admin_presets_it_a', ['itemid' => $setting->itemid]);
+ $attrs = $DB->get_records('adminpresets_it_a', ['itemid' => $setting->itemid]);
if ($attrs) {
foreach ($attrs as $attr) {
$attributes[$attr->name] = $attr->value;
@@ -566,7 +562,7 @@ class manager {
}
// We ride through the plugins array.
- $data = $DB->get_records('tool_admin_presets_plug', ['adminpresetid' => $preset->id]);
+ $data = $DB->get_records('adminpresets_plug', ['adminpresetid' => $preset->id]);
if ($data) {
$plugins = [];
foreach ($data as $plugin) {
@@ -636,8 +632,8 @@ class manager {
}
// Create the preset.
- if (!$preset->id = $DB->insert_record('tool_admin_presets', $preset)) {
- throw new moodle_exception('errorinserting', 'tool_admin_presets');
+ if (!$preset->id = $DB->insert_record('adminpresets', $preset)) {
+ throw new moodle_exception('errorinserting', 'core_adminpresets');
}
// Process settings.
@@ -682,8 +678,8 @@ class manager {
$item->value = $presetsetting->get_value();
// Insert preset item.
- if (!$item->id = $DB->insert_record('tool_admin_presets_it', $item)) {
- throw new moodle_exception('errorinserting', 'tool_admin_presets');
+ if (!$item->id = $DB->insert_record('adminpresets_it', $item)) {
+ throw new moodle_exception('errorinserting', 'core_adminpresets');
}
// Add setting attributes.
@@ -702,7 +698,7 @@ class manager {
$attr->itemid = $item->id;
$attr->name = $attrname;
$attr->value = $attrvalue->__toString();
- $DB->insert_record('tool_admin_presets_it_a', $attr);
+ $DB->insert_record('adminpresets_it_a', $attr);
}
}
}
@@ -725,8 +721,8 @@ class manager {
$entry->enabled = $plugin->__toString();
// Insert plugin.
- if (!$entry->id = $DB->insert_record('tool_admin_presets_plug', $entry)) {
- throw new moodle_exception('errorinserting', 'tool_admin_presets');
+ if (!$entry->id = $DB->insert_record('adminpresets_plug', $entry)) {
+ throw new moodle_exception('errorinserting', 'core_adminpresets');
}
}
}
@@ -734,7 +730,7 @@ class manager {
// If there are no valid or selected settings we should delete the admin preset record.
if (!$settingsfound && !$pluginsfound) {
- $DB->delete_records('tool_admin_presets', ['id' => $preset->id]);
+ $DB->delete_records('adminpresets', ['id' => $preset->id]);
$preset = null;
}
@@ -751,44 +747,44 @@ class manager {
global $DB;
// Check the preset exists.
- $preset = $DB->get_record('tool_admin_presets', ['id' => $presetid]);
+ $preset = $DB->get_record('adminpresets', ['id' => $presetid]);
if (!$preset) {
- throw new moodle_exception('errordeleting', 'tool_admin_presets');
+ throw new moodle_exception('errordeleting', 'core_adminpresets');
}
// Deleting the preset applications.
- if ($previouslyapplied = $DB->get_records('tool_admin_presets_app', ['adminpresetid' => $presetid], 'id')) {
+ if ($previouslyapplied = $DB->get_records('adminpresets_app', ['adminpresetid' => $presetid], 'id')) {
$appids = array_keys($previouslyapplied);
list($insql, $inparams) = $DB->get_in_or_equal($appids);
- $DB->delete_records_select('tool_admin_presets_app_it', "adminpresetapplyid $insql", $inparams);
- $DB->delete_records_select('tool_admin_presets_app_it_a', "adminpresetapplyid $insql", $inparams);
- $DB->delete_records_select('tool_admin_presets_app_plug', "adminpresetapplyid $insql", $inparams);
+ $DB->delete_records_select('adminpresets_app_it', "adminpresetapplyid $insql", $inparams);
+ $DB->delete_records_select('adminpresets_app_it_a', "adminpresetapplyid $insql", $inparams);
+ $DB->delete_records_select('adminpresets_app_plug', "adminpresetapplyid $insql", $inparams);
- if (!$DB->delete_records('tool_admin_presets_app', ['adminpresetid' => $presetid])) {
- throw new moodle_exception('errordeleting', 'tool_admin_presets');
+ if (!$DB->delete_records('adminpresets_app', ['adminpresetid' => $presetid])) {
+ throw new moodle_exception('errordeleting', 'core_adminpresets');
}
}
// Getting items ids and remove advanced items associated to them.
- $items = $DB->get_records('tool_admin_presets_it', ['adminpresetid' => $presetid], 'id');
+ $items = $DB->get_records('adminpresets_it', ['adminpresetid' => $presetid], 'id');
if (!empty($items)) {
$itemsid = array_keys($items);
list($insql, $inparams) = $DB->get_in_or_equal($itemsid);
- $DB->delete_records_select('tool_admin_presets_it_a', "itemid $insql", $inparams);
+ $DB->delete_records_select('adminpresets_it_a', "itemid $insql", $inparams);
}
- if (!$DB->delete_records('tool_admin_presets_it', ['adminpresetid' => $presetid])) {
- throw new moodle_exception('errordeleting', 'tool_admin_presets');
+ if (!$DB->delete_records('adminpresets_it', ['adminpresetid' => $presetid])) {
+ throw new moodle_exception('errordeleting', 'core_adminpresets');
}
// Delete plugins.
- if (!$DB->delete_records('tool_admin_presets_plug', ['adminpresetid' => $presetid])) {
- throw new moodle_exception('errordeleting', 'tool_admin_presets');
+ if (!$DB->delete_records('adminpresets_plug', ['adminpresetid' => $presetid])) {
+ throw new moodle_exception('errordeleting', 'core_adminpresets');
}
// Delete preset.
- if (!$DB->delete_records('tool_admin_presets', ['id' => $presetid])) {
- throw new moodle_exception('errordeleting', 'tool_admin_presets');
+ if (!$DB->delete_records('adminpresets', ['id' => $presetid])) {
+ throw new moodle_exception('errordeleting', 'core_adminpresets');
}
}
@@ -812,13 +808,13 @@ class manager {
// Actual settings.
$sitesettings = $this->get_site_settings();
- if (!$DB->get_record('tool_admin_presets_app', ['id' => $presetappid])) {
- throw new moodle_exception('wrongid', 'tool_admin_presets');
+ if (!$DB->get_record('adminpresets_app', ['id' => $presetappid])) {
+ throw new moodle_exception('wrongid', 'core_adminpresets');
}
// Items.
$itemsql = "SELECT cl.id, cl.plugin, cl.name, cl.value, cl.oldvalue, ap.adminpresetapplyid
- FROM {tool_admin_presets_app_it} ap
+ FROM {adminpresets_app_it} ap
JOIN {config_log} cl ON cl.id = ap.configlogid
WHERE ap.adminpresetapplyid = :presetid";
$itemchanges = $DB->get_records_sql($itemsql, ['presetid' => $presetappid]);
@@ -832,7 +828,6 @@ class manager {
if (!empty($sitesettings[$change->plugin][$change->name])) {
$actualsetting = $sitesettings[$change->plugin][$change->name];
$oldsetting = $this->get_setting($actualsetting->get_settingdata(), $change->oldvalue);
- $oldsetting->set_text();
$visiblepluginname = $oldsetting->get_settingdata()->plugin;
if ($visiblepluginname == 'none') {
@@ -852,12 +847,12 @@ class manager {
// Output table.
$rollback[] = $contextdata;
- // Deleting the admin_preset_apply_item instance.
+ // Deleting the adminpreset applied item instance.
$deletewhere = [
'adminpresetapplyid' => $change->adminpresetapplyid,
'configlogid' => $change->id,
];
- $DB->delete_records('tool_admin_presets_app_it', $deletewhere);
+ $DB->delete_records('adminpresets_app_it', $deletewhere);
} else {
$failures[] = $contextdata;
@@ -868,7 +863,7 @@ class manager {
// Attributes.
$attrsql = "SELECT cl.id, cl.plugin, cl.name, cl.value, cl.oldvalue, ap.itemname, ap.adminpresetapplyid
- FROM {tool_admin_presets_app_it_a} ap
+ FROM {adminpresets_app_it_a} ap
JOIN {config_log} cl ON cl.id = ap.configlogid
WHERE ap.adminpresetapplyid = :presetid";
$attrchanges = $DB->get_records_sql($attrsql, ['presetid' => $presetappid]);
@@ -885,7 +880,6 @@ class manager {
$oldsetting = $this->get_setting($actualsetting->get_settingdata(), $actualsetting->get_value());
$oldsetting->set_attribute_value($change->name, $change->oldvalue);
- $oldsetting->set_text();
$varname = $change->plugin . '_' . $change->name;
@@ -906,12 +900,12 @@ class manager {
'visiblevalue' => $oldsetting->get_visiblevalue()
];
- // Deleting the admin_preset_apply_item_attr instance.
+ // Deleting the adminpreset applied item attribute instance.
$deletewhere = [
'adminpresetapplyid' => $change->adminpresetapplyid,
'configlogid' => $change->id,
];
- $DB->delete_records('tool_admin_presets_app_it_a', $deletewhere);
+ $DB->delete_records('adminpresets_app_it_a', $deletewhere);
} else {
$visiblepluginname = $oldsetting->get_settingdata()->plugin;
@@ -930,7 +924,7 @@ class manager {
}
// Plugins.
- $plugins = $DB->get_records('tool_admin_presets_app_plug', ['adminpresetapplyid' => $presetappid]);
+ $plugins = $DB->get_records('adminpresets_app_plug', ['adminpresetapplyid' => $presetappid]);
if ($plugins) {
foreach ($plugins as $plugin) {
$pluginclass = \core_plugin_manager::resolve_plugininfo_class($plugin->plugin);
@@ -949,16 +943,16 @@ class manager {
'visiblevalue' => $plugin->oldvalue,
];
}
- $DB->delete_records('tool_admin_presets_app_plug', ['adminpresetapplyid' => $presetappid]);
+ $DB->delete_records('adminpresets_app_plug', ['adminpresetapplyid' => $presetappid]);
}
// Delete application if no items nor attributes nor plugins of the application remains.
- if (!$DB->get_records('tool_admin_presets_app_it', ['adminpresetapplyid' => $presetappid]) &&
- !$DB->get_records('tool_admin_presets_app_it_a', ['adminpresetapplyid' => $presetappid]) &&
- !$DB->get_records('tool_admin_presets_app_plug', ['adminpresetapplyid' => $presetappid])) {
+ if (!$DB->get_records('adminpresets_app_it', ['adminpresetapplyid' => $presetappid]) &&
+ !$DB->get_records('adminpresets_app_it_a', ['adminpresetapplyid' => $presetappid]) &&
+ !$DB->get_records('adminpresets_app_plug', ['adminpresetapplyid' => $presetappid])) {
- $presetapp = $DB->get_record('tool_admin_presets_app', ['id' => $presetappid]);
- $DB->delete_records('tool_admin_presets_app', ['id' => $presetappid]);
+ $presetapp = $DB->get_record('adminpresets_app', ['id' => $presetappid]);
+ $DB->delete_records('adminpresets_app', ['id' => $presetappid]);
}
return [$presetapp, $rollback, $failures];
@@ -977,7 +971,7 @@ class manager {
$applied = [];
$skipped = [];
- if (!$items = $DB->get_records('tool_admin_presets_it', ['adminpresetid' => $presetid])) {
+ if (!$items = $DB->get_records('adminpresets_it', ['adminpresetid' => $presetid])) {
return [$applied, $skipped, $adminpresetapplyid];
}
@@ -1039,8 +1033,8 @@ class manager {
$presetapplied->adminpresetid = $presetid;
$presetapplied->userid = $USER->id;
$presetapplied->time = time();
- if (!$simulate && !$adminpresetapplyid = $DB->insert_record('tool_admin_presets_app', $presetapplied)) {
- throw new moodle_exception('errorinserting', 'tool_admin_presets');
+ if (!$simulate && !$adminpresetapplyid = $DB->insert_record('adminpresets_app', $presetapplied)) {
+ throw new moodle_exception('errorinserting', 'core_adminpresets');
}
}
@@ -1049,7 +1043,7 @@ class manager {
$applieditem = new stdClass();
$applieditem->adminpresetapplyid = $adminpresetapplyid;
if (!$simulate && $applieditem->configlogid = $presetsetting->save_value()) {
- $DB->insert_record('tool_admin_presets_app_it', $applieditem);
+ $DB->insert_record('adminpresets_app_it', $applieditem);
}
// For settings with multiple values.
@@ -1059,7 +1053,7 @@ class manager {
$applieditemattr->adminpresetapplyid = $applieditem->adminpresetapplyid;
$applieditemattr->configlogid = $attributelogid;
$applieditemattr->itemname = $presetsetting->get_settingdata()->name;
- $DB->insert_record('tool_admin_presets_app_it_a', $applieditemattr);
+ $DB->insert_record('adminpresets_app_it_a', $applieditemattr);
}
}
@@ -1089,10 +1083,10 @@ class manager {
$applied = [];
$skipped = [];
- $strenabled = get_string('enabled', 'tool_admin_presets');
- $strdisabled = get_string('disabled', 'tool_admin_presets');
+ $strenabled = get_string('enabled', 'core_adminpresets');
+ $strdisabled = get_string('disabled', 'core_adminpresets');
- $plugins = $DB->get_records('tool_admin_presets_plug', ['adminpresetid' => $presetid]);
+ $plugins = $DB->get_records('adminpresets_plug', ['adminpresetid' => $presetid]);
foreach ($plugins as $plugin) {
$pluginclass = \core_plugin_manager::resolve_plugininfo_class($plugin->plugin);
$oldvalue = $pluginclass::get_enabled_plugin($plugin->name);
@@ -1106,7 +1100,7 @@ class manager {
} else if ($plugin->enabled == 0) {
$visiblevalue = $strdisabled;
} else {
- $visiblevalue = get_string('disabledwithvalue', 'tool_admin_presets', $plugin->enabled);
+ $visiblevalue = get_string('disabledwithvalue', 'core_adminpresets', $plugin->enabled);
}
$data = [
@@ -1133,8 +1127,8 @@ class manager {
$presetapplied->adminpresetid = $presetid;
$presetapplied->userid = $USER->id;
$presetapplied->time = time();
- if (!$adminpresetapplyid = $DB->insert_record('tool_admin_presets_app', $presetapplied)) {
- throw new moodle_exception('errorinserting', 'tool_admin_presets');
+ if (!$adminpresetapplyid = $DB->insert_record('adminpresets_app', $presetapplied)) {
+ throw new moodle_exception('errorinserting', 'core_adminpresets');
}
}
@@ -1145,7 +1139,7 @@ class manager {
$appliedplug->name = $plugin->name;
$appliedplug->value = $plugin->enabled;
$appliedplug->oldvalue = $oldvalue;
- $DB->insert_record('tool_admin_presets_app_plug', $appliedplug);
+ $DB->insert_record('adminpresets_app_plug', $appliedplug);
}
if ($oldvalue > 0) {
@@ -1153,7 +1147,7 @@ class manager {
} else if ($oldvalue == 0) {
$oldvisiblevalue = $strdisabled;
} else {
- $oldvisiblevalue = get_string('disabledwithvalue', 'tool_admin_presets', $oldvalue);
+ $oldvisiblevalue = get_string('disabledwithvalue', 'core_adminpresets', $oldvalue);
}
$data['oldvisiblevalue'] = $oldvisiblevalue;
$applied[] = $data;
diff --git a/adminpresets/classes/privacy/provider.php b/adminpresets/classes/privacy/provider.php
new file mode 100644
index 00000000000..c552b0b45f7
--- /dev/null
+++ b/adminpresets/classes/privacy/provider.php
@@ -0,0 +1,125 @@
+.
+
+namespace core_adminpresets\privacy;
+
+use core_privacy\local\metadata\collection;
+use core_privacy\local\request\approved_contextlist;
+use core_privacy\local\request\approved_userlist;
+use core_privacy\local\request\contextlist;
+use core_privacy\local\request\userlist;
+
+/**
+ * Admin presets this file handle privacy provider.
+ *
+ * @package core_adminpresets
+ * @copyright 2021 Pimenko
+ * @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class provider implements
+ \core_privacy\local\metadata\provider,
+ \core_privacy\local\request\subsystem\provider,
+ \core_privacy\local\request\core_userlist_provider {
+
+ /**
+ * Returns information about the user data stored in this component.
+ *
+ * @param collection $collection A list of information about this component
+ * @return collection The collection object filled out with information about this component.
+ */
+ public static function get_metadata(collection $collection) : collection {
+ // These tables are really data about site configuration and not user data.
+
+ // The adminpresets includes information about which user performed a configuration change using the admin_presets
+ // tool.
+ // This is not considered to be user data.
+ $collection->add_database_table('adminpresets', [
+ 'userid' => 'privacy:metadata:adminpresets:userid',
+ 'name' => 'privacy:metadata:adminpresets:name',
+ 'comments' => 'privacy:metadata:adminpresets:comments',
+ 'site' => 'privacy:metadata:adminpresets:site',
+ 'moodlerelease' => 'privacy:metadata:adminpresets:moodlerelease',
+ 'timecreated' => 'privacy:metadata:adminpresets:timecreated',
+ ], 'privacy:metadata:adminpresets');
+
+ // The adminpresets_app includes information about which user performed configuration change using the admin_presets
+ // tool.
+ // This is not considered to be user data.
+ $collection->add_database_table('adminpresets_app', [
+ 'adminpresetid' => 'privacy:metadata:adminpresets_app:adminpresetid',
+ 'userid' => 'privacy:metadata:adminpresets_app:userid',
+ 'time' => 'privacy:metadata:adminpresets_app:time',
+ ], 'privacy:metadata:adminpresets_app');
+
+ return $collection;
+ }
+
+ /**
+ * Get the list of contexts that contain user information for the specified user.
+ *
+ * @param int $userid The user to search.
+ * @return contextlist $contextlist The contextlist containing the list of contexts used in this plugin.
+ */
+ public static function get_contexts_for_userid(int $userid) : contextlist {
+ return new contextlist();
+ }
+
+ /**
+ * Get the list of users who have data within a context.
+ *
+ * @param userlist $userlist The userlist containing the list of users who have data in this context/plugin combination.
+ */
+ public static function get_users_in_context(userlist $userlist) {
+ // Don't add any user.
+ }
+
+ /**
+ * Export all user data for the specified user, in the specified contexts.
+ *
+ * @param approved_contextlist $contextlist The approved contexts to export information for.
+ */
+ public static function export_user_data(approved_contextlist $contextlist) {
+ // None of the core tables should be exported.
+ }
+
+ /**
+ * Delete all data for all users in the specified context.
+ *
+ * @param context $context The specific context to delete data for.
+ */
+ public static function delete_data_for_all_users_in_context(\context $context) {
+ // None of the the data from these tables should be deleted.
+ }
+
+ /**
+ * Delete all user data for the specified user, in the specified contexts.
+ *
+ * @param approved_contextlist $contextlist The approved contexts and user information to delete information for.
+ */
+ public static function delete_data_for_user(approved_contextlist $contextlist) {
+ // None of the the data from these tables should be deleted.
+ }
+
+ /**
+ * Delete multiple users within a single context.
+ *
+ * @param approved_userlist $userlist The approved context and user information to delete information for.
+ */
+ public static function delete_data_for_users(approved_userlist $userlist) {
+ // None of the the data from these tables should be deleted.
+ }
+}
diff --git a/admin/tool/admin_presets/tests/fixtures/import_settings.xml b/adminpresets/tests/fixtures/import_settings.xml
similarity index 100%
rename from admin/tool/admin_presets/tests/fixtures/import_settings.xml
rename to adminpresets/tests/fixtures/import_settings.xml
diff --git a/admin/tool/admin_presets/tests/fixtures/import_settings_plugins.xml b/adminpresets/tests/fixtures/import_settings_plugins.xml
similarity index 100%
rename from admin/tool/admin_presets/tests/fixtures/import_settings_plugins.xml
rename to adminpresets/tests/fixtures/import_settings_plugins.xml
diff --git a/admin/tool/admin_presets/tests/fixtures/import_settings_with_unexisting_setting.xml b/adminpresets/tests/fixtures/import_settings_with_unexisting_setting.xml
similarity index 100%
rename from admin/tool/admin_presets/tests/fixtures/import_settings_with_unexisting_setting.xml
rename to adminpresets/tests/fixtures/import_settings_with_unexisting_setting.xml
diff --git a/admin/tool/admin_presets/tests/fixtures/import_starter_name.xml b/adminpresets/tests/fixtures/import_starter_name.xml
similarity index 100%
rename from admin/tool/admin_presets/tests/fixtures/import_starter_name.xml
rename to adminpresets/tests/fixtures/import_starter_name.xml
diff --git a/admin/tool/admin_presets/tests/fixtures/invalid_xml_file.xml b/adminpresets/tests/fixtures/invalid_xml_file.xml
similarity index 100%
rename from admin/tool/admin_presets/tests/fixtures/invalid_xml_file.xml
rename to adminpresets/tests/fixtures/invalid_xml_file.xml
diff --git a/admin/tool/admin_presets/tests/fixtures/unexisting_category.xml b/adminpresets/tests/fixtures/unexisting_category.xml
similarity index 100%
rename from admin/tool/admin_presets/tests/fixtures/unexisting_category.xml
rename to adminpresets/tests/fixtures/unexisting_category.xml
diff --git a/admin/tool/admin_presets/tests/fixtures/unexisting_setting.xml b/adminpresets/tests/fixtures/unexisting_setting.xml
similarity index 100%
rename from admin/tool/admin_presets/tests/fixtures/unexisting_setting.xml
rename to adminpresets/tests/fixtures/unexisting_setting.xml
diff --git a/adminpresets/tests/generator/lib.php b/adminpresets/tests/generator/lib.php
new file mode 100644
index 00000000000..41e514746a1
--- /dev/null
+++ b/adminpresets/tests/generator/lib.php
@@ -0,0 +1,245 @@
+.
+
+defined('MOODLE_INTERNAL') || die();
+
+use core_adminpresets\local\setting\adminpresets_setting;
+use core_adminpresets\manager;
+use core_adminpresets\helper;
+
+global $CFG;
+require_once($CFG->libdir . '/adminlib.php');
+
+/**
+ * Data generator for adminpresets component.
+ *
+ * @package core_adminpresets
+ * @category test
+ * @copyright 2021 Sara Arjona (sara@moodle.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class core_adminpresets_generator extends \component_generator_base {
+
+ /**
+ * Create a preset. This preset will have only 3 settings and 3 plugins.
+ * Settings:
+ * - none.enablebadges = 0
+ * - none.allowemojipicker = 1
+ * - mod_lesson.mediawidth = 900
+ * - mod_lesson.maxanswers = 2 with advanced disabled.
+ * Plugins:
+ * - enrol_guest = 0
+ * - mod_glossary = 0
+ * - qtype_truefalse = 1
+ *
+ * @param array $data Preset data. Supported values:
+ * - name. To define the preset name.
+ * - comments. To change the comments field.
+ * - author. To set the author.
+ * - applypreset. Whether the preset should be applied too or not.
+ * @return int Identifier of the preset created.
+ */
+ public function create_preset(array $data = []): int {
+ global $DB, $USER, $CFG;
+
+ if (!isset($data['name'])) {
+ $data['name'] = 'Preset default name';
+ }
+ if (!isset($data['comments'])) {
+ $data['comments'] = 'Preset default comment';
+ }
+ if (!isset($data['author'])) {
+ $data['author'] = 'Default author';
+ }
+
+ $preset = [
+ 'userid' => $USER->id,
+ 'name' => $data['name'],
+ 'comments' => $data['comments'],
+ 'site' => $CFG->wwwroot,
+ 'author' => $data['author'],
+ 'moodleversion' => $CFG->version,
+ 'moodlerelease' => $CFG->release,
+ 'timecreated' => time(),
+ 'timeimported' => 0,
+ ];
+
+ $presetid = $DB->insert_record('adminpresets', $preset);
+ $preset['id'] = $presetid;
+
+ // Setting: enablebadges = 0.
+ helper::add_item($presetid, 'enablebadges', '0');
+ // Setting: allowemojipicker = 1.
+ helper::add_item($presetid, 'allowemojipicker', '1');
+ // Setting: mediawidth = 900.
+ helper::add_item($presetid, 'mediawidth', '900', 'mod_lesson');
+ // Setting: maxanswers = 2 (with advanced disabled).
+ helper::add_item($presetid, 'maxanswers', '2', 'mod_lesson', 'maxanswers_adv', 0);
+
+ // Plugin: enrol_guest = 0.
+ helper::add_plugin($presetid, 'enrol', 'guest', 0);
+ // Plugin: mod_glossary = 0.
+ helper::add_plugin($presetid, 'mod', 'glossary', 0);
+ // Plugin: qtype_truefalse.
+ helper::add_plugin($presetid, 'qtype', 'truefalse', 1);
+
+ // Check if the preset should be created as applied preset too, to fill in the rest of the tables.
+ $applypreset = isset($data['applypreset']) && $data['applypreset'];
+ if ($applypreset) {
+ $presetapp = [
+ 'adminpresetid' => $presetid,
+ 'userid' => $USER->id,
+ 'time' => time(),
+ ];
+ $appid = $DB->insert_record('adminpresets_app', $presetapp);
+
+ $this->apply_setting($appid, 'enablebadges', '1', '0');
+ // The allowemojipicker setting shouldn't be applied because the value matches the current one.
+ $this->apply_setting($appid, 'mediawidth', '640', '900', 'mod_lesson');
+ $this->apply_setting($appid, 'maxanswers', '5', '2', 'mod_lesson');
+ $this->apply_setting($appid, 'maxanswers_adv', '1', '0', 'mod_lesson', 'maxanswers');
+
+ $this->apply_plugin($appid, 'enrol', 'guest', 1, 0);
+ $this->apply_plugin($appid, 'mod', 'glossary', 1, 0);
+ // The qtype_truefalse plugin shouldn't be applied because the value matches the current one.
+ }
+
+ return $presetid;
+ }
+
+ /**
+ * Helper method to create an applied setting item.
+ *
+ * @param int $appid The applied preset identifier.
+ * @param string $name The setting name.
+ * @param string $oldvalue The setting old value.
+ * @param string $newvalue The setting new value.
+ * @param string|null $plugin The setting plugin (or null if none).
+ * @param string|null $itemname Whether it should be treated as advanced item or not.
+ *
+ * @return bool|int true or new id.
+ */
+ private function apply_setting(int $appid, string $name, string $oldvalue, string $newvalue, ?string $plugin = null,
+ ?string $itemname = null) {
+ global $DB;
+
+ set_config($name, $newvalue, $plugin);
+ $configlogid = $this->add_to_config_log($name, $oldvalue, $newvalue, $plugin);
+ $presetappitem = [
+ 'adminpresetapplyid' => $appid,
+ 'configlogid' => $configlogid,
+ ];
+ $table = 'adminpresets_app_it';
+ if (!is_null($itemname)) {
+ $table = 'adminpresets_app_it_a';
+ $presetappitem['itemname'] = $itemname;
+ }
+ $appitemid = $DB->insert_record($table, $presetappitem);
+
+ return $appitemid;
+
+ }
+
+ /**
+ * Helper method to create an applied plugin.
+ *
+ * @param int $appid The applied preset identifier.
+ * @param string $plugin The plugin type.
+ * @param string $name The plugin name.
+ * @param int $oldvalue The setting old value.
+ * @param int $newvalue The setting new value.
+ *
+ * @return bool|int true or new id.
+ */
+ private function apply_plugin(int $appid, string $plugin, string $name, int $oldvalue, int $newvalue) {
+ global $DB;
+
+ // Change plugin visibility.
+ $pluginclass = \core_plugin_manager::resolve_plugininfo_class($plugin);
+ $pluginclass::enable_plugin($name, $newvalue);
+
+ // Create entry in applied plugins table.
+ $presetappplug = [
+ 'adminpresetapplyid' => $appid,
+ 'plugin' => $plugin,
+ 'name' => $name,
+ 'value' => $newvalue,
+ 'oldvalue' => $oldvalue,
+ ];
+ $appplugid = $DB->insert_record('adminpresets_app_plug', $presetappplug);
+
+ return $appplugid;
+ }
+
+ /**
+ * Helper method to add entry in config_log.
+ *
+ * @param string $name The setting name.
+ * @param string $oldvalue The setting old value.
+ * @param string $value The setting new value.
+ * @param string|null $plugin The setting plugin (or null if the setting doesn't belong to any plugin).
+ * @return int The id of the config_log entry created.
+ */
+ private function add_to_config_log(string $name, string $oldvalue, string $value, ?string $plugin = null): int {
+ global $DB, $USER;
+
+ $log = new stdClass();
+ $log->userid = $USER->id;
+ $log->timemodified = time();
+ $log->name = $name;
+ $log->oldvalue = $oldvalue;
+ $log->value = $value;
+ $log->plugin = $plugin;
+ $id = $DB->insert_record('config_log', $log);
+
+ return $id;
+ }
+
+ /**
+ * Helper method to access to a protected property.
+ *
+ * @param string|object $object The class.
+ * @param string $property The private/protected property in $object to access.
+ * @return mixed The current value of the property.
+ */
+ public function access_protected($object, string $property) {
+ $reflection = new ReflectionClass($object);
+ $property = $reflection->getProperty($property);
+ $property->setAccessible(true);
+ return $property->getValue($object);
+ }
+
+
+ /**
+ * Given a tree category and setting name, it gets the adminpresets_setting class.
+ *
+ * @param string $category Tree category name where the setting is located.
+ * @param string $settingname Setting name to get the class.
+ * @return adminpresets_setting
+ */
+ public function get_admin_preset_setting(string $category, string $settingname): adminpresets_setting {
+ $adminroot = admin_get_root();
+
+ // Set method accessibility.
+ $method = new ReflectionMethod(manager::class, 'get_setting');
+ $method->setAccessible(true);
+
+ // Get the proper adminpresets_setting instance.
+ $settingpage = $adminroot->locate($category);
+ $settingdata = $settingpage->settings->$settingname;
+ return $method->invokeArgs(new manager(), [$settingdata, '']);
+ }
+}
diff --git a/admin/tool/admin_presets/tests/generator_test.php b/adminpresets/tests/generator_test.php
similarity index 88%
rename from admin/tool/admin_presets/tests/generator_test.php
rename to adminpresets/tests/generator_test.php
index 110ceb294b6..ec8ccb8004e 100644
--- a/admin/tool/admin_presets/tests/generator_test.php
+++ b/adminpresets/tests/generator_test.php
@@ -14,16 +14,16 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets;
+namespace core_adminpresets;
/**
* Tests for the data generator.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @category test
* @copyright 2021 Sara Arjona (sara@moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @coversDefaultClass \tool_admin_presets_generator
+ * @coversDefaultClass core_adminpresets_generator
*/
class generator_test extends \advanced_testcase {
@@ -68,10 +68,10 @@ class generator_test extends \advanced_testcase {
}
// Create a preset.
- $presetid = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets')->create_preset($data);
+ $presetid = $this->getDataGenerator()->get_plugin_generator('core_adminpresets')->create_preset($data);
// Check the preset data.
- $preset = $DB->get_record('tool_admin_presets', ['id' => $presetid]);
+ $preset = $DB->get_record('adminpresets', ['id' => $presetid]);
$this->assertEquals($name, $preset->name);
$this->assertEquals($comments, $preset->comments);
@@ -81,7 +81,7 @@ class generator_test extends \advanced_testcase {
$this->assertEquals($CFG->wwwroot, $preset->site);
// Check the settings.
- $settings = $DB->get_records('tool_admin_presets_it', ['adminpresetid' => $presetid]);
+ $settings = $DB->get_records('adminpresets_it', ['adminpresetid' => $presetid]);
$this->assertCount(4, $settings);
// These are the settings created in the generator. Check the results match them.
$expectedsettings = [
@@ -98,14 +98,14 @@ class generator_test extends \advanced_testcase {
// Check the advanced settings (should be only one).
$settingsid = array_keys($settings);
list($insql, $inparams) = $DB->get_in_or_equal($settingsid);
- $advsettings = $DB->get_records_select('tool_admin_presets_it_a', 'itemid ' . $insql, $inparams);
+ $advsettings = $DB->get_records_select('adminpresets_it_a', 'itemid ' . $insql, $inparams);
$this->assertCount(1, $advsettings);
$advsetting = reset($advsettings);
$this->assertEquals('maxanswers_adv', $advsetting->name);
$this->assertEquals(0, $advsetting->value);
// Check the plugins.
- $plugins = $DB->get_records('tool_admin_presets_plug', ['adminpresetid' => $presetid]);
+ $plugins = $DB->get_records('adminpresets_plug', ['adminpresetid' => $presetid]);
$this->assertCount(3, $plugins);
// These are the plugins created in the generator. Check the results match them.
$expectedplugins = [
@@ -127,12 +127,12 @@ class generator_test extends \advanced_testcase {
if ($applypreset) {
// Verify that the preset has been applied.
- $apps = $DB->get_records('tool_admin_presets_app', ['adminpresetid' => $presetid]);
+ $apps = $DB->get_records('adminpresets_app', ['adminpresetid' => $presetid]);
$this->assertCount(1, $apps);
$app = reset($apps);
// Check the applied settings.
- $appsettings = $DB->get_records('tool_admin_presets_app_it', ['adminpresetapplyid' => $app->id]);
+ $appsettings = $DB->get_records('adminpresets_app_it', ['adminpresetapplyid' => $app->id]);
$this->assertCount(3, $appsettings);
// These are the settings created in the generator (all but the allowemojipicker because it hasn't changed).
$expectedappsettings = $expectedsettings;
@@ -144,7 +144,7 @@ class generator_test extends \advanced_testcase {
$this->assertEquals($expectedappsettings[$configlog->name], $configlog->value);
}
- $appsettings = $DB->get_records('tool_admin_presets_app_it_a', ['adminpresetapplyid' => $app->id]);
+ $appsettings = $DB->get_records('adminpresets_app_it_a', ['adminpresetapplyid' => $app->id]);
$this->assertCount(1, $appsettings);
$appsetting = reset($appsettings);
$configlog = $DB->get_record('config_log', ['id' => $appsetting->configlogid]);
@@ -152,7 +152,7 @@ class generator_test extends \advanced_testcase {
$this->assertEquals(0, $configlog->value);
// Check the applied plugins.
- $appplugins = $DB->get_records('tool_admin_presets_app_plug', ['adminpresetapplyid' => $app->id]);
+ $appplugins = $DB->get_records('adminpresets_app_plug', ['adminpresetapplyid' => $app->id]);
$this->assertCount(2, $appplugins);
// These are the plugins created in the generator (all but the qtype_truefalse because it hasn't changed).
$expectedappplugins = $expectedplugins;
diff --git a/admin/tool/admin_presets/tests/helper_test.php b/adminpresets/tests/helper_test.php
similarity index 90%
rename from admin/tool/admin_presets/tests/helper_test.php
rename to adminpresets/tests/helper_test.php
index e1ab519f5cb..81fc4500a9a 100644
--- a/admin/tool/admin_presets/tests/helper_test.php
+++ b/adminpresets/tests/helper_test.php
@@ -14,16 +14,16 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets;
+namespace core_adminpresets;
/**
* Tests for the helper class.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @category test
* @copyright 2021 Sara Arjona (sara@moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @coversDefaultClass \tool_admin_presets\helper
+ * @coversDefaultClass helper
*/
class helper_test extends \advanced_testcase {
@@ -53,7 +53,7 @@ class helper_test extends \advanced_testcase {
$presetid = helper::create_preset($data);
// Check the preset data.
- $preset = $DB->get_record('tool_admin_presets', ['id' => $presetid]);
+ $preset = $DB->get_record('adminpresets', ['id' => $presetid]);
$this->assertEquals($name, $preset->name);
$this->assertEquals($comments, $preset->comments);
@@ -63,9 +63,9 @@ class helper_test extends \advanced_testcase {
$this->assertEquals($CFG->wwwroot, $preset->site);
// Check the preset is empty and hasn't settings or plugins.
- $settings = $DB->get_records('tool_admin_presets_it', ['adminpresetid' => $presetid]);
+ $settings = $DB->get_records('adminpresets_it', ['adminpresetid' => $presetid]);
$this->assertCount(0, $settings);
- $plugins = $DB->get_records('tool_admin_presets_plug', ['adminpresetid' => $presetid]);
+ $plugins = $DB->get_records('adminpresets_plug', ['adminpresetid' => $presetid]);
$this->assertCount(0, $plugins);
}
@@ -112,13 +112,13 @@ class helper_test extends \advanced_testcase {
// Create a preset.
$presetid = helper::create_preset([]);
- $this->assertEquals(1, $DB->count_records('tool_admin_presets', ['id' => $presetid]));
+ $this->assertEquals(1, $DB->count_records('adminpresets', ['id' => $presetid]));
// Add items.
$itemid = helper::add_item($presetid, $name, $value, $plugin, $advname, $advvalue);
// Check settings have been created.
- $settings = $DB->get_records('tool_admin_presets_it', ['adminpresetid' => $presetid]);
+ $settings = $DB->get_records('adminpresets_it', ['adminpresetid' => $presetid]);
$this->assertCount(1, $settings);
$setting = reset($settings);
@@ -129,7 +129,7 @@ class helper_test extends \advanced_testcase {
if ($advname) {
// Check settings have been created.
- $advsettings = $DB->get_records('tool_admin_presets_it_a', ['itemid' => $itemid]);
+ $advsettings = $DB->get_records('adminpresets_it_a', ['itemid' => $itemid]);
$this->assertCount(1, $advsettings);
$advsetting = reset($advsettings);
@@ -137,11 +137,11 @@ class helper_test extends \advanced_testcase {
$this->assertEquals($advvalue, $advsetting->value);
} else {
// Check no advanced items have been created.
- $this->assertEquals(0, $DB->count_records('tool_admin_presets_it_a', ['itemid' => $itemid]));
+ $this->assertEquals(0, $DB->count_records('adminpresets_it_a', ['itemid' => $itemid]));
}
// Check no plugins have been created.
- $this->assertEquals(0, $DB->count_records('tool_admin_presets_plug', ['adminpresetid' => $presetid]));
+ $this->assertEquals(0, $DB->count_records('adminpresets_plug', ['adminpresetid' => $presetid]));
}
/**
@@ -187,13 +187,13 @@ class helper_test extends \advanced_testcase {
// Create a preset.
$presetid = helper::create_preset([]);
- $this->assertEquals(1, $DB->count_records('tool_admin_presets', ['id' => $presetid]));
+ $this->assertEquals(1, $DB->count_records('adminpresets', ['id' => $presetid]));
// Add plugin.
$pluginid = helper::add_plugin($presetid, $type, $name, $enabled);
// Check plugin has been created.
- $pluggins = $DB->get_records('tool_admin_presets_plug', ['adminpresetid' => $presetid]);
+ $pluggins = $DB->get_records('adminpresets_plug', ['adminpresetid' => $presetid]);
$this->assertCount(1, $pluggins);
$plugin = reset($pluggins);
@@ -203,7 +203,7 @@ class helper_test extends \advanced_testcase {
$this->assertEquals((int) $enabled, $plugin->enabled);
// Check no settings have been created.
- $this->assertEquals(0, $DB->count_records('tool_admin_presets_it', ['adminpresetid' => $presetid]));
+ $this->assertEquals(0, $DB->count_records('adminpresets_it', ['adminpresetid' => $presetid]));
}
/**
@@ -259,7 +259,7 @@ class helper_test extends \advanced_testcase {
// and plugins are the same.
set_config('enableanalytics', '0');
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$generator->create_preset(['name' => 'Preset 1']);
$presetid = helper::change_default_preset($preset);
diff --git a/admin/tool/admin_presets/tests/local/setting/admin_preset_admin_setting_bloglevel_test.php b/adminpresets/tests/local/setting/adminpresets_admin_setting_bloglevel_test.php
similarity index 89%
rename from admin/tool/admin_presets/tests/local/setting/admin_preset_admin_setting_bloglevel_test.php
rename to adminpresets/tests/local/setting/adminpresets_admin_setting_bloglevel_test.php
index 08f6ee65fff..d59108abbc5 100644
--- a/admin/tool/admin_presets/tests/local/setting/admin_preset_admin_setting_bloglevel_test.php
+++ b/adminpresets/tests/local/setting/adminpresets_admin_setting_bloglevel_test.php
@@ -14,18 +14,18 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
/**
- * Tests for the admin_preset_admin_setting_bloglevel class.
+ * Tests for the adminpresets_admin_setting_bloglevel class.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @category test
* @copyright 2021 Sara Arjona (sara@moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @coversDefaultClass \tool_admin_presets\local\setting\admin_preset_admin_setting_bloglevel
+ * @coversDefaultClass \core_adminpresets\local\setting\adminpresets_admin_setting_bloglevel
*/
-class admin_preset_admin_setting_bloglevel_test extends \advanced_testcase {
+class adminpresets_admin_setting_bloglevel_test extends \advanced_testcase {
/**
* Test the behaviour of save_value() method.
@@ -48,14 +48,14 @@ class admin_preset_admin_setting_bloglevel_test extends \advanced_testcase {
set_config('bloglevel', BLOG_SITE_LEVEL); // All site users can see all blog entries.
// Get the setting and save the value.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$setting = $generator->get_admin_preset_setting('blog', 'bloglevel');
$result = $setting->save_value(false, $settingvalue);
// Check the result is the expected (saved when it has a different value and ignored when the value is the same).
if ($expectedsaved) {
$this->assertCount(1, $DB->get_records('config_log', ['id' => $result]));
- // Specific from the save_value in admin_preset_admin_setting_bloglevel.
+ // Specific from the save_value in adminpresets_admin_setting_bloglevel.
if ($settingvalue != 0) {
$this->assertTrue((bool) $DB->get_field('block', 'visible', ['name' => 'blog_menu']));
} else {
diff --git a/admin/tool/admin_presets/tests/local/setting/admin_preset_admin_setting_sitesettext_test.php b/adminpresets/tests/local/setting/adminpresets_admin_setting_sitesettext_test.php
similarity index 88%
rename from admin/tool/admin_presets/tests/local/setting/admin_preset_admin_setting_sitesettext_test.php
rename to adminpresets/tests/local/setting/adminpresets_admin_setting_sitesettext_test.php
index ad9213f8d33..3ae332154fa 100644
--- a/admin/tool/admin_presets/tests/local/setting/admin_preset_admin_setting_sitesettext_test.php
+++ b/adminpresets/tests/local/setting/adminpresets_admin_setting_sitesettext_test.php
@@ -14,18 +14,18 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
/**
- * Tests for the admin_preset_admin_setting_sitesettext class.
+ * Tests for the adminpresets_admin_setting_sitesettext class.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @category test
* @copyright 2021 Sara Arjona (sara@moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @coversDefaultClass \tool_admin_presets\local\setting\admin_preset_admin_setting_sitesettext
+ * @coversDefaultClass \core_adminpresets\local\setting\adminpresets_admin_setting_sitesettext
*/
-class admin_preset_admin_setting_sitesettext_test extends \advanced_testcase {
+class adminpresets_admin_setting_sitesettext_test extends \advanced_testcase {
/**
* Test the behaviour of save_value() method.
@@ -46,14 +46,14 @@ class admin_preset_admin_setting_sitesettext_test extends \advanced_testcase {
$this->setAdminUser();
// Get the setting and save the value.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$setting = $generator->get_admin_preset_setting('frontpagesettings', $settingname);
$result = $setting->save_value(false, $settingvalue);
// Check the result is the expected (saved when it has a different value and ignored when the value is the same).
if ($expectedsaved) {
$this->assertCount(1, $DB->get_records('config_log', ['id' => $result]));
- // Specific from the save_value in admin_preset_admin_setting_sitesettext.
+ // Specific from the save_value in adminpresets_admin_setting_sitesettext.
$sitecourse = $DB->get_record('course', ['id' => 1]);
$this->assertEquals($settingvalue, $sitecourse->{$settingname});
} else {
diff --git a/admin/tool/admin_presets/tests/local/setting/admin_preset_setting_test.php b/adminpresets/tests/local/setting/adminpresets_setting_test.php
similarity index 95%
rename from admin/tool/admin_presets/tests/local/setting/admin_preset_setting_test.php
rename to adminpresets/tests/local/setting/adminpresets_setting_test.php
index c46592e5463..3cd81ed5d54 100644
--- a/admin/tool/admin_presets/tests/local/setting/admin_preset_setting_test.php
+++ b/adminpresets/tests/local/setting/adminpresets_setting_test.php
@@ -14,18 +14,18 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\local\setting;
+namespace core_adminpresets\local\setting;
/**
- * Tests for the admin_preset_setting class.
+ * Tests for the adminpresets_setting class.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @category test
* @copyright 2021 Sara Arjona (sara@moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @coversDefaultClass \tool_admin_presets\local\setting\admin_preset_setting
+ * @coversDefaultClass \core_adminpresets\local\setting\adminpresets_setting
*/
-class admin_preset_setting_test extends \advanced_testcase {
+class adminpresets_setting_test extends \advanced_testcase {
/**
* Test the behaviour of save_value() method.
@@ -59,7 +59,7 @@ class admin_preset_setting_test extends \advanced_testcase {
$name = $settingname;
}
// Get the setting and save the value.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$setting = $generator->get_admin_preset_setting($category, $name);
$result = $setting->save_value(false, $settingvalue);
@@ -142,7 +142,7 @@ class admin_preset_setting_test extends \advanced_testcase {
$name = $settingname;
}
// Get the setting and save the value.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$setting = $generator->get_admin_preset_setting($category, $name);
if ($advsettingname) {
$setting->set_attribute_value($advsettingname, $advsettingvalue);
diff --git a/admin/tool/admin_presets/tests/manager_test.php b/adminpresets/tests/manager_test.php
similarity index 78%
rename from admin/tool/admin_presets/tests/manager_test.php
rename to adminpresets/tests/manager_test.php
index c60e89fc32a..d5040f76d76 100644
--- a/admin/tool/admin_presets/tests/manager_test.php
+++ b/adminpresets/tests/manager_test.php
@@ -14,18 +14,18 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets;
+namespace core_adminpresets;
use stdClass;
/**
* Tests for the manager class.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @category test
* @copyright 2021 Sara Arjona (sara@moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @coversDefaultClass \tool_admin_presets\manager
+ * @coversDefaultClass \core_adminpresets\manager
*/
class manager_test extends \advanced_testcase {
/**
@@ -47,21 +47,21 @@ class manager_test extends \advanced_testcase {
// Check fullname is set into the none category.
$this->assertInstanceOf(
- '\tool_admin_presets\local\setting\admin_preset_admin_setting_sitesettext',
+ '\core_adminpresets\local\setting\adminpresets_admin_setting_sitesettext',
$result['none']['fullname']
);
$this->assertEquals('PHPUnit test site', $result['none']['fullname']->get_value());
// Check some of the config setting is present (they should be stored in the "none" category).
$this->assertInstanceOf(
- '\tool_admin_presets\local\setting\admin_preset_admin_setting_configcheckbox',
+ '\core_adminpresets\local\setting\adminpresets_admin_setting_configcheckbox',
$result['none']['enablecompletion']
);
$this->assertEquals(1, $result['none']['enablecompletion']->get_value());
// Check some of the plugin config settings is present.
$this->assertInstanceOf(
- '\tool_admin_presets\local\setting\admin_preset_admin_setting_configtext',
+ '\core_adminpresets\local\setting\adminpresets_admin_setting_configtext',
$result['folder']['maxsizetodownload']
);
$this->assertEquals(0, $result['folder']['maxsizetodownload']->get_value());
@@ -79,19 +79,19 @@ class manager_test extends \advanced_testcase {
$result = $manager->get_site_settings();
// Site fullname.
$this->assertInstanceOf(
- '\tool_admin_presets\local\setting\admin_preset_admin_setting_sitesettext',
+ '\core_adminpresets\local\setting\adminpresets_admin_setting_sitesettext',
$result['none']['fullname']
);
$this->assertEquals($sitecourse->fullname, $result['none']['fullname']->get_value());
// Config setting.
$this->assertInstanceOf(
- '\tool_admin_presets\local\setting\admin_preset_admin_setting_configcheckbox',
+ '\core_adminpresets\local\setting\adminpresets_admin_setting_configcheckbox',
$result['none']['enablecompletion']
);
$this->assertEquals(0, $result['none']['enablecompletion']->get_value());
// Plugin config settting.
$this->assertInstanceOf(
- '\tool_admin_presets\local\setting\admin_preset_admin_setting_configtext',
+ '\core_adminpresets\local\setting\adminpresets_admin_setting_configtext',
$result['folder']['maxsizetodownload']
);
$this->assertEquals(101, $result['folder']['maxsizetodownload']->get_value());
@@ -111,21 +111,21 @@ class manager_test extends \advanced_testcase {
$adminroot = admin_get_root();
- // Check the admin_preset_xxxxx class is created properly when it exists.
+ // Check the adminpresets_xxxxx class is created properly when it exists.
$settingpage = $adminroot->locate('optionalsubsystems');
$settingdata = $settingpage->settings->enablebadges;
$manager = new manager();
$result = $manager->get_setting($settingdata, '');
- $this->assertInstanceOf('\tool_admin_presets\local\setting\admin_preset_admin_setting_configcheckbox', $result);
- $this->assertNotEquals('tool_admin_presets\local\setting\admin_preset_setting', get_class($result));
+ $this->assertInstanceOf('\core_adminpresets\local\setting\adminpresets_admin_setting_configcheckbox', $result);
+ $this->assertNotEquals('core_adminpresets\local\setting\adminpresets_setting', get_class($result));
// Check the mapped class is returned when no specific class exists and it exists in the mappings array.
$settingpage = $adminroot->locate('h5psettings');
$settingdata = $settingpage->settings->h5plibraryhandler;;
$result = $manager->get_setting($settingdata, '');
- $this->assertInstanceOf('\tool_admin_presets\local\setting\admin_preset_admin_setting_configselect', $result);
+ $this->assertInstanceOf('\core_adminpresets\local\setting\adminpresets_admin_setting_configselect', $result);
$this->assertNotEquals(
- 'tool_admin_presets\local\setting\admin_preset_admin_settings_h5plib_handler_select',
+ 'core_adminpresets\local\setting\adminpresets_admin_settings_h5plib_handler_select',
get_class($result)
);
@@ -133,15 +133,15 @@ class manager_test extends \advanced_testcase {
$settingpage = $adminroot->locate('modsettingquiz');
$settingdata = $settingpage->settings->quizbrowsersecurity;;
$result = $manager->get_setting($settingdata, '');
- $this->assertInstanceOf('\mod_quiz\local\setting\admin_preset_mod_quiz_admin_setting_browsersecurity', $result);
- $this->assertNotEquals('tool_admin_presets\local\setting\admin_preset_setting', get_class($result));
+ $this->assertInstanceOf('\mod_quiz\adminpresets\adminpresets_mod_quiz_admin_setting_browsersecurity', $result);
+ $this->assertNotEquals('core_adminpresets\local\setting\adminpresets_setting', get_class($result));
- // Check the admin_preset_setting class is returned when no specific class exists.
+ // Check the adminpresets_setting class is returned when no specific class exists.
$settingpage = $adminroot->locate('managecustomfields');
$settingdata = $settingpage->settings->customfieldsui;;
$result = $manager->get_setting($settingdata, '');
- $this->assertInstanceOf('\tool_admin_presets\local\setting\admin_preset_setting', $result);
- $this->assertEquals('tool_admin_presets\local\setting\admin_preset_setting', get_class($result));
+ $this->assertInstanceOf('\core_adminpresets\local\setting\adminpresets_setting', $result);
+ $this->assertEquals('core_adminpresets\local\setting\adminpresets_setting', get_class($result));
}
/**
@@ -154,7 +154,7 @@ class manager_test extends \advanced_testcase {
$this->setAdminUser();
// Create some presets.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset();
// Unexisting preset identifier.
@@ -177,17 +177,17 @@ class manager_test extends \advanced_testcase {
$this->setAdminUser();
// Create a preset.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset();
- $currentpresets = $DB->count_records('tool_admin_presets');
- $currentitems = $DB->count_records('tool_admin_presets_it');
- $currentadvitems = $DB->count_records('tool_admin_presets_it_a');
- $currentplugins = $DB->count_records('tool_admin_presets_plug');
- $currentapppresets = $DB->count_records('tool_admin_presets_app');
- $currentappitems = $DB->count_records('tool_admin_presets_app_it');
- $currentappadvitems = $DB->count_records('tool_admin_presets_app_it_a');
- $currentappplugins = $DB->count_records('tool_admin_presets_app_plug');
+ $currentpresets = $DB->count_records('adminpresets');
+ $currentitems = $DB->count_records('adminpresets_it');
+ $currentadvitems = $DB->count_records('adminpresets_it_a');
+ $currentplugins = $DB->count_records('adminpresets_plug');
+ $currentapppresets = $DB->count_records('adminpresets_app');
+ $currentappitems = $DB->count_records('adminpresets_app_it');
+ $currentappadvitems = $DB->count_records('adminpresets_app_it_a');
+ $currentappplugins = $DB->count_records('adminpresets_app_plug');
// Set the config values (to confirm they change after applying the preset).
set_config('enablebadges', 1);
@@ -203,18 +203,18 @@ class manager_test extends \advanced_testcase {
$manager->apply_preset($presetid);
// Check the preset applied has been added to database.
- $this->assertCount($currentapppresets + 1, $DB->get_records('tool_admin_presets_app'));
+ $this->assertCount($currentapppresets + 1, $DB->get_records('adminpresets_app'));
// Applied items: enablebadges@none, mediawitdh@mod_lesson and maxanswers@@mod_lesson.
- $this->assertCount($currentappitems + 3, $DB->get_records('tool_admin_presets_app_it'));
+ $this->assertCount($currentappitems + 3, $DB->get_records('adminpresets_app_it'));
// Applied advanced items: maxanswers_adv@mod_lesson.
- $this->assertCount($currentappadvitems + 1, $DB->get_records('tool_admin_presets_app_it_a'));
+ $this->assertCount($currentappadvitems + 1, $DB->get_records('adminpresets_app_it_a'));
// Applied plugins: enrol_guest and mod_glossary.
- $this->assertCount($currentappplugins + 2, $DB->get_records('tool_admin_presets_app_plug'));
+ $this->assertCount($currentappplugins + 2, $DB->get_records('adminpresets_app_plug'));
// Check no new preset has been created.
- $this->assertCount($currentpresets, $DB->get_records('tool_admin_presets'));
- $this->assertCount($currentitems, $DB->get_records('tool_admin_presets_it'));
- $this->assertCount($currentadvitems, $DB->get_records('tool_admin_presets_it_a'));
- $this->assertCount($currentplugins, $DB->get_records('tool_admin_presets_plug'));
+ $this->assertCount($currentpresets, $DB->get_records('adminpresets'));
+ $this->assertCount($currentitems, $DB->get_records('adminpresets_it'));
+ $this->assertCount($currentadvitems, $DB->get_records('adminpresets_it_a'));
+ $this->assertCount($currentplugins, $DB->get_records('adminpresets_plug'));
// Check the setting values have changed accordingly with the ones defined in the preset.
$this->assertEquals(0, get_config('core', 'enablebadges'));
@@ -238,12 +238,12 @@ class manager_test extends \advanced_testcase {
$this->assertArrayHasKey('truefalse', $enabledplugins);
// Check the presetid has been also stored in the lastpresetapplied config setting.
- $this->assertEquals($presetid, get_config('tool_admin_presets', 'lastpresetapplied'));
+ $this->assertEquals($presetid, get_config('adminpresets', 'lastpresetapplied'));
// Call apply_preset as a simulation, so it shouldn't be applied and lastpresetapplied should still be $presetid.
$presetid2 = $generator->create_preset();
$manager->apply_preset($presetid2, true);
- $this->assertEquals($presetid, get_config('tool_admin_presets', 'lastpresetapplied'));
+ $this->assertEquals($presetid, get_config('adminpresets', 'lastpresetapplied'));
}
@@ -263,8 +263,8 @@ class manager_test extends \advanced_testcase {
$this->setAdminUser();
// Get current presets and items.
- $currentpresets = $DB->count_records('tool_admin_presets');
- $currentadvitems = $DB->count_records('tool_admin_presets_it_a');
+ $currentpresets = $DB->count_records('adminpresets');
+ $currentadvitems = $DB->count_records('adminpresets_it_a');
// Initialise some settings (to compare their values have been exported as expected).
set_config('recaptchapublickey', 'abcde');
@@ -288,7 +288,7 @@ class manager_test extends \advanced_testcase {
list($presetid, $settingsfound, $pluginsfound) = $manager->export_preset((object) $data);
// Check the preset record has been created.
- $presets = $DB->get_records('tool_admin_presets');
+ $presets = $DB->get_records('adminpresets');
$this->assertCount($currentpresets + 1, $presets);
$this->assertArrayHasKey($presetid, $presets);
$preset = $presets[$presetid];
@@ -300,31 +300,31 @@ class manager_test extends \advanced_testcase {
$this->assertTrue($pluginsfound);
// Check the items, advanced attributes and plugins have been created.
- $this->assertGreaterThan(0, $DB->count_records('tool_admin_presets_it', ['adminpresetid' => $presetid]));
- $this->assertGreaterThan($currentadvitems, $DB->count_records('tool_admin_presets_it_a'));
- $this->assertGreaterThan(0, $DB->count_records('tool_admin_presets_plug', ['adminpresetid' => $presetid]));
+ $this->assertGreaterThan(0, $DB->count_records('adminpresets_it', ['adminpresetid' => $presetid]));
+ $this->assertGreaterThan($currentadvitems, $DB->count_records('adminpresets_it_a'));
+ $this->assertGreaterThan(0, $DB->count_records('adminpresets_plug', ['adminpresetid' => $presetid]));
// Check settings have been created with the expected values.
$params = ['adminpresetid' => $presetid, 'plugin' => 'none', 'name' => 'enablebadges'];
- $setting = $DB->get_record('tool_admin_presets_it', $params);
+ $setting = $DB->get_record('adminpresets_it', $params);
$this->assertEquals('0', $setting->value);
$params = ['adminpresetid' => $presetid, 'plugin' => 'mod_lesson', 'name' => 'mediawidth'];
- $setting = $DB->get_record('tool_admin_presets_it', $params);
+ $setting = $DB->get_record('adminpresets_it', $params);
$this->assertEquals('900', $setting->value);
$params = ['adminpresetid' => $presetid, 'plugin' => 'mod_lesson', 'name' => 'maxanswers'];
- $setting = $DB->get_record('tool_admin_presets_it', $params);
+ $setting = $DB->get_record('adminpresets_it', $params);
$this->assertEquals('2', $setting->value);
$params = ['itemid' => $setting->id, 'name' => 'maxanswers_adv'];
- $setting = $DB->get_record('tool_admin_presets_it_a', $params);
+ $setting = $DB->get_record('adminpresets_it_a', $params);
$this->assertEquals('0', $setting->value);
$params = ['adminpresetid' => $presetid, 'plugin' => 'mod_lesson', 'name' => 'defaultfeedback'];
- $setting = $DB->get_record('tool_admin_presets_it', $params);
+ $setting = $DB->get_record('adminpresets_it', $params);
$this->assertEquals('0', $setting->value);
$params = ['itemid' => $setting->id, 'name' => 'defaultfeedback_adv'];
- $setting = $DB->get_record('tool_admin_presets_it_a', $params);
+ $setting = $DB->get_record('adminpresets_it_a', $params);
$this->assertEquals('1', $setting->value);
// Check plugins have been created with the expected values.
@@ -334,16 +334,16 @@ class manager_test extends \advanced_testcase {
$enabledplugins = $manager->get_enabled_plugins($plugintype);
foreach ($plugins as $pluginname => $unused) {
$params = ['adminpresetid' => $presetid, 'plugin' => $plugintype, 'name' => $pluginname];
- $plugin = $DB->get_record('tool_admin_presets_plug', $params);
+ $plugin = $DB->get_record('adminpresets_plug', $params);
$enabled = (!empty($enabledplugins) && array_key_exists($pluginname, $enabledplugins));
$this->assertEquals($enabled, (bool) $plugin->enabled);
}
// Check whether sensible settings have been exported or not.
$params = ['adminpresetid' => $presetid, 'plugin' => 'none', 'name' => 'recaptchapublickey'];
- $recaptchasetting = $DB->get_record('tool_admin_presets_it', $params);
+ $recaptchasetting = $DB->get_record('adminpresets_it', $params);
$params = ['adminpresetid' => $presetid, 'plugin' => 'none', 'name' => 'cronremotepassword'];
- $cronsetting = $DB->get_record('tool_admin_presets_it', $params);
+ $cronsetting = $DB->get_record('adminpresets_it', $params);
if ($includesensible) {
$this->assertEquals('abcde', $recaptchasetting->value);
$this->assertNotFalse($cronsetting);
@@ -387,7 +387,7 @@ class manager_test extends \advanced_testcase {
$this->setAdminUser();
// Create some presets.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset();
// Unexisting preset identifier.
@@ -421,9 +421,9 @@ class manager_test extends \advanced_testcase {
$this->resetAfterTest();
$this->setAdminUser();
- $currentpresets = $DB->count_records('tool_admin_presets');
- $currentitems = $DB->count_records('tool_admin_presets_it');
- $currentadvitems = $DB->count_records('tool_admin_presets_it_a');
+ $currentpresets = $DB->count_records('adminpresets');
+ $currentitems = $DB->count_records('adminpresets_it');
+ $currentadvitems = $DB->count_records('adminpresets_it_a');
// Call the method to be tested.
$manager = new manager();
@@ -440,9 +440,9 @@ class manager_test extends \advanced_testcase {
if ($expectedpreset) {
// Check the preset record has been created.
- $presets = $DB->get_records('tool_admin_presets');
+ $presets = $DB->get_records('adminpresets');
$this->assertCount($currentpresets + 1, $presets);
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$this->assertArrayHasKey($preset->id, $presets);
$preset = $presets[$preset->id];
$this->assertEquals($expectedpresetname, $preset->name);
@@ -452,7 +452,7 @@ class manager_test extends \advanced_testcase {
if ($expectedsettings) {
// Check the items have been created.
- $items = $DB->get_records('tool_admin_presets_it', ['adminpresetid' => $preset->id]);
+ $items = $DB->get_records('adminpresets_it', ['adminpresetid' => $preset->id]);
$this->assertCount(4, $items);
$presetitems = [
'none' => [
@@ -471,7 +471,7 @@ class manager_test extends \advanced_testcase {
}
// Check the advanced attributes have been created.
- $advitems = $DB->get_records('tool_admin_presets_it_a');
+ $advitems = $DB->get_records('adminpresets_it_a');
$this->assertCount($currentadvitems + 1, $advitems);
$advitemfound = false;
foreach ($advitems as $advitem) {
@@ -485,7 +485,7 @@ class manager_test extends \advanced_testcase {
if ($expectedplugins) {
// Check the plugins have been created.
- $plugins = $DB->get_records('tool_admin_presets_plug', ['adminpresetid' => $preset->id]);
+ $plugins = $DB->get_records('adminpresets_plug', ['adminpresetid' => $preset->id]);
$this->assertCount(6, $plugins);
$presetplugins = [
'atto' => [
@@ -509,9 +509,9 @@ class manager_test extends \advanced_testcase {
}
} else {
// Check the preset nor the items are not created.
- $this->assertCount($currentpresets, $DB->get_records('tool_admin_presets'));
- $this->assertCount($currentitems, $DB->get_records('tool_admin_presets_it'));
- $this->assertCount($currentadvitems, $DB->get_records('tool_admin_presets_it_a'));
+ $this->assertCount($currentpresets, $DB->get_records('adminpresets'));
+ $this->assertCount($currentitems, $DB->get_records('adminpresets_it'));
+ $this->assertCount($currentadvitems, $DB->get_records('adminpresets_it_a'));
}
}
}
@@ -591,7 +591,7 @@ class manager_test extends \advanced_testcase {
$this->setAdminUser();
// Create some presets.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset(['name' => 'Preset 1']);
// Unexisting preset identifier.
@@ -615,46 +615,46 @@ class manager_test extends \advanced_testcase {
$this->setAdminUser();
// Create some presets.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid1 = $generator->create_preset(['name' => 'Preset 1', 'applypreset' => true]);
$presetid2 = $generator->create_preset(['name' => 'Preset 2']);
- $currentpresets = $DB->count_records('tool_admin_presets');
- $currentitems = $DB->count_records('tool_admin_presets_it');
- $currentadvitems = $DB->count_records('tool_admin_presets_it_a');
- $currentplugins = $DB->count_records('tool_admin_presets_plug');
+ $currentpresets = $DB->count_records('adminpresets');
+ $currentitems = $DB->count_records('adminpresets_it');
+ $currentadvitems = $DB->count_records('adminpresets_it_a');
+ $currentplugins = $DB->count_records('adminpresets_plug');
// Only preset1 has been applied.
- $this->assertCount(1, $DB->get_records('tool_admin_presets_app'));
+ $this->assertCount(1, $DB->get_records('adminpresets_app'));
// Only the preset1 settings that have changed: enablebadges, mediawidth and maxanswers.
- $this->assertCount(3, $DB->get_records('tool_admin_presets_app_it'));
+ $this->assertCount(3, $DB->get_records('adminpresets_app_it'));
// Only the preset1 advanced settings that have changed: maxanswers_adv.
- $this->assertCount(1, $DB->get_records('tool_admin_presets_app_it_a'));
+ $this->assertCount(1, $DB->get_records('adminpresets_app_it_a'));
// Only the preset1 plugins that have changed: enrol_guest and mod_glossary.
- $this->assertCount(2, $DB->get_records('tool_admin_presets_app_plug'));
+ $this->assertCount(2, $DB->get_records('adminpresets_app_plug'));
// Call the method to be tested.
$manager = new manager();
$manager->delete_preset($presetid1);
// Check the preset data has been removed.
- $presets = $DB->get_records('tool_admin_presets');
+ $presets = $DB->get_records('adminpresets');
$this->assertCount($currentpresets - 1, $presets);
$preset = reset($presets);
$this->assertArrayHasKey($presetid2, $presets);
// Check preset items.
- $this->assertCount($currentitems - 4, $DB->get_records('tool_admin_presets_it'));
- $this->assertCount(0, $DB->get_records('tool_admin_presets_it', ['adminpresetid' => $presetid1]));
+ $this->assertCount($currentitems - 4, $DB->get_records('adminpresets_it'));
+ $this->assertCount(0, $DB->get_records('adminpresets_it', ['adminpresetid' => $presetid1]));
// Check preset advanced items.
- $this->assertCount($currentadvitems - 1, $DB->get_records('tool_admin_presets_it_a'));
+ $this->assertCount($currentadvitems - 1, $DB->get_records('adminpresets_it_a'));
// Check preset plugins.
- $this->assertCount($currentplugins - 3, $DB->get_records('tool_admin_presets_plug'));
- $this->assertCount(0, $DB->get_records('tool_admin_presets_plug', ['adminpresetid' => $presetid1]));
+ $this->assertCount($currentplugins - 3, $DB->get_records('adminpresets_plug'));
+ $this->assertCount(0, $DB->get_records('adminpresets_plug', ['adminpresetid' => $presetid1]));
// Check preset applied tables are empty now.
- $this->assertCount(0, $DB->get_records('tool_admin_presets_app'));
- $this->assertCount(0, $DB->get_records('tool_admin_presets_app_it'));
- $this->assertCount(0, $DB->get_records('tool_admin_presets_app_it_a'));
- $this->assertCount(0, $DB->get_records('tool_admin_presets_app_plug'));
+ $this->assertCount(0, $DB->get_records('adminpresets_app'));
+ $this->assertCount(0, $DB->get_records('adminpresets_app_it'));
+ $this->assertCount(0, $DB->get_records('adminpresets_app_it_a'));
+ $this->assertCount(0, $DB->get_records('adminpresets_app_plug'));
}
/**
@@ -669,9 +669,9 @@ class manager_test extends \advanced_testcase {
$this->setAdminUser();
// Create a preset and apply it.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset(['applypreset' => true]);
- $presetappid = $DB->get_field('tool_admin_presets_app', 'id', ['adminpresetid' => $presetid]);
+ $presetappid = $DB->get_field('adminpresets_app', 'id', ['adminpresetid' => $presetid]);
// Unexisting applied preset identifier.
$unexistingid = $presetappid * 2;
@@ -702,18 +702,18 @@ class manager_test extends \advanced_testcase {
set_config('usecomments', 0);
// Create a preset and apply it.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$presetid = $generator->create_preset(['applypreset' => true]);
- $presetappid = $DB->get_field('tool_admin_presets_app', 'id', ['adminpresetid' => $presetid]);
+ $presetappid = $DB->get_field('adminpresets_app', 'id', ['adminpresetid' => $presetid]);
- $currentpresets = $DB->count_records('tool_admin_presets');
- $currentitems = $DB->count_records('tool_admin_presets_it');
- $currentadvitems = $DB->count_records('tool_admin_presets_it_a');
- $currentplugins = $DB->count_records('tool_admin_presets_plug');
- $this->assertCount(1, $DB->get_records('tool_admin_presets_app'));
- $this->assertCount(3, $DB->get_records('tool_admin_presets_app_it'));
- $this->assertCount(1, $DB->get_records('tool_admin_presets_app_it_a'));
- $this->assertCount(2, $DB->get_records('tool_admin_presets_app_plug'));
+ $currentpresets = $DB->count_records('adminpresets');
+ $currentitems = $DB->count_records('adminpresets_it');
+ $currentadvitems = $DB->count_records('adminpresets_it_a');
+ $currentplugins = $DB->count_records('adminpresets_plug');
+ $this->assertCount(1, $DB->get_records('adminpresets_app'));
+ $this->assertCount(3, $DB->get_records('adminpresets_app_it'));
+ $this->assertCount(1, $DB->get_records('adminpresets_app_it_a'));
+ $this->assertCount(2, $DB->get_records('adminpresets_app_plug'));
// Check the setttings have changed accordingly after applying the preset.
$this->assertEquals(0, get_config('core', 'enablebadges'));
@@ -739,15 +739,15 @@ class manager_test extends \advanced_testcase {
$this->assertNotEmpty($presetapp);
$this->assertNotEmpty($rollback);
$this->assertEmpty($failures);
- $this->assertCount(0, $DB->get_records('tool_admin_presets_app'));
- $this->assertCount(0, $DB->get_records('tool_admin_presets_app_it'));
- $this->assertCount(0, $DB->get_records('tool_admin_presets_app_it_a'));
- $this->assertCount(0, $DB->get_records('tool_admin_presets_app_plug'));
+ $this->assertCount(0, $DB->get_records('adminpresets_app'));
+ $this->assertCount(0, $DB->get_records('adminpresets_app_it'));
+ $this->assertCount(0, $DB->get_records('adminpresets_app_it_a'));
+ $this->assertCount(0, $DB->get_records('adminpresets_app_plug'));
// Check the preset data hasn't changed.
- $this->assertCount($currentpresets, $DB->get_records('tool_admin_presets'));
- $this->assertCount($currentitems, $DB->get_records('tool_admin_presets_it'));
- $this->assertCount($currentadvitems, $DB->get_records('tool_admin_presets_it_a'));
- $this->assertCount($currentplugins, $DB->get_records('tool_admin_presets_plug'));
+ $this->assertCount($currentpresets, $DB->get_records('adminpresets'));
+ $this->assertCount($currentitems, $DB->get_records('adminpresets_it'));
+ $this->assertCount($currentadvitems, $DB->get_records('adminpresets_it_a'));
+ $this->assertCount($currentplugins, $DB->get_records('adminpresets_plug'));
// Check the setting values have been reverted accordingly.
$this->assertEquals(1, get_config('core', 'enablebadges'));
diff --git a/admin/tool/admin_presets/tests/privacy/provider_test.php b/adminpresets/tests/privacy/privacy_provider_test.php
similarity index 84%
rename from admin/tool/admin_presets/tests/privacy/provider_test.php
rename to adminpresets/tests/privacy/privacy_provider_test.php
index 3a11ab9301a..fb2bfbdc9c0 100644
--- a/admin/tool/admin_presets/tests/privacy/provider_test.php
+++ b/adminpresets/tests/privacy/privacy_provider_test.php
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace tool_admin_presets\privacy;
+namespace core_adminpresets\privacy;
use context_system;
use context_user;
@@ -24,20 +24,20 @@ use core_privacy\tests\provider_testcase;
/**
* Tests for the privacy provider class.
*
- * @package tool_admin_presets
+ * @package core_adminpresets
* @category test
* @copyright 2021 Sara Arjona (sara@moodle.com)
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
- * @coversDefaultClass \tool_admin_presets\privacy\provider
+ * @coversDefaultClass \core_adminpresets\privacy\provider
*/
-class provider_test extends provider_testcase {
+class privacy_provider_test extends provider_testcase {
/**
* Test for provider::get_metadata().
* @covers ::get_metadata
*/
public function test_get_metadata() {
- $collection = new collection('tool_admin_presets');
+ $collection = new collection('core_adminpresets');
$newcollection = provider::get_metadata($collection);
$itemcollection = $newcollection->get_collection();
$this->assertCount(2, $itemcollection);
@@ -56,7 +56,7 @@ class provider_test extends provider_testcase {
$this->setAdminUser();
// Create a preset.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$generator->create_preset();
$contextlist = provider::get_contexts_for_userid($USER->id);
@@ -74,11 +74,11 @@ class provider_test extends provider_testcase {
$this->setAdminUser();
// Create a preset.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$generator->create_preset();
$usercontext = context_user::instance($USER->id);
- $userlist = new \core_privacy\local\request\userlist($usercontext, 'tool_admin_presets');
+ $userlist = new \core_privacy\local\request\userlist($usercontext, 'core_adminpresets');
\core_message\privacy\provider::get_users_in_context($userlist);
$this->assertEmpty($userlist->get_userids());
}
@@ -95,24 +95,24 @@ class provider_test extends provider_testcase {
$this->setAdminUser();
// Create a preset.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$generator->create_preset();
// Check data is not exported in user context.
$usercontext = context_user::instance($USER->id);
- $this->export_context_data_for_user($USER->id, $usercontext, 'tool_admin_presets');
+ $this->export_context_data_for_user($USER->id, $usercontext, 'core_adminpresets');
$writer = \core_privacy\local\request\writer::with_context($usercontext);
- $this->assertEmpty($writer->get_data([get_string('pluginname', 'tool_admin_presets')]));
+ $this->assertEmpty($writer->get_data([get_string('siteadminpresetspluginname', 'core_adminpresets')]));
$this->assertEmpty($writer->get_all_metadata([]));
$this->assertEmpty($writer->get_files([]));
// Check data is not exported in system context either.
$systemcontext = context_system::instance();
- $this->export_context_data_for_user($USER->id, $systemcontext, 'tool_admin_presets');
+ $this->export_context_data_for_user($USER->id, $systemcontext, 'core_adminpresets');
$writer = \core_privacy\local\request\writer::with_context($systemcontext);
- $this->assertEmpty($writer->get_data([get_string('pluginname', 'tool_admin_presets')]));
+ $this->assertEmpty($writer->get_data([get_string('siteadminpresetspluginname', 'core_adminpresets')]));
$this->assertEmpty($writer->get_all_metadata([]));
$this->assertEmpty($writer->get_files([]));
}
@@ -127,19 +127,19 @@ class provider_test extends provider_testcase {
$this->resetAfterTest();
$this->setAdminUser();
- $currentpresets = $DB->count_records('tool_admin_presets');
+ $currentpresets = $DB->count_records('adminpresets');
// Create a preset.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$generator->create_preset();
- $this->assertEquals($currentpresets + 1, $DB->count_records('tool_admin_presets'));
+ $this->assertEquals($currentpresets + 1, $DB->count_records('adminpresets'));
$usercontext = context_user::instance($USER->id);
provider::delete_data_for_all_users_in_context($usercontext);
// Confirm the presets haven't been removed.
- $this->assertEquals($currentpresets + 1, $DB->count_records('tool_admin_presets'));
+ $this->assertEquals($currentpresets + 1, $DB->count_records('adminpresets'));
}
/**
@@ -152,19 +152,19 @@ class provider_test extends provider_testcase {
$this->resetAfterTest();
$this->setAdminUser();
- $currentpresets = $DB->count_records('tool_admin_presets');
+ $currentpresets = $DB->count_records('adminpresets');
// Create a preset.
- $generator = $this->getDataGenerator()->get_plugin_generator('tool_admin_presets');
+ $generator = $this->getDataGenerator()->get_plugin_generator('core_adminpresets');
$generator->create_preset();
- $this->assertEquals($currentpresets + 1, $DB->count_records('tool_admin_presets'));
+ $this->assertEquals($currentpresets + 1, $DB->count_records('adminpresets'));
$usercontext = context_user::instance($USER->id);
- $contextlist = new \core_privacy\local\request\approved_contextlist($USER, 'tool_admin_presets', [$usercontext->id]);
+ $contextlist = new \core_privacy\local\request\approved_contextlist($USER, 'core_adminpresets', [$usercontext->id]);
provider::delete_data_for_user($contextlist);
// Confirm the presets haven't been removed.
- $this->assertEquals($currentpresets + 1, $DB->count_records('tool_admin_presets'));
+ $this->assertEquals($currentpresets + 1, $DB->count_records('adminpresets'));
}
}
diff --git a/auth/ldap/classes/local/setting/admin_preset_auth_ldap_admin_setting_special_contexts_configtext.php b/auth/ldap/classes/adminpresets/adminpresets_auth_ldap_admin_setting_special_contexts_configtext.php
similarity index 90%
rename from auth/ldap/classes/local/setting/admin_preset_auth_ldap_admin_setting_special_contexts_configtext.php
rename to auth/ldap/classes/adminpresets/adminpresets_auth_ldap_admin_setting_special_contexts_configtext.php
index 435d08cd109..2391b3c2b2c 100644
--- a/auth/ldap/classes/local/setting/admin_preset_auth_ldap_admin_setting_special_contexts_configtext.php
+++ b/auth/ldap/classes/adminpresets/adminpresets_auth_ldap_admin_setting_special_contexts_configtext.php
@@ -14,9 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace auth_ldap\local\setting;
+namespace auth_ldap\adminpresets;
-use tool_admin_presets\local\setting\admin_preset_setting;
+use core_adminpresets\local\setting\adminpresets_setting;
/**
* Basic text setting, cleans the param using the admin_setting paramtext attribute.
@@ -26,7 +26,7 @@ use tool_admin_presets\local\setting\admin_preset_setting;
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_auth_ldap_admin_setting_special_contexts_configtext extends admin_preset_setting {
+class adminpresets_auth_ldap_admin_setting_special_contexts_configtext extends adminpresets_setting {
/**
* Validates the value using paramtype attribute
diff --git a/config-dist.php b/config-dist.php
index 4bf80b2ec06..fb5eeb514e7 100644
--- a/config-dist.php
+++ b/config-dist.php
@@ -1163,7 +1163,7 @@ $CFG->admin = 'admin';
// This setting accepts the following values:
// - One of the core preset names (i.e "starter" or "full").
// - The path of a valid XML preset file, that will be imported and applied. Absolute paths are recommended, to
-// guarantee the file is found: i.e."MOODLEPATH/admin/tool/admin_presets/tests/fixtures/import_settings_plugins.xml".
+// guarantee the file is found: i.e."MOODLEPATH/adminpresets/tests/fixtures/import_settings_plugins.xml".
//
// This setting is only used during the installation process. So once the Moodle site is installed, it is ignored.
//
diff --git a/lang/en/adminpresets.php b/lang/en/adminpresets.php
new file mode 100644
index 00000000000..6bfd529f01a
--- /dev/null
+++ b/lang/en/adminpresets.php
@@ -0,0 +1,55 @@
+.
+
+/**
+ * Core admin presets component to load some settings/plugins.
+ *
+ * @package core_adminpresets
+ * @copyright 2021 Sara Arjona (sara@moodle.com)
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
+$string['disabled'] = 'Disabled';
+$string['disabledwithvalue'] = 'Disabled ({$a})';
+$string['enabled'] = 'Enabled';
+$string['errordeleting'] = 'Error deleting from database.';
+$string['errorinserting'] = 'Error inserting into database.';
+$string['errornopreset'] = 'It doesn\'t exists a preset with that name.';
+$string['fullpreset'] = 'Full';
+$string['fullpresetdescription'] = 'All the Starter features plus External (LTI) tool, SCORM, Workshop, Analytics, Badges, Competencies, Learning plans and lots more.';
+$string['markedasadvanced'] = 'marked as advanced';
+$string['markedasforced'] = 'marked as forced';
+$string['markedaslocked'] = 'marked as locked';
+$string['markedasnonadvanced'] = 'marked as non advanced';
+$string['markedasnonforced'] = 'marked as non forced';
+$string['markedasnonlocked'] = 'marked as non locked';
+$string['privacy:metadata:adminpresets'] = 'The list of configuration presets.';
+$string['privacy:metadata:adminpresets:comments'] = 'A description about the preset.';
+$string['privacy:metadata:adminpresets:moodlerelease'] = 'The Moodle release version where the preset is based on.';
+$string['privacy:metadata:adminpresets:name'] = 'The name of the preset.';
+$string['privacy:metadata:adminpresets:site'] = 'The Moodle site where this preset was created.';
+$string['privacy:metadata:adminpresets:timecreated'] = 'The time that the change was made.';
+$string['privacy:metadata:adminpresets:userid'] = 'The user who create the preset.';
+$string['privacy:metadata:adminpresets_app'] = 'The configuration presets that have been applied.';
+$string['privacy:metadata:adminpresets_app:adminpresetid'] = 'The id of the preset applied.';
+$string['privacy:metadata:adminpresets_app:time'] = 'The time that the preset was applied.';
+$string['privacy:metadata:adminpresets_app:userid'] = 'The user who applied the preset.';
+$string['sensiblesettings'] = 'Settings with passwords';
+$string['sensiblesettingstext'] = 'Settings with passwords or other sensitive information can be excluded when creating a site admin preset. Enter additional settings with format SETTINGNAME@@PLUGINNAME separated by commas.';
+$string['siteadminpresetspluginname'] = 'Site admin presets';
+$string['starterpreset'] = 'Starter';
+$string['starterpresetdescription'] = 'Moodle with all of the most popular features, including Assignment, Feedback, Forum, H5P, Quiz and Completion tracking.';
+$string['wrongid'] = 'Wrong id';
diff --git a/lib/components.json b/lib/components.json
index 73dea36498e..19ca1243fd8 100644
--- a/lib/components.json
+++ b/lib/components.json
@@ -45,6 +45,7 @@
"subsystems": {
"access": null,
"admin": "admin",
+ "adminpresets": "adminpresets",
"analytics": "analytics",
"antivirus": "lib\/antivirus",
"auth": "auth",
diff --git a/lib/db/install.php b/lib/db/install.php
index db1041e4700..1f45b51cf9b 100644
--- a/lib/db/install.php
+++ b/lib/db/install.php
@@ -331,4 +331,8 @@ function xmldb_main_install() {
require_once($CFG->dirroot . '/badges/upgradelib.php'); // Core install and upgrade related functions only for badges.
badges_install_default_backpacks();
+
+ // Create default core site admin presets.
+ require_once($CFG->dirroot . '/adminpresets/classes/helper.php');
+ \core_adminpresets\helper::create_default_presets();
}
diff --git a/lib/db/install.xml b/lib/db/install.xml
index 6d4a6d15145..0a62801cf5c 100644
--- a/lib/db/install.xml
+++ b/lib/db/install.xml
@@ -1,5 +1,5 @@
-
@@ -4497,5 +4497,130 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/db/upgrade.php b/lib/db/upgrade.php
index 013dbac2035..201e7b8f33a 100644
--- a/lib/db/upgrade.php
+++ b/lib/db/upgrade.php
@@ -3322,5 +3322,221 @@ privatefiles,moodle|/user/files.php';
upgrade_main_savepoint(true, 2021122100.02);
}
+ if ($oldversion < 2021123000.01) {
+ // The tool_admin_presets tables have been moved to core, because core_adminpresets component has been created, so
+ // it can interact with the rest of core.
+ // So the tool_admin_presetsXXX tables will be renamed to adminipresetsXXX if they exists; otherwise, they will be created.
+
+ $tooltable = new xmldb_table('tool_admin_presets');
+ $table = new xmldb_table('adminpresets');
+ if ($dbman->table_exists($tooltable)) {
+ $dbman->rename_table($tooltable, 'adminpresets');
+ } else if (!$dbman->table_exists($table)) {
+ // Adding fields to table adminpresets.
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('name', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('comments', XMLDB_TYPE_TEXT, null, null, null, null, null);
+ $table->add_field('site', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('author', XMLDB_TYPE_CHAR, '255', null, null, null, null);
+ $table->add_field('moodleversion', XMLDB_TYPE_CHAR, '20', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('moodlerelease', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('iscore', XMLDB_TYPE_INTEGER, '1', null, XMLDB_NOTNULL, null, '0');
+ $table->add_field('timecreated', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
+ $table->add_field('timeimported', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, '0');
+
+ // Adding keys to table adminpresets.
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
+
+ // Launch create table for adminpresets.
+ $dbman->create_table($table);
+ }
+
+ $tooltable = new xmldb_table('tool_admin_presets_it');
+ $table = new xmldb_table('adminpresets_it');
+ if ($dbman->table_exists($tooltable)) {
+ $dbman->rename_table($tooltable, 'adminpresets_it');
+ } else if (!$dbman->table_exists($table)) {
+ // Adding fields to table adminpresets_it.
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('adminpresetid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('plugin', XMLDB_TYPE_CHAR, '100', null, null, null, null);
+ $table->add_field('name', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('value', XMLDB_TYPE_TEXT, null, null, null, null, null);
+
+ // Adding keys to table adminpresets_it.
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
+
+ // Adding indexes to table adminpresets_it.
+ $table->add_index('adminpresetid', XMLDB_INDEX_NOTUNIQUE, ['adminpresetid']);
+
+ // Launch create table for adminpresets_it.
+ $dbman->create_table($table);
+ }
+
+ $tooltable = new xmldb_table('tool_admin_presets_it_a');
+ $table = new xmldb_table('adminpresets_it_a');
+ if ($dbman->table_exists($tooltable)) {
+ $dbman->rename_table($tooltable, 'adminpresets_it_a');
+ } else if (!$dbman->table_exists($table)) {
+ // Adding fields to table adminpresets_it_a.
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('itemid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('name', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('value', XMLDB_TYPE_TEXT, null, null, null, null, null);
+
+ // Adding keys to table adminpresets_it_a.
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
+
+ // Adding indexes to table adminpresets_it_a.
+ $table->add_index('itemid', XMLDB_INDEX_NOTUNIQUE, ['itemid']);
+
+ // Launch create table for adminpresets_it_a.
+ $dbman->create_table($table);
+ }
+
+ $tooltable = new xmldb_table('tool_admin_presets_app');
+ $table = new xmldb_table('adminpresets_app');
+ if ($dbman->table_exists($tooltable)) {
+ $dbman->rename_table($tooltable, 'adminpresets_app');
+ } else if (!$dbman->table_exists($table)) {
+ // Adding fields to table adminpresets_app.
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('adminpresetid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('userid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('time', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+
+ // Adding keys to table adminpresets_app.
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
+
+ // Adding indexes to table adminpresets_app.
+ $table->add_index('adminpresetid', XMLDB_INDEX_NOTUNIQUE, ['adminpresetid']);
+
+ // Launch create table for adminpresets_app.
+ $dbman->create_table($table);
+ }
+
+ $tooltable = new xmldb_table('tool_admin_presets_app_it');
+ $table = new xmldb_table('adminpresets_app_it');
+ if ($dbman->table_exists($tooltable)) {
+ $dbman->rename_table($tooltable, 'adminpresets_app_it');
+ } else if (!$dbman->table_exists($table)) {
+ // Adding fields to table adminpresets_app_it.
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('adminpresetapplyid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('configlogid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+
+ // Adding keys to table adminpresets_app_it.
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
+
+ // Adding indexes to table adminpresets_app_it.
+ $table->add_index('configlogid', XMLDB_INDEX_NOTUNIQUE, ['configlogid']);
+ $table->add_index('adminpresetapplyid', XMLDB_INDEX_NOTUNIQUE, ['adminpresetapplyid']);
+
+ // Launch create table for adminpresets_app_it.
+ $dbman->create_table($table);
+ }
+
+ $tooltable = new xmldb_table('tool_admin_presets_app_it_a');
+ $table = new xmldb_table('adminpresets_app_it_a');
+ if ($dbman->table_exists($tooltable)) {
+ $dbman->rename_table($tooltable, 'adminpresets_app_it_a');
+ } else if (!$dbman->table_exists($table)) {
+ // Adding fields to table adminpresets_app_it_a.
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('adminpresetapplyid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('configlogid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('itemname', XMLDB_TYPE_CHAR, '100', null, null, null, null);
+
+ // Adding keys to table adminpresets_app_it_a.
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
+
+ // Adding indexes to table adminpresets_app_it_a.
+ $table->add_index('configlogid', XMLDB_INDEX_NOTUNIQUE, ['configlogid']);
+ $table->add_index('adminpresetapplyid', XMLDB_INDEX_NOTUNIQUE, ['adminpresetapplyid']);
+
+ // Launch create table for adminpresets_app_it_a.
+ $dbman->create_table($table);
+ }
+
+ $tooltable = new xmldb_table('tool_admin_presets_plug');
+ $table = new xmldb_table('adminpresets_plug');
+ if ($dbman->table_exists($tooltable)) {
+ $dbman->rename_table($tooltable, 'adminpresets_plug');
+ } else if (!$dbman->table_exists($table)) {
+ // Adding fields to table adminpresets_plug.
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('adminpresetid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('plugin', XMLDB_TYPE_CHAR, '100', null, null, null, null);
+ $table->add_field('name', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('enabled', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0');
+
+ // Adding keys to table adminpresets_plug.
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
+
+ // Adding indexes to table adminpresets_plug.
+ $table->add_index('adminpresetid', XMLDB_INDEX_NOTUNIQUE, ['adminpresetid']);
+
+ // Launch create table for adminpresets_plug.
+ $dbman->create_table($table);
+ }
+
+ $tooltable = new xmldb_table('tool_admin_presets_app_plug');
+ $table = new xmldb_table('adminpresets_app_plug');
+ if ($dbman->table_exists($tooltable)) {
+ $dbman->rename_table($tooltable, 'adminpresets_app_plug');
+ } else if (!$dbman->table_exists($table)) {
+ // Adding fields to table adminpresets_app_plug.
+ $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+ $table->add_field('adminpresetapplyid', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('plugin', XMLDB_TYPE_CHAR, '100', null, null, null, null);
+ $table->add_field('name', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
+ $table->add_field('value', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0');
+ $table->add_field('oldvalue', XMLDB_TYPE_INTEGER, '4', null, XMLDB_NOTNULL, null, '0');
+
+ // Adding keys to table adminpresets_app_plug.
+ $table->add_key('primary', XMLDB_KEY_PRIMARY, ['id']);
+
+ // Adding indexes to table adminpresets_app_plug.
+ $table->add_index('adminpresetapplyid', XMLDB_INDEX_NOTUNIQUE, ['adminpresetapplyid']);
+
+ // Launch create table for adminpresets_app_plug.
+ if (!$dbman->table_exists($table)) {
+ $dbman->create_table($table);
+ }
+ }
+
+ if ($DB->count_records('adminpresets', ['iscore' => 1]) == 0) {
+ // Create default core site admin presets.
+ require_once($CFG->dirroot . '/adminpresets/classes/helper.php');
+ \core_adminpresets\helper::create_default_presets();
+ }
+
+ // Main savepoint reached.
+ upgrade_main_savepoint(true, 2021123000.01);
+ }
+
+ if ($oldversion < 2021123000.02) {
+ // If exists, migrate sensiblesettings admin settings from tool_admin_preset to adminpresets.
+ if (get_config('tool_admin_presets', 'sensiblesettings') !== false) {
+ set_config('sensiblesettings', get_config('tool_admin_presets', 'sensiblesettings'), 'adminpresets');
+ unset_config('sensiblesettings', 'tool_admin_presets');
+ }
+
+ // Main savepoint reached.
+ upgrade_main_savepoint(true, 2021123000.02);
+ }
+
+ if ($oldversion < 2021123000.03) {
+ // If exists, migrate lastpresetapplied setting from tool_admin_preset to adminpresets.
+ if (get_config('tool_admin_presets', 'lastpresetapplied') !== false) {
+ set_config('lastpresetapplied', get_config('tool_admin_presets', 'lastpresetapplied'), 'adminpresets');
+ unset_config('lastpresetapplied', 'tool_admin_presets');
+ }
+
+ // Main savepoint reached.
+ upgrade_main_savepoint(true, 2021123000.03);
+ }
+
return true;
}
diff --git a/lib/installlib.php b/lib/installlib.php
index 0a72a79bf93..120f6eba0a0 100644
--- a/lib/installlib.php
+++ b/lib/installlib.php
@@ -538,6 +538,6 @@ function install_cli_database(array $options, $interactive) {
// Apply default preset, if it is defined in $CFG and has a valid value.
if (!empty($CFG->setsitepresetduringinstall)) {
- \tool_admin_presets\helper::change_default_preset($CFG->setsitepresetduringinstall);
+ \core_adminpresets\helper::change_default_preset($CFG->setsitepresetduringinstall);
}
}
diff --git a/lib/tests/component_test.php b/lib/tests/component_test.php
index f9ec91db5fe..631fd27643b 100644
--- a/lib/tests/component_test.php
+++ b/lib/tests/component_test.php
@@ -36,7 +36,7 @@ class component_test extends advanced_testcase {
* this is defined here to annoy devs that try to add more without any thinking,
* always verify that it does not collide with any existing add-on modules and subplugins!!!
*/
- const SUBSYSTEMCOUNT = 74;
+ const SUBSYSTEMCOUNT = 75;
public function setUp(): void {
$psr0namespaces = new ReflectionProperty('core_component', 'psr0namespaces');
diff --git a/mod/quiz/classes/local/setting/admin_preset_mod_quiz_admin_review_setting.php b/mod/quiz/classes/adminpresets/adminpresets_mod_quiz_admin_review_setting.php
similarity index 73%
rename from mod/quiz/classes/local/setting/admin_preset_mod_quiz_admin_review_setting.php
rename to mod/quiz/classes/adminpresets/adminpresets_mod_quiz_admin_review_setting.php
index ec44c4b7ea8..102dafb12e8 100644
--- a/mod/quiz/classes/local/setting/admin_preset_mod_quiz_admin_review_setting.php
+++ b/mod/quiz/classes/adminpresets/adminpresets_mod_quiz_admin_review_setting.php
@@ -14,10 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_quiz\local\setting;
+namespace mod_quiz\adminpresets;
use ReflectionMethod;
-use tool_admin_presets\local\setting\admin_preset_setting;
+use core_adminpresets\local\setting\adminpresets_setting;
/**
* Admin settings class for the quiz review options.
@@ -27,22 +27,7 @@ use tool_admin_presets\local\setting\admin_preset_setting;
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_mod_quiz_admin_review_setting extends admin_preset_setting {
-
- /**
- * Overwrite to add the reviewoptions text
- */
- public function set_text() {
-
- $this->set_visiblevalue();
-
- $name = get_string('reviewoptionsheading', 'quiz') .
- ': ' . $this->settingdata->visiblename;
- $namediv = '' . $name . '
';
- $valuediv = '' . $this->visiblevalue . '
';
-
- $this->text = $namediv . $valuediv . '
';
- }
+class adminpresets_mod_quiz_admin_review_setting extends adminpresets_setting {
/**
* The setting value is a sum of 'mod_quiz_admin_review_setting::times'
diff --git a/mod/quiz/classes/local/setting/admin_preset_mod_quiz_admin_setting_browsersecurity.php b/mod/quiz/classes/adminpresets/adminpresets_mod_quiz_admin_setting_browsersecurity.php
similarity index 82%
rename from mod/quiz/classes/local/setting/admin_preset_mod_quiz_admin_setting_browsersecurity.php
rename to mod/quiz/classes/adminpresets/adminpresets_mod_quiz_admin_setting_browsersecurity.php
index c16641ee727..d73e0a63e63 100644
--- a/mod/quiz/classes/local/setting/admin_preset_mod_quiz_admin_setting_browsersecurity.php
+++ b/mod/quiz/classes/adminpresets/adminpresets_mod_quiz_admin_setting_browsersecurity.php
@@ -14,9 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_quiz\local\setting;
+namespace mod_quiz\adminpresets;
-use tool_admin_presets\local\setting\admin_preset_admin_setting_configselect_with_advanced;
+use core_adminpresets\local\setting\adminpresets_admin_setting_configselect_with_advanced;
/**
* Admin settings class for the quiz browser security option.
@@ -26,7 +26,7 @@ use tool_admin_presets\local\setting\admin_preset_admin_setting_configselect_wit
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_mod_quiz_admin_setting_browsersecurity extends admin_preset_admin_setting_configselect_with_advanced {
+class adminpresets_mod_quiz_admin_setting_browsersecurity extends adminpresets_admin_setting_configselect_with_advanced {
public function set_behaviors() {
$this->behaviors['loadchoices'] = &$this->settingdata;
diff --git a/mod/quiz/classes/local/setting/admin_preset_mod_quiz_admin_setting_grademethod.php b/mod/quiz/classes/adminpresets/adminpresets_mod_quiz_admin_setting_grademethod.php
similarity index 82%
rename from mod/quiz/classes/local/setting/admin_preset_mod_quiz_admin_setting_grademethod.php
rename to mod/quiz/classes/adminpresets/adminpresets_mod_quiz_admin_setting_grademethod.php
index 3f64e525186..1393d5a30e5 100644
--- a/mod/quiz/classes/local/setting/admin_preset_mod_quiz_admin_setting_grademethod.php
+++ b/mod/quiz/classes/adminpresets/adminpresets_mod_quiz_admin_setting_grademethod.php
@@ -14,9 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_quiz\local\setting;
+namespace mod_quiz\adminpresets;
-use tool_admin_presets\local\setting\admin_preset_admin_setting_configselect_with_advanced;
+use core_adminpresets\local\setting\adminpresets_admin_setting_configselect_with_advanced;
/**
* Admin settings class for the quiz grading method.
@@ -26,7 +26,7 @@ use tool_admin_presets\local\setting\admin_preset_admin_setting_configselect_wit
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_mod_quiz_admin_setting_grademethod extends admin_preset_admin_setting_configselect_with_advanced {
+class adminpresets_mod_quiz_admin_setting_grademethod extends adminpresets_admin_setting_configselect_with_advanced {
public function set_behaviors() {
$this->behaviors['loadchoices'] = &$this->settingdata;
diff --git a/mod/quiz/classes/local/setting/admin_preset_mod_quiz_admin_setting_overduehandling.php b/mod/quiz/classes/adminpresets/adminpresets_mod_quiz_admin_setting_overduehandling.php
similarity index 82%
rename from mod/quiz/classes/local/setting/admin_preset_mod_quiz_admin_setting_overduehandling.php
rename to mod/quiz/classes/adminpresets/adminpresets_mod_quiz_admin_setting_overduehandling.php
index e284ff711ab..4e5745921da 100644
--- a/mod/quiz/classes/local/setting/admin_preset_mod_quiz_admin_setting_overduehandling.php
+++ b/mod/quiz/classes/adminpresets/adminpresets_mod_quiz_admin_setting_overduehandling.php
@@ -14,9 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_quiz\local\setting;
+namespace mod_quiz\adminpresets;
-use tool_admin_presets\local\setting\admin_preset_admin_setting_configselect_with_advanced;
+use core_adminpresets\local\setting\adminpresets_admin_setting_configselect_with_advanced;
/**
* Admin settings class for the quiz overdue attempt handling method.
@@ -26,7 +26,7 @@ use tool_admin_presets\local\setting\admin_preset_admin_setting_configselect_wit
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_mod_quiz_admin_setting_overduehandling extends admin_preset_admin_setting_configselect_with_advanced {
+class adminpresets_mod_quiz_admin_setting_overduehandling extends adminpresets_admin_setting_configselect_with_advanced {
public function set_behaviors() {
$this->behaviors['loadchoices'] = &$this->settingdata;
diff --git a/mod/quiz/classes/local/setting/admin_preset_mod_quiz_admin_setting_user_image.php b/mod/quiz/classes/adminpresets/adminpresets_mod_quiz_admin_setting_user_image.php
similarity index 82%
rename from mod/quiz/classes/local/setting/admin_preset_mod_quiz_admin_setting_user_image.php
rename to mod/quiz/classes/adminpresets/adminpresets_mod_quiz_admin_setting_user_image.php
index 0dc8268373a..2ed15506fb8 100644
--- a/mod/quiz/classes/local/setting/admin_preset_mod_quiz_admin_setting_user_image.php
+++ b/mod/quiz/classes/adminpresets/adminpresets_mod_quiz_admin_setting_user_image.php
@@ -14,9 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_quiz\local\setting;
+namespace mod_quiz\adminpresets;
-use tool_admin_presets\local\setting\admin_preset_admin_setting_configselect_with_advanced;
+use core_adminpresets\local\setting\adminpresets_admin_setting_configselect_with_advanced;
/**
* Admin settings class for the choices for how to display the user's image.
@@ -26,7 +26,7 @@ use tool_admin_presets\local\setting\admin_preset_admin_setting_configselect_wit
* @author Jordan Kesraoui | Sylvain Revenu | Pimenko based on David Monllaó code
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class admin_preset_mod_quiz_admin_setting_user_image extends admin_preset_admin_setting_configselect_with_advanced {
+class adminpresets_mod_quiz_admin_setting_user_image extends adminpresets_admin_setting_configselect_with_advanced {
public function set_behaviors() {
$this->behaviors['loadchoices'] = &$this->settingdata;
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 3a1ccc779e7..7c0661877d9 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -208,6 +208,9 @@
reportbuilder/tests
+
+ adminpresets/tests
+
diff --git a/version.php b/version.php
index 4366b8f45e6..0d6e9573562 100644
--- a/version.php
+++ b/version.php
@@ -29,7 +29,7 @@
defined('MOODLE_INTERNAL') || die();
-$version = 2021123000.00; // YYYYMMDD = weekly release date of this DEV branch.
+$version = 2021123000.03; // YYYYMMDD = weekly release date of this DEV branch.
// RR = release increments - 00 in DEV branches.
// .XX = incremental changes.
$release = '4.0dev+ (Build: 20211230)'; // Human-friendly version name