Plugin manager: add ALERT message function

A plugin file may include a <ALERT> tag which displays a markdown formatted message when a new version is available.
Use this to give instructions or warnings to users before the upgrade is done.
This commit is contained in:
bergware
2022-05-31 21:45:22 +02:00
parent e2cfd09740
commit cbcad92963
4 changed files with 37 additions and 20 deletions
@@ -1,6 +1,6 @@
#!/usr/bin/php -q
<?PHP
// Copyright 2005-2021, Lime Technology
// Copyright 2005-2022, Lime Technology
// License: GPLv2 only
//
// Program updates made by Bergware International (April 2020)
@@ -228,6 +228,12 @@ function plugin($method, $plugin_file, &$error) {
return trim($xml->CHANGES);
}
// alert message
if ($method == 'alert') {
if (!$xml->ALERT) return false;
return trim($xml->ALERT);
}
// check if $method is an attribute
if (!in_array($method, $methods)) {
foreach ($xml->attributes() as $key => $value) {
@@ -477,7 +483,7 @@ if ($method == 'install') {
echo "plugin: installed Unraid version is too high, require at most version $max\n";
if (dirname($plugin_file) == "$boot") {
move($plugin_file, "$boot-error");
}
}
exit(1);
}
$plugin = basename($plugin_file);