Fixed a bug where files were not being uploaded to a project's task
Reported by Jose Antonio Garcia in dolibarr.es' forum http://www.dolibarr.es/index.php/foro/7-bugs-versiones-estables/1250-error-subir-archivo-en-una-tarea-de-un-proyecto Conflicts: htdocs/projet/tasks/document.php
This commit is contained in:
parent
1f9e0d3e00
commit
173ff4f92a
@ -44,11 +44,11 @@ $ref= GETPOST('ref','alpha');
|
|||||||
$withproject=GETPOST('withproject','int');
|
$withproject=GETPOST('withproject','int');
|
||||||
$project_ref = GETPOST('project_ref','alpha');
|
$project_ref = GETPOST('project_ref','alpha');
|
||||||
|
|
||||||
$mesg='';
|
$mesg='';
|
||||||
if (isset($_SESSION['DolMessage']))
|
if (isset($_SESSION['DolMessage']))
|
||||||
{
|
{
|
||||||
$mesg=$_SESSION['DolMessage'];
|
$mesg=$_SESSION['DolMessage'];
|
||||||
unset($_SESSION['DolMessage']);
|
unset($_SESSION['DolMessage']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
@ -79,55 +79,6 @@ $projectstatic = new Project($db);
|
|||||||
* Actions
|
* Actions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Envoi fichier
|
|
||||||
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
|
||||||
{
|
|
||||||
if (dol_mkdir($upload_dir) >= 0)
|
|
||||||
{
|
|
||||||
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_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 = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$langs->load("errors");
|
|
||||||
if ($resupload < 0) // Unknown error
|
|
||||||
{
|
|
||||||
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
|
|
||||||
}
|
|
||||||
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
|
|
||||||
{
|
|
||||||
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
|
|
||||||
}
|
|
||||||
else // Known error
|
|
||||||
{
|
|
||||||
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete
|
|
||||||
if ($action=='delete')
|
|
||||||
{
|
|
||||||
$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);
|
|
||||||
$_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
|
|
||||||
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Retreive First Task ID of Project if withprojet is on to allow project prev next to work
|
// Retreive First Task ID of Project if withprojet is on to allow project prev next to work
|
||||||
if (! empty($project_ref) && ! empty($withproject))
|
if (! empty($project_ref) && ! empty($withproject))
|
||||||
{
|
{
|
||||||
@ -164,6 +115,56 @@ if ($id > 0 || ! empty($ref))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Envoi fichier
|
||||||
|
if ($_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
|
||||||
|
{
|
||||||
|
if (dol_mkdir($upload_dir) >= 0)
|
||||||
|
{
|
||||||
|
$resupload=dol_move_uploaded_file($_FILES['userfile']['tmp_name'], $upload_dir . "/" . dol_unescapefile($_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 = '<div class="ok">'.$langs->trans("FileTransferComplete").'</div>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$langs->load("errors");
|
||||||
|
if ($resupload < 0) // Unknown error
|
||||||
|
{
|
||||||
|
$mesg = '<div class="error">'.$langs->trans("ErrorFileNotUploaded").'</div>';
|
||||||
|
}
|
||||||
|
else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus
|
||||||
|
{
|
||||||
|
$mesg = '<div class="error">'.$langs->trans("ErrorFileIsInfectedWithAVirus").'</div>';
|
||||||
|
}
|
||||||
|
else // Known error
|
||||||
|
{
|
||||||
|
$mesg = '<div class="error">'.$langs->trans($resupload).'</div>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
if ($action=='delete')
|
||||||
|
{
|
||||||
|
$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);
|
||||||
|
$_SESSION['DolMessage'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
|
||||||
|
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user