From 77526c63ce7db2b71f4f2b1082d5a0df79b1f14a Mon Sep 17 00:00:00 2001 From: pek5892 Date: Wed, 12 Jun 2024 12:27:03 +0200 Subject: [PATCH] Fix installazione plugins --- modules/aggiornamenti/upload_modules.php | 71 +++++++++++++++++------- 1 file changed, 52 insertions(+), 19 deletions(-) diff --git a/modules/aggiornamenti/upload_modules.php b/modules/aggiornamenti/upload_modules.php index 56393891f..dc8f3ca40 100755 --- a/modules/aggiornamenti/upload_modules.php +++ b/modules/aggiornamenti/upload_modules.php @@ -144,26 +144,59 @@ if (file_exists($extraction_dir.'/VERSION')) { copyr(dirname($file->getRealPath()), base_dir().'/'.$directory.'/'.$info['directory']); // Eventuale registrazione nel database - if (empty($installed)) { - $dbo->insert($table, array_merge($insert, [ - 'directory' => $info['directory'], - 'name' => $info['name'], - 'options' => $info['options'], - 'version' => $info['version'], - 'compatibility' => $info['compatibility'], - 'order' => 100, - 'default' => 0, - 'enabled' => 1, - ])); - $id_record = $dbo->lastInsertedID(); - $dbo->insert($table.'_lang', array_merge($insert_lang, [ - 'title' => !empty($info['title']) ? $info['title'] : $info['name'], - 'id_record' => $id_record, - 'id_lang' => Models\Locale::getDefault()->id, - ])); - flash()->error(tr('Installazione completata!')); + if (basename($file->getRealPath()) == 'PLUGIN') { + if (empty($installed)) { + $dbo->insert($table, array_merge($insert, [ + 'directory' => $info['directory'], + 'name' => $info['name'], + 'options' => $info['options'], + 'idmodule_from' => $insert['idmodule_from'], + 'idmodule_to' => $insert['idmodule_to'], + 'position' => $insert['position'], + 'version' => $info['version'], + 'compatibility' => $info['compatibility'], + 'order' => 100, + 'default' => 0, + 'enabled' => 1, + ])); + $id_record = $dbo->lastInsertedID(); + $dbo->insert($table.'_lang', array_merge($insert_lang, [ + 'title' => !empty($info['title']) ? $info['title'] : $info['name'], + 'id_record' => $id_record, + 'id_lang' => Models\Locale::getDefault()->id, + ])); + flash()->error(tr('Installazione completata!')); + } else { + + flash()->error(tr('Aggiornamento completato!')); + } } else { - flash()->error(tr('Aggiornamento completato!')); + if (empty($installed)) { + $dbo->insert($table, array_merge($insert, [ + 'directory' => $info['directory'], + 'name' => $info['name'], + 'options' => $info['options'], + 'version' => $info['version'], + 'compatibility' => $info['compatibility'], + 'id_module' => $insert['id_module'], + 'is_record' => $insert['is_record'], + 'icon' => $insert['icon'], + 'filename' => $insert_lang['filename'], + 'order' => 100, + 'default' => 0, + 'enabled' => 1, + ])); + $id_record = $dbo->lastInsertedID(); + $dbo->insert($table.'_lang', array_merge($insert_lang, [ + 'title' => !empty($info['title']) ? $info['title'] : $info['name'], + 'id_record' => $id_record, + 'id_lang' => Models\Locale::getDefault()->id, + ])); + flash()->error(tr('Installazione completata!')); + } else { + + flash()->error(tr('Aggiornamento completato!')); + } } } }