MDL-79809 environment: Add recommended custom check

Add support for custom environment checks to have a recommended
option in addition to required an optional.
This commit is contained in:
Huong Nguyen 2024-06-14 09:29:17 +07:00
parent 17124e62a9
commit 2978ffc4a5
No known key found for this signature in database
GPG Key ID: 40D88AB693A3E72A
3 changed files with 10 additions and 5 deletions

View File

@ -2052,8 +2052,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') {
@ -2084,7 +2086,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)

View File

@ -606,6 +606,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\'.';

View File

@ -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 {