From 74a4ea3d1276ae69b90a1a7b3c56909e859afdc0 Mon Sep 17 00:00:00 2001 From: MatteoPistorello Date: Fri, 27 May 2022 11:50:28 +0200 Subject: [PATCH] Miglioramenti aggiornamento da zip --- modules/aggiornamenti/upload_modules.php | 44 ++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/modules/aggiornamenti/upload_modules.php b/modules/aggiornamenti/upload_modules.php index 800933369..465dcbca6 100755 --- a/modules/aggiornamenti/upload_modules.php +++ b/modules/aggiornamenti/upload_modules.php @@ -52,9 +52,9 @@ if (file_exists($extraction_dir.'/VERSION')) { ->ignoreVCS(true) ->in($extraction_dir); - $files = $finder->name('MODULE')->name('PLUGIN')->name('TEMPLATES'); + $files_module = $finder->name('MODULE'); - foreach ($files as $file) { + foreach ($files_module as $file) { // Informazioni dal file di configurazione $info = Util\Ini::readFile($file->getRealPath()); @@ -71,8 +71,46 @@ if (file_exists($extraction_dir.'/VERSION')) { $insert['icon'] = $info['icon']; } + // Copia dei file nella cartella relativa + copyr(dirname($file->getRealPath()), base_dir().'/'.$directory.'/'.$info['directory']); + + // Eventuale registrazione nel database + if (empty($installed)) { + $dbo->insert($table, array_merge($insert, [ + 'name' => $info['name'], + 'title' => !empty($info['title']) ? $info['title'] : $info['name'], + 'directory' => $info['directory'], + 'options' => $info['options'], + 'version' => $info['version'], + 'compatibility' => $info['compatibility'], + 'order' => 100, + 'default' => 0, + 'enabled' => 1, + ])); + + flash()->error(tr('Installazione completata!')); + } else { + flash()->error(tr('Aggiornamento completato!')); + } + } + + $finder = Symfony\Component\Finder\Finder::create() + ->files() + ->ignoreDotFiles(true) + ->ignoreVCS(true) + ->in($extraction_dir); + + $files_plugin_template = $finder->name('PLUGIN')->name('TEMPLATES'); + + foreach ($files_plugin_template as $file) { + // Informazioni dal file di configurazione + $info = Util\Ini::readFile($file->getRealPath()); + + // Informazioni aggiuntive per il database + $insert = []; + // Plugin - elseif (basename($file->getRealPath()) == 'PLUGIN') { + if (basename($file->getRealPath()) == 'PLUGIN') { $directory = 'plugins'; $table = 'zz_plugins';