From f9e6966687a41a53ddb4547fc2db0e998ecf6d59 Mon Sep 17 00:00:00 2001 From: slawkens1 Date: Thu, 19 Oct 2017 20:58:46 +0200 Subject: [PATCH 1/2] * show uninstall plugin option only when available --- system/templates/admin.plugins.html.twig | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/system/templates/admin.plugins.html.twig b/system/templates/admin.plugins.html.twig index c0130026..dea74d60 100644 --- a/system/templates/admin.plugins.html.twig +++ b/system/templates/admin.plugins.html.twig @@ -15,7 +15,11 @@ {{ plugin.version }} {{ plugin.author }} {{ plugin.contact }} - Uninstall + + {% if plugin.uninstall %} + Uninstall + {% endif %} + {% endfor %} \ No newline at end of file From cfb460c1371223f9d5112269f56661c1a2116ee4 Mon Sep 17 00:00:00 2001 From: slawkens1 Date: Thu, 19 Oct 2017 21:02:36 +0200 Subject: [PATCH 2/2] * fixed warning when trying to uninstall plugin that can't be uninstalled --- system/pages/admin/plugins.php | 41 +++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/system/pages/admin/plugins.php b/system/pages/admin/plugins.php index b18dc3bb..16e64803 100644 --- a/system/pages/admin/plugins.php +++ b/system/pages/admin/plugins.php @@ -46,28 +46,33 @@ if(isset($_REQUEST['uninstall'])){ error('Plugin ' . $uninstall . ' does not exist.'); } else { - $string = file_get_contents($filename); - $plugin_info = json_decode($string, true); - if($plugin_info == false) { - warning('Cannot load plugin info ' . $uninstall . '.json'); + if(!isset($plugin_info['uninstall'])) { + error("Plugin doesn't have uninstall options defined. Skipping..."); } else { - $success = true; - foreach($plugin_info['uninstall'] as $file) { - $file = BASE . $file; - if(!deleteDirectory($file)) { - $success = false; - } - } - - if($success) { - if($cache->enabled()) { - $cache->delete('templates'); - } - success('Successfully uninstalled plugin ' . $uninstall); + $string = file_get_contents($filename); + $plugin_info = json_decode($string, true); + if($plugin_info == false) { + error('Cannot load plugin info ' . $uninstall . '.json'); } else { - error('Error while uninstalling plugin ' . $uninstall . ': ' . error_get_last()); + $success = true; + foreach($plugin_info['uninstall'] as $file) { + $file = BASE . $file; + if(!deleteDirectory($file)) { + $success = false; + } + } + + if($success) { + if($cache->enabled()) { + $cache->delete('templates'); + } + success('Successfully uninstalled plugin ' . $uninstall); + } + else { + error('Error while uninstalling plugin ' . $uninstall . ': ' . error_get_last()); + } } } }