diff --git a/actions.php b/actions.php index d442d4b27..05e80c3e0 100644 --- a/actions.php +++ b/actions.php @@ -39,13 +39,12 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') { else { // UPLOAD if (filter('op') == 'link_file' && !empty($_FILES) && !empty($_FILES['blob']['name'])) { - $nome = filter('nome_allegato'); $nome = !empty($nome) ? $nome : $_FILES['blob']['name']; - + $src = $_FILES['blob']['tmp_name']; $f = pathinfo($_FILES['blob']['name']); - + /* $allowed = [ // Image formats @@ -166,25 +165,18 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') { do { $filename = random_string().'.'.$f['extension']; } while (file_exists($upload_dir.'/'.$filename)); - - + // Creazione file fisico if (move_uploaded_file($src, $upload_dir.'/'.$filename)) { - - $dbo->insert('zz_files', [ + $dbo->insert('zz_files', [ 'nome' => $nome, 'filename' => $filename, 'original' => $_FILES['blob']['name'], 'id_module' => $id_module, 'id_record' => $id_record, - 'id_plugin' => $id_plugin, + 'id_plugin' => !empty($id_plugin) ? $id_plugin : null, ]); - /*$dbo->query('INSERT INTO zz_files(nome, filename, original, id_module, id_record, id_plugin) VALUES('.prepare($nome).','.prepare($filename).',"'.$_FILES['blob']['name'].'",'.prepare($id_module).','.prepare($id_record).','.prepare($id_plugin).')'); - - echo 'INSERT INTO zz_files(nome, filename, original, id_module, id_record, id_plugin) VALUES('.prepare($nome).','.prepare($filename).',"'.$_FILES['blob']['name'].'",'.prepare($id_module).','.prepare($id_record).','.prepare($id_plugin).')'; - exit;*/ - $_SESSION['infos'][] = tr('File caricato correttamente!'); } else { $_SESSION['errors'][] = tr('Errore durante il caricamento del file!'); diff --git a/src/HTMLBuilder/Manager/FileManager.php b/src/HTMLBuilder/Manager/FileManager.php index 38105a467..350261599 100644 --- a/src/HTMLBuilder/Manager/FileManager.php +++ b/src/HTMLBuilder/Manager/FileManager.php @@ -9,26 +9,24 @@ namespace HTMLBuilder\Manager; */ class FileManager implements ManagerInterface { - - /** - * Gestione "filelist_and_upload". + /** + * Gestione "filelist_and_upload". * Esempio: {( "name": "filelist_and_upload", "id_module": "2", "id_record": "1", "readonly": "false", "ajax": "true" )}. * * @param array $options * * @return string */ - public function manage($options) { - $options['readonly'] = ($options['readonly']=='true') ? true : false; + $options['readonly'] = ($options['readonly'] == 'true') ? true : false; $options['ajax'] = isset($options['ajax']) ? $options['ajax'] : false; - $options['showpanel'] = isset($options['showpanel']) ? $options['showpanel'] : true; + $options['showpanel'] = isset($options['showpanel']) ? $options['showpanel'] : true; $options['label'] = isset($options['label']) ? $options['label'] : tr('Nuovo allegato').':'; $dbo = \Database::getConnection(); -$result .= ' + $result .= '