MDL-81172 Administration: 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:
Matt Porritt 2024-03-15 13:47:20 +11:00
parent 5d74f366a0
commit 66349bad3a
4 changed files with 14 additions and 6 deletions

View file

@ -4504,7 +4504,7 @@
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_oracle_usage" level="optional">
</CUSTOM_CHECK>
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_async_backup" level="optional">
<CUSTOM_CHECK file="lib/upgradelib.php" function="check_async_backup" level="recommended">
</CUSTOM_CHECK>
</CUSTOM_CHECKS>
</MOODLE>

View file

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

View file

@ -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\'.';

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 {