Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not try to uninstall a system module and check module and layout key #1128

Merged
merged 4 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions application/modules/admin/controllers/admin/Layouts.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,19 @@ public function advSettingsAction()
public function advSettingsShowAction()
{
$layoutKey = $this->getRequest()->getParam('layoutKey');

if (!$layoutKey || !file_exists(APPLICATION_PATH . '/layouts/' . $layoutKey . '/config/config.php')) {
$this->redirect()
->withMessage('layoutNotFoundOrInvalid', 'danger')
->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)) {
Expand Down
20 changes: 14 additions & 6 deletions application/modules/admin/controllers/admin/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -422,12 +421,21 @@ public function uninstallAction()
$key = $this->getRequest()->getParam('key');

if ($this->getRequest()->isSecure()) {
$configClass = '\\Modules\\' . ucfirst($key) . '\\Config\\Config';
$config = new $configClass($this->getTranslator());
$config->uninstall();
$moduleMapper->delete($key);
if ($key && file_exists(APPLICATION_PATH . '/modules/' . $key . '/config/config.php')) {
$configClass = '\\Modules\\' . ucfirst($key) . '\\Config\\Config';
$config = new $configClass($this->getTranslator());

$this->addMessage('deleteSuccess');
if (!isset($config->config['system_module'])) {
$config->uninstall();
$moduleMapper->delete($key);

$this->addMessage('uninstallSuccess');
} else {
$this->addMessage('uninstallDeniedSystemModule', 'danger');
}
} else {
$this->addMessage('moduleNotFoundOrInvalid', 'danger');
}
}

$this->redirect(['action' => 'index']);
Expand Down
3 changes: 3 additions & 0 deletions application/modules/admin/translations/de.php
Original file line number Diff line number Diff line change
Expand Up @@ -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?',
Expand Down Expand Up @@ -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',
];
3 changes: 3 additions & 0 deletions application/modules/admin/translations/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -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?',
Expand Down Expand Up @@ -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',
];