mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-02-01 16:36:45 +01:00
Fix possibilità di caricare allegati anche per i plugin
This commit is contained in:
parent
2cab589d83
commit
473fe4d8d0
14
actions.php
14
actions.php
@ -40,17 +40,12 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
|
||||
// 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
|
||||
@ -173,8 +168,6 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
|
||||
} while (file_exists($upload_dir.'/'.$filename));
|
||||
|
||||
|
||||
|
||||
|
||||
// Creazione file fisico
|
||||
if (move_uploaded_file($src, $upload_dir.'/'.$filename)) {
|
||||
|
||||
@ -186,6 +179,11 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
|
||||
'id_record' => $id_record,
|
||||
'id_plugin' => $id_plugin,
|
||||
]);
|
||||
|
||||
/*$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 {
|
||||
@ -219,7 +217,7 @@ if (filter('op') == 'link_file' || filter('op') == 'unlink_file') {
|
||||
}
|
||||
}
|
||||
|
||||
redirect(ROOTDIR.'/editor.php?id_module='.$id_module.'&id_record='.$id_record);
|
||||
redirect(ROOTDIR.'/editor.php?id_module='.$id_module.'&id_record='.$id_record.((!empty($options['id_plugin'])) ? '#tab_'.$options['id_plugin'] : ''));
|
||||
}
|
||||
} elseif (filter('op') == 'download_file') {
|
||||
$rs = $dbo->fetchArray('SELECT * FROM zz_files WHERE id_module='.prepare($id_module).' AND id='.prepare(filter('id')).' AND filename='.prepare(filter('filename')));
|
||||
|
@ -81,7 +81,7 @@ class FileManager implements ManagerInterface
|
||||
</div>
|
||||
|
||||
<div class="col-lg-2 text-right">
|
||||
<button type="button" class="btn btn-success" onclick="saveFile_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').'();">
|
||||
<button type="button" class="btn btn-success" onclick="saveFile_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').' ( $(this) );">
|
||||
<i class="fa fa-upload"></i> '.tr('Carica').'
|
||||
</button>
|
||||
</div>
|
||||
@ -89,7 +89,7 @@ class FileManager implements ManagerInterface
|
||||
|
||||
$result .= '
|
||||
<script>
|
||||
function saveFile_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').'(){
|
||||
function saveFile_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').' (btn){
|
||||
if(!$("#blob_'.$options['id_record'].((!empty($options['id_plugin'])) ? '_'.$options['id_plugin'] : '').'").val()){
|
||||
swal("'.addslashes(tr('Attenzione!')).'", "'.addslashes(tr('Devi selezionare un file con il tasto "Sfoglia"')).'...", "warning");
|
||||
return false;
|
||||
@ -104,7 +104,9 @@ class FileManager implements ManagerInterface
|
||||
form_data.append("id_module", "'.$options['id_module'].'");
|
||||
form_data.append("id_plugin","'.$options['id_plugin'].'");
|
||||
|
||||
$("#main_loading").fadeIn();
|
||||
prev_html = btn.html();
|
||||
btn.html("<i class=\"fa fa-spinner fa-pulse fa-fw\"></i>'.tr("Attendere...").'");
|
||||
btn.prop("disabled", true);
|
||||
|
||||
$.ajax({
|
||||
url: "'.ROOTDIR.'/actions.php",
|
||||
@ -115,6 +117,10 @@ class FileManager implements ManagerInterface
|
||||
dataType : "html",
|
||||
data: form_data,
|
||||
success: function(data) {
|
||||
|
||||
btn.html(prev_html);
|
||||
btn.prop("disabled", false);
|
||||
|
||||
location.href = globals.rootdir + "/editor.php?id_module='.$options['id_module'].'&id_record='.$options['id_record'].((!empty($options['id_plugin'])) ? '#tab_'.$options['id_plugin'] : '').'";
|
||||
},
|
||||
error: function(data) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user