diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index e500c5e8804..bd68b50b445 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -27,6 +27,7 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/member.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"); @@ -77,7 +78,16 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) $resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']); if (is_numeric($resupload) && $resupload > 0) { - $mesg = '
'.$langs->trans("FileTransferComplete").'
'; + if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) + { + // Create small thumbs for image (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs"); + } + $mesg = '
'.$langs->trans("FileTransferComplete").'
'; } else { @@ -101,9 +111,10 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) // Suppression fichier if ($action == 'confirm_deletefile' && $confirm == 'yes') { - $file = $upload_dir . "/" . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $langs->load("other"); + $file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file); - $mesg = '
'.$langs->trans("FileWasRemoved").'
'; + $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; } diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index b09e8da9d4a..18c0273ed89 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -147,7 +147,8 @@ if (! empty($_POST['removedfile']) || ! empty($_POST['removedfilehtml'])) $result = dol_delete_file($pathtodelete,1); if ($result >= 0) { - $message = '
'.$langs->trans("FileWasRemoved",$filetodelete).'
'; + $langs->load("other"); + $message = '
'.$langs->trans("FileWasRemoved",$filetodelete).'
'; //print_r($_FILES); include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'); diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index aeb71f91b80..448ba78d158 100755 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -31,6 +31,7 @@ require_once(DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"); require_once(DOL_DOCUMENT_ROOT."/comm/action/class/cactioncomm.class.php"); require_once(DOL_DOCUMENT_ROOT."/comm/action/class/actioncomm.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); @@ -67,8 +68,6 @@ if (! $sortfield) $sortfield="name"; */ if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - // Creation repertoire si n'existe pas $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($objectid); @@ -77,7 +76,16 @@ if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) $resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']); if (is_numeric($resupload) && $resupload > 0) { - $mesg = '
'.$langs->trans("FileTransferComplete").'
'; + if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) + { + // Create small thumbs for image (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs"); + } + $mesg = '
'.$langs->trans("FileTransferComplete").'
'; } else { diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index d7dcaa4c548..a55a407b71b 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -28,6 +28,7 @@ require("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propal.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/propal.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); $langs->load('compta'); @@ -77,7 +78,16 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) $resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']); if (is_numeric($resupload) && $resupload > 0) { - $mesg = '
'.$langs->trans("FileTransferComplete").'
'; + if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) + { + // Create small thumbs for image (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs"); + } + $mesg = '
'.$langs->trans("FileTransferComplete").'
'; } else { @@ -104,12 +114,13 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') { if ($object->fetch($id)) { - $object->fetch_thirdparty(); + $langs->load("other"); + $object->fetch_thirdparty(); $upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); - $file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file,0,0,0,$object); - $mesg = '
'.$langs->trans("FileWasRemoved").'
'; + $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; } } diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 58cbe37ede0..f5d9ba94e7e 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -27,6 +27,7 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); require_once(DOL_DOCUMENT_ROOT ."/commande/class/commande.class.php"); @@ -80,7 +81,16 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) $resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']); if (is_numeric($resupload) && $resupload > 0) { - $mesg = '
'.$langs->trans("FileTransferComplete").'
'; + if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) + { + // Create small thumbs for image (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs"); + } + $mesg = '
'.$langs->trans("FileTransferComplete").'
'; } else { @@ -107,12 +117,13 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') { if ($object->fetch($id)) { - $object->fetch_thirdparty(); + $langs->load("other"); + $object->fetch_thirdparty(); $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); - $file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file,0,0,0,$object); - $mesg = '
'.$langs->trans("FileWasRemoved").'
'; + $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; } } diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 3008771d340..7b7605a63dc 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -476,11 +476,11 @@ else if ($action == 'setconditions' && $user->rights->commande->creer) $object->fetch($id); $result=$object->setPaymentTerms(GETPOST('cond_reglement_id','int')); if ($result < 0) - { + { dol_print_error($db,$object->error); } else - { + { if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { // Define output language @@ -496,7 +496,7 @@ else if ($action == 'setconditions' && $user->rights->commande->creer) $ret=$object->fetch($id); // Reload to get new records commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref, $hookmanager); } - } + } } else if ($action == 'setremisepercent' && $user->rights->commande->creer) @@ -1028,10 +1028,11 @@ else if ($action == 'remove_file') { require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); + $langs->load("other"); $upload_dir = $conf->commande->dir_output; - $file = $upload_dir . '/' . $_GET['file']; + $file = $upload_dir . '/' . GETPOST('file'); dol_delete_file($file); - $mesg = '
'.$langs->trans("FileWasRemoved").'
'; + $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('file')).'
'; } } diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 6a940988dfc..d3048dcfd11 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -29,6 +29,7 @@ require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); require_once(DOL_DOCUMENT_ROOT.'/core/class/discount.class.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/invoice.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); $langs->load('propal'); @@ -82,7 +83,16 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) $resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']); if (is_numeric($resupload) && $resupload > 0) { - $mesg = '
'.$langs->trans("FileTransferComplete").'
'; + if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) + { + // Create small thumbs for image (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs"); + } + $mesg = '
'.$langs->trans("FileTransferComplete").'
'; } else { @@ -109,12 +119,13 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') { if ($object->fetch($id)) { + $langs->load("other"); $object->fetch_thirdparty(); $upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref); - $file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file,0,0,0,$object); - $mesg = '
'.$langs->trans("FileWasRemoved").'
'; + $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; } } diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index 3261fab405a..82962f224eb 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -73,8 +73,6 @@ $modulepart='tax'; if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC)) { - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - if (dol_mkdir($upload_dir) >= 0) { $resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']); @@ -82,11 +80,10 @@ if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC)) { if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) { - // Create small thumbs for company (Ratio is near 16/9) + // Create small thumbs for image (Ratio is near 16/9) // Used on logon for example $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs"); - - // Create mini thumbs for company (Ratio is near 16/9) + // Create mini thumbs for image (Ratio is near 16/9) // Used on menu or for setup page for example $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs"); } diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index cb270c042d8..ea04ce4e33f 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -29,6 +29,7 @@ require ("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/contract.lib.php"); require_once(DOL_DOCUMENT_ROOT."/contrat/class/contrat.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); $langs->load("other"); @@ -69,13 +70,20 @@ $modulepart='contract'; */ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - if (dol_mkdir($upload_dir) >= 0) { $resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']); if (is_numeric($resupload) && $resupload > 0) { + if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) + { + // Create small thumbs for image (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs"); + } $mesg = '
'.$langs->trans("FileTransferComplete").'
'; } else diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 472e99cb05e..1723b443e4b 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -504,9 +504,11 @@ class FormFile if ($delallowed) { - $out.= ''; + //$out.= ''; } diff --git a/htdocs/document.php b/htdocs/document.php index 6c8c7c59c7f..91a4c8c714e 100644 --- a/htdocs/document.php +++ b/htdocs/document.php @@ -483,7 +483,7 @@ if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file)) exit; } - +/* if ($action == 'remove_file') // Remove a file { clearstatcache(); @@ -508,7 +508,7 @@ if ($action == 'remove_file') // Remove a file return; } else // Open and return file -{ +{*/ clearstatcache(); $filename = basename($original_file); @@ -540,6 +540,6 @@ else // Open and return file //flush(); readfile($original_file_osencoded); -} +//} ?> diff --git a/htdocs/ecm/docmine.php b/htdocs/ecm/docmine.php index e75a0903a28..55db3ddb284 100644 --- a/htdocs/ecm/docmine.php +++ b/htdocs/ecm/docmine.php @@ -73,8 +73,6 @@ $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; // Upload file if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC)) { - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - if (dol_mkdir($upload_dir) >= 0) { $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']); @@ -110,12 +108,13 @@ if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC)) // Remove file if (GETPOST('action') == 'confirm_deletefile' && GETPOST('confirm') == 'yes') { - $file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). - $result=dol_delete_file($file); + $langs->load("other"); + $file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $result=dol_delete_file($file); - $mesg = '
'.$langs->trans("FileWasRemoved").'
'; + $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; - $result=$ecmdir->changeNbOfFiles('-'); + $result=$ecmdir->changeNbOfFiles('-'); } // Remove dir diff --git a/htdocs/ecm/docother.php b/htdocs/ecm/docother.php index a6c17e2b45e..c07a4d799a7 100644 --- a/htdocs/ecm/docother.php +++ b/htdocs/ecm/docother.php @@ -43,8 +43,6 @@ $upload_dir = $conf->ecm->dir_output.'/'.$section; // Envoie fichier if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - if (dol_mkdir($upload_dir) >= 0) { $resupload = dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']); @@ -80,9 +78,10 @@ if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) // Suppression fichier if ($_POST['action'] == 'confirm_deletefile' && $_POST['confirm'] == 'yes') { - $file = $upload_dir . "/" . urldecode($_GET["urlfile"]); + $langs->load("other"); + $file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file); - $mesg = '
'.$langs->trans("FileWasRemoved").'
'; + $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; } diff --git a/htdocs/ecm/index.php b/htdocs/ecm/index.php index 41ecb945509..9eac55e9fc9 100644 --- a/htdocs/ecm/index.php +++ b/htdocs/ecm/index.php @@ -154,6 +154,7 @@ if ($action == 'confirm_deletefile') { if (GETPOST('confirm') == 'yes') { + $langs->load("other"); $result=$ecmdir->fetch($section); if (! $result > 0) { @@ -166,7 +167,7 @@ if ($action == 'confirm_deletefile') $result=dol_delete_file($file); - $mesg = '
'.$langs->trans("FileWasRemoved").'
'; + $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; $result=$ecmdir->changeNbOfFiles('-'); diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php index a25f5cfdea7..4a04ef2a564 100644 --- a/htdocs/fourn/commande/document.php +++ b/htdocs/fourn/commande/document.php @@ -27,6 +27,7 @@ require("../../main.inc.php"); require_once(DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/fourn.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); require_once DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.commande.class.php"; @@ -74,8 +75,6 @@ if ($commande->fetch($_GET['id'],$_GET['ref']) < 0) // Envoi fichier if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - $upload_dir = $conf->fournisseur->dir_output . "/commande/" . dol_sanitizeFileName($commande->ref); if (dol_mkdir($upload_dir) >= 0) @@ -83,6 +82,15 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) $resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']); if (is_numeric($resupload) && $resupload > 0) { + if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) + { + // Create small thumbs for image (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs"); + } $mesg = '
'.$langs->trans("FileTransferComplete").'
'; } else @@ -107,10 +115,11 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) // Delete if ($action=='delete') { + $langs->load("other"); $upload_dir = $conf->fournisseur->dir_output . "/commande/" . dol_sanitizeFileName($commande->ref); - $file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file); - $mesg = '
'.$langs->trans("FileWasRemoved").'
'; + $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; } diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index e8fd1a83ef3..7389ee51129 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -604,10 +604,11 @@ else if ($action == 'remove_file' && $user->rights->fournisseur->commande->creer if ($object->fetch($id)) { + $langs->load("other"); $upload_dir = $conf->fournisseur->commande->dir_output . "/"; - $file = $upload_dir . '/' . $_GET['file']; + $file = $upload_dir . '/' . GETPOST('file'); dol_delete_file($file); - $mesg = '
'.$langs->trans("FileWasRemoved").'
'; + $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('file')).'
'; } } diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index 30b33678e9f..5a0e20cf31b 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -78,6 +78,15 @@ if ($_POST['sendit'] && ! empty($conf->global->MAIN_UPLOAD_DOC)) $resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']); if (is_numeric($resupload) && $resupload > 0) { + if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) + { + // Create small thumbs for image (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs"); + } $mesg = '
'.$langs->trans("FileTransferComplete").'
'; } else @@ -108,12 +117,13 @@ if ($action=='delete') $facture = new FactureFournisseur($db); if ($facture->fetch($facid)) { + $langs->load("other"); $ref=dol_sanitizeFileName($facture->ref); $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($facture->id,2).$ref; - $file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file); - $mesg = '
'.$langs->trans('FileWasRemoved').'
'; + $mesg = '
'.$langs->trans('FileWasRemoved',GETPOST('urlfile')).'
'; } } diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index be0b0acd31b..ad133547fbc 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -419,7 +419,7 @@ elseif ($action == 'update_line') $pu=$_POST['puttc']; $price_base_type='TTC'; } - + if ($_POST['idprod']) { $prod = new Product($db); @@ -431,12 +431,12 @@ elseif ($action == 'update_line') } else { - + $label = $_POST['desc']; $type = $_POST["type"]?$_POST["type"]:0; } - + $localtax1tx= get_localtax($_POST['tauxtva'], 1, $object->thirdparty); $localtax2tx= get_localtax($_POST['tauxtva'], 2, $object->thirdparty); @@ -828,9 +828,9 @@ elseif ($action == 'remove_file') if ($object->fetch($id)) { $upload_dir = $conf->fournisseur->facture->dir_output . "/"; - $file = $upload_dir . '/' . $_GET['file']; + $file = $upload_dir . '/' . GETPOST('file'); dol_delete_file($file); - $mesg = '
'.$langs->trans("FileWasRemoved").'
'; + $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('file')).'
'; } } diff --git a/htdocs/ftp/index.php b/htdocs/ftp/index.php index c37014a5517..9849671f5d0 100644 --- a/htdocs/ftp/index.php +++ b/htdocs/ftp/index.php @@ -161,6 +161,8 @@ if ($_REQUEST['action'] == 'confirm_deletefile' && $_REQUEST['confirm'] == 'yes' if ($conn_id && $ok && ! $mesg) { + $langs->load("other"); + // Remote file $filename=$file; $remotefile=$section.(preg_match('@[\\\/]$@',$section)?'':'/').$file; @@ -208,6 +210,8 @@ if ($_POST["const"] && $_POST["delete"] && $_POST["delete"] == $langs->trans("De { if ($const["check"]) // Is checkbox checked { + $langs->load("other"); + // Remote file $file=$const["file"]; $section=$const["section"]; diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 4450c318467..e56b520ef7a 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -28,6 +28,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); require_once(DOL_DOCUMENT_ROOT."/imports/class/import.class.php"); require_once(DOL_DOCUMENT_ROOT.'/core/modules/import/modules_import.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/import.lib.php"); $langs->load("exports"); @@ -191,8 +192,6 @@ if ($action == 'add_import_model') if ($step == 3 && $datatoimport) { - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - if ( $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { dol_mkdir($conf->import->dir_temp); diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 7af3740e054..30ea8211eca 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -619,6 +619,8 @@ ByMonth=by month ByDay=By day BySalesRepresentative=By sales representative LinkedToSpecificUsers=Linked to a particular user contact +DeleteAFile=Delete a file +ConfirmDeleteAFile=Are you sure you want to delete file # Week day Monday=Monday diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 7e07d70890b..d298b043532 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -621,6 +621,8 @@ ByMonth=Par mois ByDay=Par jour BySalesRepresentative=Par commerciaux LinkedToSpecificUsers=Liés à un contact utilisateur particulier +DeleteAFile=Suppression de fichier +ConfirmDeleteAFile=Confirmez-vous la suppression du fichier # Week day Monday=Lundi diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 6d496d689a2..cf5835e1c3a 100755 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -29,6 +29,7 @@ require('../main.inc.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/product.lib.php"); require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); $langs->load("other"); @@ -73,14 +74,21 @@ $modulepart='produit'; if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - if (dol_mkdir($upload_dir) >= 0) { $resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']); if (is_numeric($resupload) && $resupload > 0) { - $mesg = '
'.$langs->trans("FileTransferComplete").'
'; + if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) + { + // Create small thumbs for image (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs"); + } + $mesg = '
'.$langs->trans("FileTransferComplete").'
'; } else { diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index f66c62b1b5e..77602350540 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -26,6 +26,7 @@ require('../main.inc.php'); require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); $langs->load('projects'); @@ -70,8 +71,6 @@ if (! $sortfield) $sortfield="name"; // Envoi fichier if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($project->ref); if (dol_mkdir($upload_dir) >= 0) @@ -79,6 +78,15 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) $resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']); if (is_numeric($resupload) && $resupload > 0) { + if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) + { + // Create small thumbs for image (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs"); + } $mesg = '
'.$langs->trans("FileTransferComplete").'
'; } else @@ -103,10 +111,11 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) // Delete if ($action == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && $user->rights->projet->supprimer) { + $langs->load("other"); $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($project->ref); - $file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file); - $mesg = '
'.$langs->trans("FileWasRemoved").'
'; + $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; } diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php index efa3290e2ef..d72cf2d8dba 100644 --- a/htdocs/projet/fiche.php +++ b/htdocs/projet/fiche.php @@ -43,11 +43,11 @@ if ($id == '' && $ref == '' && ($action != "create" && $action != "add" && $acti $mine = GETPOST('mode')=='mine' ? 1 : 0; //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects -$project = new Project($db); +$object = new Project($db); if ($ref) { - $project->fetch(0,$ref); - $id=$project->id; + $object->fetch(0,$ref); + $id=$object->id; } // Security check @@ -67,9 +67,8 @@ if (GETPOST("cancel") && ! empty($backtopage)) { if (GETPOST("comefromclone")==1) { - $project = new Project($db); - $project->fetch($id); - $result=$project->delete($user); + $object->fetch($id); + $result=$object->delete($user); if ($result > 0) { Header("Location: index.php"); @@ -77,7 +76,7 @@ if (GETPOST("cancel") && ! empty($backtopage)) } else { - dol_syslog($project->error,LOG_DEBUG); + dol_syslog($object->error,LOG_DEBUG); $mesg='
'.$langs->trans("CantRemoveProject").'
'; } } @@ -88,9 +87,8 @@ if (GETPOST("cancel") && ! empty($backtopage)) //if cancel and come from clone then delete the cloned project if (GETPOST("cancel") && (GETPOST("comefromclone")==1)) { - $project = new Project($db); - $project->fetch($id); - $result=$project->delete($user); + $object->fetch($id); + $result=$object->delete($user); if ($result > 0) { Header("Location: index.php"); @@ -98,7 +96,7 @@ if (GETPOST("cancel") && (GETPOST("comefromclone")==1)) } else { - dol_syslog($project->error,LOG_DEBUG); + dol_syslog($object->error,LOG_DEBUG); $mesg='
'.$langs->trans("CantRemoveProject").'
'; } } @@ -123,31 +121,31 @@ if ($action == 'add' && $user->rights->projet->creer) $db->begin(); - $project->ref = GETPOST('ref','alpha'); - $project->title = GETPOST('title','alpha'); - $project->socid = GETPOST('socid','int'); - $project->description = GETPOST('description','alpha'); - $project->public = GETPOST('public','alpha'); - $project->datec=dol_now(); - $project->date_start=dol_mktime(0,0,0,GETPOST('projectmonth','int'),GETPOST('projectday','int'),GETPOST('projectyear','int')); - $project->date_end=dol_mktime(0,0,0,GETPOST('projectendmonth','int'),GETPOST('projectendday','int'),GETPOST('projectendyear','int')); + $object->ref = GETPOST('ref','alpha'); + $object->title = GETPOST('title','alpha'); + $object->socid = GETPOST('socid','int'); + $object->description = GETPOST('description','alpha'); + $object->public = GETPOST('public','alpha'); + $object->datec=dol_now(); + $object->date_start=dol_mktime(0,0,0,GETPOST('projectmonth','int'),GETPOST('projectday','int'),GETPOST('projectyear','int')); + $object->date_end=dol_mktime(0,0,0,GETPOST('projectendmonth','int'),GETPOST('projectendday','int'),GETPOST('projectendyear','int')); - $result = $project->create($user); + $result = $object->create($user); if ($result > 0) { // Add myself as project leader - $result = $project->add_contact($user->id, 'PROJECTLEADER', 'internal'); + $result = $object->add_contact($user->id, 'PROJECTLEADER', 'internal'); if ($result < 0) { $langs->load("errors"); - $mesg='
'.$langs->trans($project->error).'
'; + $mesg='
'.$langs->trans($object->error).'
'; $error++; } } else { $langs->load("errors"); - $mesg='
'.$langs->trans($project->error).'
'; + $mesg='
'.$langs->trans($object->error).'
'; $error++; } @@ -155,7 +153,7 @@ if ($action == 'add' && $user->rights->projet->creer) { $db->commit(); - Header("Location:fiche.php?id=".$project->id); + Header("Location:fiche.php?id=".$object->id); exit; } else @@ -189,29 +187,29 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer) } if (! $error) { - $project->fetch($id); + $object->fetch($id); - $old_start_date = $project->date_start; + $old_start_date = $object->date_start; - $project->ref = GETPOST('ref','alpha'); - $project->title = GETPOST('title','alpha'); - $project->socid = GETPOST('socid','int'); - $project->description = GETPOST('description','alpha'); - $project->public = GETPOST('public','alpha'); - $project->date_start = empty($_POST["project"])?'':dol_mktime(0,0,0,GETPOST('projectmonth'),GETPOST('projectday'),GETPOST('projectyear')); - $project->date_end = empty($_POST["projectend"])?'':dol_mktime(0,0,0,GETPOST('projectendmonth'),GETPOST('projectendday'),GETPOST('projectendyear')); + $object->ref = GETPOST('ref','alpha'); + $object->title = GETPOST('title','alpha'); + $object->socid = GETPOST('socid','int'); + $object->description = GETPOST('description','alpha'); + $object->public = GETPOST('public','alpha'); + $object->date_start = empty($_POST["project"])?'':dol_mktime(0,0,0,GETPOST('projectmonth'),GETPOST('projectday'),GETPOST('projectyear')); + $object->date_end = empty($_POST["projectend"])?'':dol_mktime(0,0,0,GETPOST('projectendmonth'),GETPOST('projectendday'),GETPOST('projectendyear')); - $result=$project->update($user); + $result=$object->update($user); - $id=$project->id; // On retourne sur la fiche projet + $id=$object->id; // On retourne sur la fiche projet - if (GETPOST("reportdate") && ($project->date_start!=$old_start_date)) + if (GETPOST("reportdate") && ($object->date_start!=$old_start_date)) { - $result=$project->shiftTaskDate($old_start_date); + $result=$object->shiftTaskDate($old_start_date); if (!$result) { $error++; - $mesg='
'.$langs->trans("ErrorShiftTaskDate").':'.$project->error.'
'; + $mesg='
'.$langs->trans("ErrorShiftTaskDate").':'.$object->error.'
'; } } } @@ -224,10 +222,10 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->projet->creer) // Build doc if ($action == 'builddoc' && $user->rights->projet->creer) { - $project->fetch($id); + $object->fetch($id); if (GETPOST('model')) { - $project->setDocModel($user, GETPOST('model')); + $object->setDocModel($user, GETPOST('model')); } $outputlangs = $langs; @@ -236,7 +234,7 @@ if ($action == 'builddoc' && $user->rights->projet->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang(GETPOST('lang_id')); } - $result=project_pdf_create($db, $project, $project->modelpdf, $outputlangs); + $result=project_pdf_create($db, $object, $object->modelpdf, $outputlangs); if ($result <= 0) { dol_print_error($db,$result); @@ -244,47 +242,62 @@ if ($action == 'builddoc' && $user->rights->projet->creer) } else { - Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$project->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); exit; } } +// Delete file in doc form +if ($action == 'remove_file' && $user->rights->projet->creer) +{ + require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); + + if ($object->fetch($id)) + { + $langs->load("other"); + $upload_dir = $conf->projet->dir_output . "/"; + $file = $upload_dir . '/' . GETPOST('file'); + dol_delete_file($file); + $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('file')).'
'; + } +} + if ($action == 'confirm_validate' && GETPOST('confirm') == 'yes') { - $project->fetch($id); + $object->fetch($id); - $result = $project->setValid($user); + $result = $object->setValid($user); if ($result <= 0) { - $mesg='
'.$project->error.'
'; + $mesg='
'.$object->error.'
'; } } if ($action == 'confirm_close' && GETPOST('confirm') == 'yes') { - $project->fetch($id); - $result = $project->setClose($user); + $object->fetch($id); + $result = $object->setClose($user); if ($result <= 0) { - $mesg='
'.$project->error.'
'; + $mesg='
'.$object->error.'
'; } } if ($action == 'confirm_reopen' && GETPOST('confirm') == 'yes') { - $project->fetch($id); - $result = $project->setValid($user); + $object->fetch($id); + $result = $object->setValid($user); if ($result <= 0) { - $mesg='
'.$project->error.'
'; + $mesg='
'.$object->error.'
'; } } if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights->projet->supprimer) { - $project->fetch($id); - $result=$project->delete($user); + $object->fetch($id); + $result=$object->delete($user); if ($result > 0) { Header("Location: index.php"); @@ -292,7 +305,7 @@ if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights- } else { - dol_syslog($project->error,LOG_DEBUG); + dol_syslog($object->error,LOG_DEBUG); $mesg='
'.$langs->trans("CantRemoveProject").'
'; } } @@ -300,16 +313,15 @@ if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $user->rights- if ($action == 'confirm_clone' && $user->rights->projet->creer && GETPOST('confirm') == 'yes') { $idtoclone=$id; - $project = new Project($db); - $project->fetch($idtoclone); + $object->fetch($idtoclone); $clone_contacts=GETPOST('clone_contacts')?1:0; $clone_tasks=GETPOST('clone_tasks')?1:0; $clone_files=GETPOST('clone_files')?1:0; $clone_notes=GETPOST('clone_notes')?1:0; - $result=$project->createFromClone($idtoclone,$clone_contacts,$clone_tasks,$clone_files,$clone_notes); + $result=$object->createFromClone($idtoclone,$clone_contacts,$clone_tasks,$clone_files,$clone_notes); if ($result <= 0) { - $mesg='
'.$project->error.'
'; + $mesg='
'.$object->error.'
'; } else { @@ -349,15 +361,13 @@ if ($action == 'create' && $user->rights->projet->creer) print ''; - $project = new Project($db); - $defaultref=''; $obj = empty($conf->global->PROJECT_ADDON)?'mod_project_simple':$conf->global->PROJECT_ADDON; if (! empty($conf->global->PROJECT_ADDON) && is_readable(DOL_DOCUMENT_ROOT ."/core/modules/project/".$conf->global->PROJECT_ADDON.".php")) { require_once(DOL_DOCUMENT_ROOT ."/core/modules/project/".$conf->global->PROJECT_ADDON.".php"); $modProject = new $obj; - $defaultref = $modProject->getNextValue($soc,$project); + $defaultref = $modProject->getNextValue($soc,$object); } if (is_numeric($defaultref) && $defaultref <= 0) $defaultref=''; @@ -378,7 +388,7 @@ if ($action == 'create' && $user->rights->projet->creer) // Public print ''; // Date start @@ -419,37 +429,36 @@ else dol_htmloutput_mesg($mesg); - $project = new Project($db); - $project->fetch($id,$ref); + $object->fetch($id,$ref); - if ($project->societe->id > 0) $result=$project->societe->fetch($project->societe->id); + if ($object->societe->id > 0) $result=$object->societe->fetch($object->societe->id); // To verify role of users - $userAccess = $project->restrictedProjectArea($user,'read'); - $userWrite = $project->restrictedProjectArea($user,'write'); - $userDelete = $project->restrictedProjectArea($user,'delete'); + $userAccess = $object->restrictedProjectArea($user,'read'); + $userWrite = $object->restrictedProjectArea($user,'write'); + $userDelete = $object->restrictedProjectArea($user,'delete'); //print "userAccess=".$userAccess." userWrite=".$userWrite." userDelete=".$userDelete; - $head=project_prepare_head($project); - dol_fiche_head($head, 'project', $langs->trans("Project"),0,($project->public?'projectpub':'project')); + $head=project_prepare_head($object); + dol_fiche_head($head, 'project', $langs->trans("Project"),0,($object->public?'projectpub':'project')); // Confirmation validation if ($action == 'validate') { - $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$project->id, $langs->trans('ValidateProject'), $langs->trans('ConfirmValidateProject'), 'confirm_validate','',0,1); + $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProject'), $langs->trans('ConfirmValidateProject'), 'confirm_validate','',0,1); if ($ret == 'html') print '
'; } // Confirmation close if ($action == 'close') { - $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("CloseAProject"),$langs->trans("ConfirmCloseAProject"),"confirm_close",'','',1); + $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("CloseAProject"),$langs->trans("ConfirmCloseAProject"),"confirm_close",'','',1); if ($ret == 'html') print '
'; } // Confirmation reopen if ($action == 'reopen') { - $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("ReOpenAProject"),$langs->trans("ConfirmReOpenAProject"),"confirm_reopen",'','',1); + $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("ReOpenAProject"),$langs->trans("ConfirmReOpenAProject"),"confirm_reopen",'','',1); if ($ret == 'html') print '
'; } // Confirmation delete @@ -457,10 +466,10 @@ else { $text=$langs->trans("ConfirmDeleteAProject"); $task=new Task($db); - $taskarray=$task->getTasksArray(0,0,$project->id,0,0); + $taskarray=$task->getTasksArray(0,0,$object->id,0,0); $nboftask=count($taskarray); if ($nboftask) $text.='
'.img_warning().' '.$langs->trans("ThisWillAlsoRemoveTasks",$nboftask); - $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$project->id,$langs->trans("DeleteAProject"),$text,"confirm_delete",'','',1); + $ret=$form->form_confirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("DeleteAProject"),$text,"confirm_delete",'','',1); if ($ret == 'html') print '
'; } @@ -475,7 +484,7 @@ else array('type' => 'checkbox', 'name' => 'clone_files', 'label' => $langs->trans("CloneFiles"), 'value' => false) ); - print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$project->id, $langs->trans("CloneProject"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 240); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans("CloneProject"), $langs->trans("ConfirmCloneProject"), "confirm_clone", $formquestion, '', 1, 240); } if ($action == 'edit' && $userWrite > 0) @@ -483,36 +492,36 @@ else print ''; print ''; print ''; - print ''; + print ''; print ''; print '
'.$langs->trans("Visibility").''; $array=array(0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject")); - print $form->selectarray('public',$array,$project->public); + print $form->selectarray('public',$array,$object->public); print '
'; // Ref print ''; - print ''; + print ''; // Label print ''; - print ''; + print ''; // Customer print ''; // Visibility print ''; // Statut - print ''; + print ''; // Date start print ''; // Description print ''; print ''; print '
'.$langs->trans("Ref").'
'.$langs->trans("Label").'
'.$langs->trans("Company").''; - print $form->select_company($project->societe->id,'socid','',1,1); + print $form->select_company($object->societe->id,'socid','',1,1); print '
'.$langs->trans("Visibility").''; $array=array(0 => $langs->trans("PrivateProject"),1 => $langs->trans("SharedProject")); - print $form->selectarray('public',$array,$project->public); + print $form->selectarray('public',$array,$object->public); print '
'.$langs->trans("Status").''.$project->getLibStatut(4).'
'.$langs->trans("Status").''.$object->getLibStatut(4).'
'.$langs->trans("DateStart").''; - print $form->select_date($project->date_start,'project'); + print $form->select_date($object->date_start,'project'); print ''. $langs->trans("ProjectReportDate"); @@ -520,13 +529,13 @@ else // Date end print '
'.$langs->trans("DateEnd").''; - print $form->select_date($project->date_end?$project->date_end:-1,'projectend'); + print $form->select_date($object->date_end?$object->date_end:-1,'projectend'); print '
'.$langs->trans("Description").''; - print ''; + print ''; print '
'; @@ -546,43 +555,43 @@ else // Define a complementary filter for search of next/prev ref. if (! $user->rights->projet->all->lire) { - $projectsListId = $project->getProjectsAuthorizedForUser($user,$mine,0); - $project->next_prev_filter=" rowid in (".(count($projectsListId)?join(',',array_keys($projectsListId)):'0').")"; + $objectsListId = $object->getProjectsAuthorizedForUser($user,$mine,0); + $object->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")"; } - print $form->showrefnav($project,'ref','',1,'ref','ref'); + print $form->showrefnav($object,'ref','',1,'ref','ref'); print ''; // Label - print ''.$langs->trans("Label").''.$project->title.''; + print ''.$langs->trans("Label").''.$object->title.''; // Third party print ''.$langs->trans("Company").''; - if ($project->societe->id > 0) print $project->societe->getNomUrl(1); + if ($object->societe->id > 0) print $object->societe->getNomUrl(1); else print' '; print ''; // Visibility print ''.$langs->trans("Visibility").''; - if ($project->public) print $langs->trans('SharedProject'); + if ($object->public) print $langs->trans('SharedProject'); else print $langs->trans('PrivateProject'); print ''; // Statut - print ''.$langs->trans("Status").''.$project->getLibStatut(4).''; + print ''.$langs->trans("Status").''.$object->getLibStatut(4).''; // Date start print ''.$langs->trans("DateStart").''; - print dol_print_date($project->date_start,'day'); + print dol_print_date($object->date_start,'day'); print ''; // Date end print ''.$langs->trans("DateEnd").''; - print dol_print_date($project->date_end,'day'); + print dol_print_date($object->date_end,'day'); print ''; // Description print ''.$langs->trans("Description").''; - print nl2br($project->description); + print nl2br($object->description); print ''; print ''; @@ -598,11 +607,11 @@ else if ($action != "edit" ) { // Validate - if ($project->statut == 0 && $user->rights->projet->creer) + if ($object->statut == 0 && $user->rights->projet->creer) { if ($userWrite > 0) { - print '
'.$langs->trans("Valid").''; + print ''.$langs->trans("Valid").''; } else { @@ -611,11 +620,11 @@ else } // Modify - if ($project->statut != 2 && $user->rights->projet->creer) + if ($object->statut != 2 && $user->rights->projet->creer) { if ($userWrite > 0) { - print ''.$langs->trans("Modify").''; + print ''.$langs->trans("Modify").''; } else { @@ -624,11 +633,11 @@ else } // Close - if ($project->statut == 1 && $user->rights->projet->creer) + if ($object->statut == 1 && $user->rights->projet->creer) { if ($userWrite > 0) { - print ''.$langs->trans("Close").''; + print ''.$langs->trans("Close").''; } else { @@ -637,11 +646,11 @@ else } // Reopen - if ($project->statut == 2 && $user->rights->projet->creer) + if ($object->statut == 2 && $user->rights->projet->creer) { if ($userWrite > 0) { - print ''.$langs->trans("ReOpen").''; + print ''.$langs->trans("ReOpen").''; } else { @@ -654,7 +663,7 @@ else { if ($userWrite > 0) { - print ''.$langs->trans('ToClone').''; + print ''.$langs->trans('ToClone').''; } else { @@ -667,7 +676,7 @@ else { if ($userDelete > 0) { - print ''.$langs->trans("Delete").''; + print ''.$langs->trans("Delete").''; } else { @@ -688,22 +697,22 @@ else /* * Documents generes */ - $filename=dol_sanitizeFileName($project->ref); - $filedir=$conf->projet->dir_output . "/" . dol_sanitizeFileName($project->ref); - $urlsource=$_SERVER["PHP_SELF"]."?id=".$project->id; + $filename=dol_sanitizeFileName($object->ref); + $filedir=$conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); + $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; $genallowed=($user->rights->projet->lire && $userAccess > 0); $delallowed=($user->rights->projet->creer && $userWrite > 0); $var=true; - $somethingshown=$formfile->show_documents('project',$filename,$filedir,$urlsource,$genallowed,$delallowed,$project->modelpdf); + $somethingshown=$formfile->show_documents('project',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf); print ''; // List of actions on element include_once(DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'); $formactions=new FormActions($db); - $somethingshown=$formactions->showactions($project,'project',$socid); + $somethingshown=$formactions->showactions($object,'project',$socid); print ''; } diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index dd4c20e2ea6..f77706f4c7f 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -28,6 +28,7 @@ require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php"); require_once(DOL_DOCUMENT_ROOT."/projet/class/task.class.php"); require_once(DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/core/lib/images.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); @@ -70,14 +71,21 @@ $projectstatic = new Project($db); // Envoi fichier if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { - require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); - if (dol_mkdir($upload_dir) >= 0) { $resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']); if (is_numeric($resupload) && $resupload > 0) { - $mesg = '
'.$langs->trans("FileTransferComplete").'
'; + if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) + { + // Create small thumbs for image (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs"); + } + $mesg = '
'.$langs->trans("FileTransferComplete").'
'; } else { @@ -101,9 +109,10 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) // Delete if ($action=='delete') { - $file = $upload_dir . '/' . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $langs->load("other"); + $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file); - $mesg = '
'.$langs->trans("FileWasRemoved").'
'; + $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; } // Retreive First Task ID of Project if withprojet is on to allow project prev next to work diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index 55a94a10e24..a5e55ed4fe9 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -64,7 +64,7 @@ $object = new Societe($db); if ($id > 0 || ! empty($ref)) { $result = $object->fetch($id, $ref); - + $upload_dir = $conf->societe->multidir_output[$object->entity] . "/" . $object->id ; $courrier_dir = $conf->societe->multidir_output[$object->entity] . "/courrier/" . get_exdir($object->id); } @@ -74,6 +74,8 @@ if ($id > 0 || ! empty($ref)) * Actions */ +// TODO Use an include to mutualize this code for action sendit and confirm_deletefile + // Post file if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) { @@ -84,16 +86,15 @@ if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) $resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . $_FILES['userfile']['name'],0,0,$_FILES['userfile']['error']); if (is_numeric($resupload) && $resupload > 0) { - if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) - { - // Create small thumbs for company (Ratio is near 16/9) - // Used on logon for example - $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs"); - - // Create mini thumbs for company (Ratio is near 16/9) - // Used on menu or for setup page for example - $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs"); - } + if (image_format_supported($upload_dir . "/" . $_FILES['userfile']['name']) == 1) + { + // Create small thumbs for image (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthsmall, $maxheightsmall, '_small', $quality, "thumbs"); + // Create mini thumbs for image (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($upload_dir . "/" . $_FILES['userfile']['name'], $maxwidthmini, $maxheightmini, '_mini', $quality, "thumbs"); + } $mesg = '
'.$langs->trans("FileTransferComplete").'
'; } else @@ -121,9 +122,9 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') { if ($object->id) { - $file = $upload_dir . "/" . $_GET['urlfile']; // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). + $file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file,0,0,0,$object); - $mesg = '
'.$langs->trans("FileWasRemoved").'
'; + $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; } } @@ -144,12 +145,12 @@ if ($object->id) */ if ($conf->notification->enabled) $langs->load("mails"); $head = societe_prepare_head($object); - + $form=new Form($db); - + dol_fiche_head($head, 'document', $langs->trans("ThirdParty"),0,'company'); - - + + // Construit liste des fichiers $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $totalsize=0; @@ -157,22 +158,22 @@ if ($object->id) { $totalsize+=$file['size']; } - - + + print ''; - + // Ref print ''; print ''; - + // Prefix if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; } - + if ($object->client) { print ''; } - + if ($object->fournisseur) { print ''; } - + // Nbre fichiers print ''; - + //Total taille print ''; - + print '
'.$langs->trans("ThirdPartyName").''; print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom'); print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; @@ -181,7 +182,7 @@ if ($object->id) if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; print '
'; @@ -190,19 +191,19 @@ if ($object->id) if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; print '
'.$langs->trans("NbOfAttachedFiles").''.count($filearray).'
'.$langs->trans("TotalSizeOfAttachedFiles").''.$totalsize.' '.$langs->trans("bytes").'
'; - + print ''; - + dol_htmloutput_mesg($mesg,$mesgs); - + /* * Confirmation suppression fichier */ @@ -211,16 +212,16 @@ if ($object->id) $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&urlfile='.urldecode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', '', 0, 1); if ($ret == 'html') print '
'; } - + $formfile=new FormFile($db); - + // Show upload form $formfile->form_attach_new_file($_SERVER["PHP_SELF"].'?id='.$object->id,'',0,0,$user->rights->societe->creer,50,$object); - + // List of document $param='&socid='.$object->id; $formfile->list_of_documents($filearray,$object,'societe',$param); - + print "

"; } else