From feefa70c4b140dd8f9e3aad3783e515c08b75382 Mon Sep 17 00:00:00 2001 From: blackcoder87 Date: Sat, 30 Nov 2024 16:51:59 +0100 Subject: [PATCH 1/4] Do not try to uninstall a system module --- .../modules/admin/controllers/admin/Modules.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/application/modules/admin/controllers/admin/Modules.php b/application/modules/admin/controllers/admin/Modules.php index 0dcf9ee3e..2d4ed74c6 100644 --- a/application/modules/admin/controllers/admin/Modules.php +++ b/application/modules/admin/controllers/admin/Modules.php @@ -234,7 +234,6 @@ public function updatesAction() foreach (glob(ROOT_PATH . '/application/modules/*') as $modulesPath) { $key = basename($modulesPath); - $modulesDir[] = $key; $configClass = '\\Modules\\' . ucfirst($key) . '\\Config\\Config'; if (class_exists($configClass)) { @@ -424,10 +423,13 @@ public function uninstallAction() if ($this->getRequest()->isSecure()) { $configClass = '\\Modules\\' . ucfirst($key) . '\\Config\\Config'; $config = new $configClass($this->getTranslator()); - $config->uninstall(); - $moduleMapper->delete($key); - $this->addMessage('deleteSuccess'); + if (!isset($config->config['system_module'])) { + $config->uninstall(); + $moduleMapper->delete($key); + + $this->addMessage('deleteSuccess'); + } } $this->redirect(['action' => 'index']); From 8a96e1998e2fd11e123e488522b0ac31c074cb2e Mon Sep 17 00:00:00 2001 From: blackcoder87 Date: Sat, 30 Nov 2024 17:25:08 +0100 Subject: [PATCH 2/4] Check if a config.php for that module exists --- .../modules/admin/controllers/admin/Modules.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/application/modules/admin/controllers/admin/Modules.php b/application/modules/admin/controllers/admin/Modules.php index 2d4ed74c6..9d9b6a935 100644 --- a/application/modules/admin/controllers/admin/Modules.php +++ b/application/modules/admin/controllers/admin/Modules.php @@ -421,14 +421,16 @@ public function uninstallAction() $key = $this->getRequest()->getParam('key'); if ($this->getRequest()->isSecure()) { - $configClass = '\\Modules\\' . ucfirst($key) . '\\Config\\Config'; - $config = new $configClass($this->getTranslator()); + if (file_exists(APPLICATION_PATH . '/modules/' . $key . '/config/config.php')) { + $configClass = '\\Modules\\' . ucfirst($key) . '\\Config\\Config'; + $config = new $configClass($this->getTranslator()); - if (!isset($config->config['system_module'])) { - $config->uninstall(); - $moduleMapper->delete($key); + if (!isset($config->config['system_module'])) { + $config->uninstall(); + $moduleMapper->delete($key); - $this->addMessage('deleteSuccess'); + $this->addMessage('deleteSuccess'); + } } } From 88096e0d2975454bad59f1a118512d5eb92f31c1 Mon Sep 17 00:00:00 2001 From: blackcoder87 Date: Sat, 30 Nov 2024 17:46:20 +0100 Subject: [PATCH 3/4] Check if layoutKey could be valid --- application/modules/admin/controllers/admin/Layouts.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/application/modules/admin/controllers/admin/Layouts.php b/application/modules/admin/controllers/admin/Layouts.php index e6f557a3a..c53c7443e 100644 --- a/application/modules/admin/controllers/admin/Layouts.php +++ b/application/modules/admin/controllers/admin/Layouts.php @@ -318,11 +318,18 @@ public function advSettingsAction() public function advSettingsShowAction() { $layoutKey = $this->getRequest()->getParam('layoutKey'); + + if (!$layoutKey || !file_exists(APPLICATION_PATH . '/layouts/' . $layoutKey . '/config/config.php')) { + $this->redirect() + ->to(['action' => 'advSettings']); + } + $this->getLayout()->getAdminHmenu() ->add($this->getTranslator()->trans('menuLayouts'), ['action' => 'index']) ->add($this->getTranslator()->trans('menuSettings'), ['action' => 'settings']) ->add($this->getTranslator()->trans('menuAdvSettings'), ['action' => 'advSettings']) ->add($this->getTranslator()->trans('menuAdvSettingsShow'), ['action' => 'advSettings', 'layoutKey' => $layoutKey]); + $settings = []; $layoutPath = APPLICATION_PATH . '/layouts/' . $layoutKey; if (is_dir($layoutPath)) { From 67b47b5cc4365d9572a505386b3a3f77d5434650 Mon Sep 17 00:00:00 2001 From: blackcoder87 Date: Sun, 1 Dec 2024 07:43:59 +0100 Subject: [PATCH 4/4] Add error messages and use correct error message for uninstall --- application/modules/admin/controllers/admin/Layouts.php | 1 + application/modules/admin/controllers/admin/Modules.php | 8 ++++++-- application/modules/admin/translations/de.php | 3 +++ application/modules/admin/translations/en.php | 3 +++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/application/modules/admin/controllers/admin/Layouts.php b/application/modules/admin/controllers/admin/Layouts.php index c53c7443e..106efbb4f 100644 --- a/application/modules/admin/controllers/admin/Layouts.php +++ b/application/modules/admin/controllers/admin/Layouts.php @@ -321,6 +321,7 @@ public function advSettingsShowAction() if (!$layoutKey || !file_exists(APPLICATION_PATH . '/layouts/' . $layoutKey . '/config/config.php')) { $this->redirect() + ->withMessage('layoutNotFoundOrInvalid', 'danger') ->to(['action' => 'advSettings']); } diff --git a/application/modules/admin/controllers/admin/Modules.php b/application/modules/admin/controllers/admin/Modules.php index 9d9b6a935..513ce314e 100644 --- a/application/modules/admin/controllers/admin/Modules.php +++ b/application/modules/admin/controllers/admin/Modules.php @@ -421,7 +421,7 @@ public function uninstallAction() $key = $this->getRequest()->getParam('key'); if ($this->getRequest()->isSecure()) { - if (file_exists(APPLICATION_PATH . '/modules/' . $key . '/config/config.php')) { + if ($key && file_exists(APPLICATION_PATH . '/modules/' . $key . '/config/config.php')) { $configClass = '\\Modules\\' . ucfirst($key) . '\\Config\\Config'; $config = new $configClass($this->getTranslator()); @@ -429,8 +429,12 @@ public function uninstallAction() $config->uninstall(); $moduleMapper->delete($key); - $this->addMessage('deleteSuccess'); + $this->addMessage('uninstallSuccess'); + } else { + $this->addMessage('uninstallDeniedSystemModule', 'danger'); } + } else { + $this->addMessage('moduleNotFoundOrInvalid', 'danger'); } } diff --git a/application/modules/admin/translations/de.php b/application/modules/admin/translations/de.php index 369a70f33..7e2ec9fe2 100644 --- a/application/modules/admin/translations/de.php +++ b/application/modules/admin/translations/de.php @@ -385,6 +385,8 @@ 'moduleUpdateFailed' => 'Modul konnte nicht aktualisiert werden.', 'downloadOrInstallDenied' => 'Aufgrund einer ungültigen Internetadresse wurde das Herunterladen oder Installieren des Updates nicht durchgeführt.', 'processingPleaseWait' => 'Verarbeite. Bitte warten.', + 'uninstallDeniedSystemModule' => 'Ein Systemmodul kann nicht deinstalliert werden.', + 'moduleNotFoundOrInvalid' => 'Modul nicht gefunden oder ungültig.', 'enableSelectedEntries' => 'Sollen die markierten Einträge wirklich freigeschaltet werden?', 'deleteSelectedEntries' => 'Sollen die markierten Einträge wirklich gelöscht werden?', @@ -434,6 +436,7 @@ 'menuAdvSettings' => 'Erweiterte Einstellungen', 'menuAdvSettingsShow' => 'Anzeige', 'noLayouts' => 'Keine Layouts mit erweiterten Einstellungen gefunden.', + 'layoutNotFoundOrInvalid' => 'Layout nicht gefunden oder ungültig.', 'orphanedSettings' => 'Es wurden Einstellungen für nicht vorhandene Layouts gefunden. Diese können unten gelöscht werden.', 'deleteOrphanedSettings' => 'Lösche verwaiste Einstellungen', ]; diff --git a/application/modules/admin/translations/en.php b/application/modules/admin/translations/en.php index 8246e23b5..349ee3106 100644 --- a/application/modules/admin/translations/en.php +++ b/application/modules/admin/translations/en.php @@ -385,6 +385,8 @@ 'moduleUpdateFailed' => 'The update of the module failed.', 'downloadOrInstallDenied' => 'Due to an invalid web address the update was not downloaded or installed.', 'processingPleaseWait' => 'Processing. Please wait.', + 'uninstallDeniedSystemModule' => 'An system module cannot be uninstalled.', + 'moduleNotFoundOrInvalid' => 'Module not found or invalid.', 'enableSelectedEntries' => 'Enable the selected entries?', 'deleteSelectedEntries' => 'Delete the selected entries?', @@ -434,6 +436,7 @@ 'menuAdvSettings' => 'Advanced Settings', 'menuAdvSettingsShow' => 'Show', 'noLayouts' => 'No layouts with advanced settings found.', + 'layoutNotFoundOrInvalid' => 'Layout not found or invalid.', 'orphanedSettings' => 'Settings have been found for not existing layouts. These can be deleted below.', 'deleteOrphanedSettings' => 'Delete orphaned settings', ];