mirror of
https://github.com/slawkens/myaac.git
synced 2025-05-02 12:19:20 +02:00
Re-enable plugin if disabled and already installed
This commit is contained in:
parent
433ccff851
commit
939508e799
35
admin/includes/settings_menus.php
Normal file
35
admin/includes/settings_menus.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
$order = 10;
|
||||||
|
|
||||||
|
$settingsMenu = [];
|
||||||
|
|
||||||
|
$settingsMenu[] = [
|
||||||
|
'name' => 'MyAAC',
|
||||||
|
'link' => 'settings&plugin=core',
|
||||||
|
'icon' => 'list',
|
||||||
|
'order' => $order,
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach (Plugins::getAllPluginsSettings() as $setting) {
|
||||||
|
$file = BASE . $setting['settingsFilename'];
|
||||||
|
if (!file_exists($file)) {
|
||||||
|
warning('Plugin setting: ' . $file . ' - cannot be loaded.');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$order += 10;
|
||||||
|
|
||||||
|
$settings = require $file;
|
||||||
|
|
||||||
|
$settingsMenu[] = [
|
||||||
|
'name' => $settings['name'],
|
||||||
|
'link' => 'settings&plugin=' . $setting['pluginFilename'],
|
||||||
|
'icon' => 'list',
|
||||||
|
'order' => $order,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($settings, $file, $order);
|
||||||
|
|
||||||
|
return $settingsMenu;
|
@ -284,6 +284,12 @@ class Plugins {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pluginFilename = str_replace('.json', '', basename($json_file));
|
||||||
|
if (self::existDisabled($pluginFilename)) {
|
||||||
|
success('The plugin already existed, but was disabled. It has been enabled again and will be now reinstalled.');
|
||||||
|
self::enable($pluginFilename);
|
||||||
|
}
|
||||||
|
|
||||||
$string = file_get_contents($file_name);
|
$string = file_get_contents($file_name);
|
||||||
$plugin_json = json_decode($string, true);
|
$plugin_json = json_decode($string, true);
|
||||||
self::$plugin_json = $plugin_json;
|
self::$plugin_json = $plugin_json;
|
||||||
@ -484,13 +490,23 @@ class Plugins {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function enable($pluginFileName): bool
|
public static function isEnabled($pluginFileName): bool
|
||||||
{
|
{
|
||||||
|
$filenameJson = $pluginFileName . '.json';
|
||||||
|
return !is_file(PLUGINS . 'disabled.' . $filenameJson) && is_file(PLUGINS . $filenameJson);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function existDisabled($pluginFileName): bool
|
||||||
|
{
|
||||||
|
$filenameJson = $pluginFileName . '.json';
|
||||||
|
return is_file(PLUGINS . 'disabled.' . $filenameJson);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function enable($pluginFileName): bool {
|
||||||
return self::enableDisable($pluginFileName, true);
|
return self::enableDisable($pluginFileName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function disable($pluginFileName): bool
|
public static function disable($pluginFileName): bool {
|
||||||
{
|
|
||||||
return self::enableDisable($pluginFileName, false);
|
return self::enableDisable($pluginFileName, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user