This commit is contained in:
Cédric Salvador 2013-07-29 16:37:49 +02:00 committed by Raphaël Doursenaud
parent 06af0733e9
commit d47bb95b56

View File

@ -2,34 +2,35 @@
// Envoi fichier // Envoi fichier
if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC))
{ {
if ($object->id) if ($object->id)
{ {
dol_add_file_process($upload_dir,0,1,'userfile'); dol_add_file_process($upload_dir,0,1,'userfile');
} }
} } elseif (GETPOST('linkit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) {
//test code for the link feature, need to mutualize it to avoid copy/paste on every document page if ($object->id) {
elseif (GETPOST('linkit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) {
if ($object->id) {
$link = GETPOST('link', 'alpha'); $link = GETPOST('link', 'alpha');
if (!strpos(substr($link, 0, 7), 'http://') && !strpos(substr($link, 0, 8), 'https://')) { if (substr($link, 0, 7) != 'http://' && substr($link, 0, 8) != 'https://') {
$link = 'http://' . $link; $link = 'http://' . $link;
} }
dol_add_file_process($upload_dir,0,1,'userfile', $link); dol_add_file_process($upload_dir,0,1,'userfile', $link);
} }
} }
// Delete file // Delete file
if ($action == 'confirm_deletefile' && $confirm == 'yes') if ($action == 'confirm_deletefile' && $confirm == 'yes')
{ {
if ($object->id) if ($object->id)
{ {
$file = $upload_dir . "/" . GETPOST('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).
$ret=dol_delete_file($file,0,0,0,$object); $ret = dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); if ($ret) {
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); } else {
exit; setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
} }
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
} }
?>