diff options
author | Andrew Dolgov <[email protected]> | 2021-03-03 19:35:11 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-03-03 19:35:11 +0300 |
commit | 0cb719a40447e30011142714d5e5ce55c051a118 (patch) | |
tree | b629f55148996ee6e4aedab227bb161f58b55db6 /classes/pref | |
parent | dfdb746a76231bfb4c8066328bf99cd54f83783c (diff) |
add basic local plugin uninstaller
Diffstat (limited to 'classes/pref')
-rw-r--r-- | classes/pref/prefs.php | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/classes/pref/prefs.php b/classes/pref/prefs.php index 275f41656..09fbce9a1 100644 --- a/classes/pref/prefs.php +++ b/classes/pref/prefs.php @@ -796,6 +796,7 @@ class Pref_Prefs extends Handler_Protected { foreach ($tmppluginhost->get_plugins() as $name => $plugin) { $about = $plugin->about(); + $is_local = $tmppluginhost->is_local($plugin); $version = htmlspecialchars($this->_get_plugin_version($plugin)); if ($about[3] ?? false) { @@ -822,6 +823,14 @@ class Pref_Prefs extends Handler_Protected { <i class='material-icons'>open_in_new</i> <?= __("More info...") ?></button> <?php } ?> + <?php if ($_SESSION["access_level"] >= 10 && $is_local) { ?> + <button dojoType='dijit.form.Button' + onclick='Helpers.Plugins.uninstall("<?= htmlspecialchars($name) ?>")'> + <?= \Controls\icon("delete") ?> + <?= __("Uninstall") ?> + </button> + <?php } ?> + <?php if ($version) { ?> <div dojoType='dijit.Tooltip' connectId='PLABEL-<?= htmlspecialchars($name) ?>' position='after'> <?= $version ?> @@ -842,6 +851,7 @@ class Pref_Prefs extends Handler_Protected { foreach ($tmppluginhost->get_plugins() as $name => $plugin) { $about = $plugin->about(); + $is_local = $tmppluginhost->is_local($plugin); $version = htmlspecialchars($this->_get_plugin_version($plugin)); if (empty($about[3]) || $about[3] == false) { @@ -889,6 +899,14 @@ class Pref_Prefs extends Handler_Protected { <i class='material-icons'>open_in_new</i> <?= __("More info...") ?></button> <?php } ?> + <?php if ($_SESSION["access_level"] >= 10 && $is_local) { ?> + <button dojoType='dijit.form.Button' + onclick='Helpers.Plugins.uninstall("<?= htmlspecialchars($name) ?>")'> + <?= \Controls\icon("delete") ?> + <?= __("Uninstall") ?> + </button> + <?php } ?> + <?php if ($version) { ?> <div dojoType='dijit.Tooltip' connectId='PLABEL-<?= htmlspecialchars($name) ?>' position='after'> <?= $version ?> @@ -1235,9 +1253,24 @@ class Pref_Prefs extends Handler_Protected { } } + function uninstallPlugin() { + if ($_SESSION["access_level"] >= 10) { + $plugin_name = basename(clean($_REQUEST['plugin'])); + $status = 0; + + $plugin_dir = dirname(dirname(__DIR__)) . "/plugins.local/$plugin_name"; + + if (is_dir($plugin_dir)) { + $status = $this->_recursive_rmdir($plugin_dir); + } + + print json_encode(['status' => $status]); + } + } + function installPlugin() { if ($_SESSION["access_level"] >= 10 && Config::get(Config::ENABLE_PLUGIN_INSTALLER)) { - $plugin_name = clean($_REQUEST['plugin']); + $plugin_name = basename(clean($_REQUEST['plugin'])); $all_plugins = $this->_get_available_plugins(); $plugin_dir = dirname(dirname(__DIR__)) . "/plugins.local"; |