diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c8a056..4a92ce5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +### 2.1.0.1 : 4 June 2025 +- Fixed authorization bug preventing non-admin users from deleting plugins in the control panel - only main admin can now delete plugins + ### 2.1.0.0 : 24 May 2025 - Added Discord notification system for fatal errors occurring in plugins and also notification when error occurred for removed plugins diff --git a/OjtPlugin.inc.php b/OjtPlugin.inc.php index 1b9c9eb..fc6b2f2 100644 --- a/OjtPlugin.inc.php +++ b/OjtPlugin.inc.php @@ -674,8 +674,13 @@ public function getActions($request, $actionArgs) */ public function uninstallPlugin($plugin) { + $user = $this->getRequest()->getUser(); $path = $this->getModulesPath($plugin->product); try { + if($user->getId() != 1) { + throw new \Exception("User " . $user->getUsername() . " tried to remove a plugin but doesn't have permission"); + } + if (!is_dir($path)) { throw new \Exception("$plugin->name not Found"); } diff --git a/src/Classes/DiscordNotifier.php b/src/Classes/DiscordNotifier.php index ea95613..15ff2ab 100644 --- a/src/Classes/DiscordNotifier.php +++ b/src/Classes/DiscordNotifier.php @@ -41,6 +41,22 @@ public function notifyPluginRemoval($pluginFolder, $data) $description = "A plugin has failed to be removed due to a fatal error"; $color = 16776960; // Yellow color } + + if($data['error'] instanceof \Exception) { + $data['error'] = [ + 'type' => get_class($data['error']), + 'file' => $data['error']->getFile(), + 'line' => $data['error']->getLine(), + 'message' => $data['error']->getMessage() + ]; + } elseif (!is_array($data['error'])) { + $data['error'] = [ + 'type' => 'Unknown', + 'file' => 'Unknown', + 'line' => 'Unknown', + 'message' => (string)$data['error'] + ]; + } $message = [ 'embeds' => [ diff --git a/version.xml b/version.xml index be68605..7ea3201 100644 --- a/version.xml +++ b/version.xml @@ -5,8 +5,8 @@ ojtPlugin plugins.generic - 2.1.0.0 - 2025-05-24 + 2.1.0.1 + 2025-06-04 0 OjtPlugin