Skip to content

Commit

Permalink
MDL-81172 Administration: Add recommended custom check
Browse files Browse the repository at this point in the history
Add support for custom environment checks to have a recommended
option in addition to required an optional.
  • Loading branch information
Matt Porritt committed Mar 18, 2024
1 parent 5d74f36 commit 66349ba
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion admin/environment.xml
Expand Up @@ -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>
Expand Down
7 changes: 5 additions & 2 deletions admin/renderer.php
Expand Up @@ -2055,8 +2055,10 @@ public function environment_check_table($result, $environment_results) {
// 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') {
Expand Down Expand Up @@ -2087,7 +2089,8 @@ public function environment_check_table($result, $environment_results) {
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)
Expand Down
4 changes: 4 additions & 0 deletions lang/en/admin.php
Expand Up @@ -75,6 +75,9 @@
$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.';
Expand Down Expand Up @@ -631,6 +634,7 @@
$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\'.';
Expand Down
7 changes: 4 additions & 3 deletions lib/environmentlib.php
Expand Up @@ -1251,7 +1251,7 @@ class environment_results {
*/
var $error_code;
/**
* @var string required/optional
* @var string required/optional/recommended.
*/
var $level;
/**
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 66349ba

Please sign in to comment.