From 66349bad3a8c7b8e5aed742837226e139bff9bab Mon Sep 17 00:00:00 2001 From: Matt Porritt Date: Fri, 15 Mar 2024 13:47:20 +1100 Subject: [PATCH] MDL-81172 Administration: Add recommended custom check Add support for custom environment checks to have a recommended option in addition to required an optional. --- admin/environment.xml | 2 +- admin/renderer.php | 7 +++++-- lang/en/admin.php | 4 ++++ lib/environmentlib.php | 7 ++++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/admin/environment.xml b/admin/environment.xml index 5630b13800b..20fdcd27ad9 100644 --- a/admin/environment.xml +++ b/admin/environment.xml @@ -4504,7 +4504,7 @@ - + diff --git a/admin/renderer.php b/admin/renderer.php index 184a7ba759a..0dab67c514d 100644 --- a/admin/renderer.php +++ b/admin/renderer.php @@ -2055,8 +2055,10 @@ class core_admin_renderer extends plugin_renderer_base { // We are checking installed & enabled things if ($environment_result->getLevel() == 'required') { $stringtouse = 'environmentrequirecustomcheck'; - } else { + } else if ($environment_result->getLevel() == 'optional') { $stringtouse = 'environmentrecommendcustomcheck'; + } else { + $stringtouse = 'environmentshouldfixcustomcheck'; } } else if ($environment_result->getPart() == 'php_setting') { @@ -2087,7 +2089,8 @@ class core_admin_renderer extends plugin_renderer_base { if ($status) { //Handle ok result (ok) $status = get_string('statusok'); } else { - if ($environment_result->getLevel() == 'optional') {//Handle check result (warning) + // Handle check result (warning). + if (in_array($environment_result->getLevel(), ['optional', 'recommended'])) { $status = get_string('check'); $warningline = true; } else { //Handle error result (error) diff --git a/lang/en/admin.php b/lang/en/admin.php index d6d570dac53..39c40f235fc 100644 --- a/lang/en/admin.php +++ b/lang/en/admin.php @@ -75,6 +75,9 @@ $string['alternativefullnameformat_desc'] = 'This defines how names are shown to $string['always'] = 'Always'; $string['appearance'] = 'Appearance'; $string['aspellpath'] = 'Path to aspell'; +$string['asyncbackupdisabled'] = 'Your site is currently configured to use synchronous backups. Asynchronous backups provide a better user experience. +Asynchronous backups will be enabled for all sites from Moodle LMS 4.5 LTS. +Synchronous backups will be removed from Moodle LMS the version after 4.5 LTS'; $string['authentication'] = 'Authentication'; $string['authpreventaccountcreation'] = 'Prevent account creation when authenticating'; $string['authpreventaccountcreation_help'] = 'When a user authenticates, an account on the site is automatically created if it doesn\'t yet exist. If an external database, such as LDAP, is used for authentication, but you wish to restrict access to the site to users with an existing account only, then this option should be enabled. New accounts will need to be created manually or via the upload users feature. Note that this setting doesn\'t apply to MNet authentication.'; @@ -631,6 +634,7 @@ $string['environmentrequirecustomcheck'] = 'this test must pass'; $string['environmentrequireinstall'] = 'must be installed and enabled'; $string['environmentrequireversion'] = 'version {$a->needed} is required and you are running {$a->current}'; $string['environmentsettingok'] = 'recommended setting detected'; +$string['environmentshouldfixcustomcheck'] = 'should be enabled for best results'; $string['environmentshouldfixsetting'] = 'PHP setting should be changed.'; $string['environmentxmlerror'] = 'Error reading environment data ({$a->error_code})'; $string['environmentmariadbwrongdbtype'] = 'Wrong $CFG->dbtype. You need to change it in your config.php file from \'mysqli\' to \'mariadb\'.'; diff --git a/lib/environmentlib.php b/lib/environmentlib.php index 4d82c2ca49a..bafbda78a45 100644 --- a/lib/environmentlib.php +++ b/lib/environmentlib.php @@ -1251,7 +1251,7 @@ class environment_results { */ var $error_code; /** - * @var string required/optional + * @var string required/optional/recommended. */ var $level; /** @@ -1548,8 +1548,9 @@ function get_level($element) { $level = 'required'; if (isset($element['@']['level'])) { $level = $element['@']['level']; - if (!in_array($level, array('required', 'optional'))) { - debugging('The level of a check in the environment.xml file must be "required" or "optional".', DEBUG_DEVELOPER); + if (!in_array($level, ['required', 'optional', 'recommended'])) { + debugging('The level of a check in the environment.xml file must be "required", "optional" or "recommended".', + DEBUG_DEVELOPER); $level = 'required'; } } else {