mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-29 18:59:21 +02:00
Merge branch 'main' into develop
This commit is contained in:
commit
869ec035d9
@ -675,26 +675,41 @@ class Plugins {
|
|||||||
|
|
||||||
public static function uninstall($plugin_name): bool
|
public static function uninstall($plugin_name): bool
|
||||||
{
|
{
|
||||||
|
$isDisabled = self::existDisabled($plugin_name);
|
||||||
|
if($isDisabled) {
|
||||||
|
self::enable($plugin_name);
|
||||||
|
}
|
||||||
|
|
||||||
|
$revertEnable = function() use ($isDisabled, $plugin_name) {
|
||||||
|
if($isDisabled) {
|
||||||
|
self::disable($plugin_name);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
$filename = BASE . 'plugins/' . $plugin_name . '.json';
|
$filename = BASE . 'plugins/' . $plugin_name . '.json';
|
||||||
if(!file_exists($filename)) {
|
if(!file_exists($filename)) {
|
||||||
self::$error = 'Plugin ' . $plugin_name . ' does not exist.';
|
self::$error = 'Plugin ' . $plugin_name . ' does not exist.';
|
||||||
|
$revertEnable();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$string = file_get_contents($filename);
|
$string = file_get_contents($filename);
|
||||||
$plugin_info = json_decode($string, true);
|
$plugin_info = json_decode($string, true);
|
||||||
if(!$plugin_info) {
|
if(!$plugin_info) {
|
||||||
self::$error = 'Cannot load plugin info ' . $plugin_name . '.json';
|
self::$error = 'Cannot load plugin info ' . $plugin_name . '.json';
|
||||||
|
$revertEnable();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isset($plugin_info['uninstall'])) {
|
if(!isset($plugin_info['uninstall'])) {
|
||||||
self::$error = "Plugin doesn't have uninstall options defined. Skipping...";
|
self::$error = "Plugin doesn't have uninstall options defined. Skipping...";
|
||||||
|
$revertEnable();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$success = true;
|
$success = true;
|
||||||
foreach($plugin_info['uninstall'] as $file) {
|
foreach($plugin_info['uninstall'] as $file) {
|
||||||
if(strpos($file, '/') === 0) {
|
if(str_starts_with($file, '/')) {
|
||||||
$success = false;
|
$success = false;
|
||||||
self::$error = "You cannot use absolute paths (starting with slash - '/'): " . $file;
|
self::$error = "You cannot use absolute paths (starting with slash - '/'): " . $file;
|
||||||
break;
|
break;
|
||||||
@ -726,6 +741,7 @@ class Plugins {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$revertEnable();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user