Fix: broken features for fileupload
This commit is contained in:
parent
6b8c4fc3f2
commit
63a5aee80e
@ -263,7 +263,7 @@ if ($objectid > 0)
|
||||
|
||||
// Affiche formulaire upload
|
||||
$formfile=new FormFile($db);
|
||||
$formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/action/document.php?id='.$act->id,'',0,0,($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create));
|
||||
$formfile->form_attach_new_file(DOL_URL_ROOT.'/comm/action/document.php?id='.$act->id,'',0,0,($user->rights->agenda->myactions->create||$user->rights->agenda->allactions->create),50,$act);
|
||||
|
||||
|
||||
// List of document
|
||||
|
||||
@ -56,6 +56,8 @@ class FileUpload
|
||||
$filename = $regs[2];
|
||||
}
|
||||
|
||||
$parentForeignKey = '';
|
||||
|
||||
// For compatibility
|
||||
if ($element == 'propal') {
|
||||
$pathname = 'comm/propal';
|
||||
@ -69,6 +71,14 @@ class FileUpload
|
||||
$element = $pathname = 'projet';
|
||||
$dir_output=$conf->$element->dir_output;
|
||||
}
|
||||
elseif ($element == 'project_task') {
|
||||
$pathname = 'projet'; $filename='task';
|
||||
$dir_output=$conf->projet->dir_output;
|
||||
$parentForeignKey = 'fk_project';
|
||||
$parentClass = 'Project';
|
||||
$parentElement = 'projet';
|
||||
$parentObject = 'project';
|
||||
}
|
||||
elseif ($element == 'fichinter') {
|
||||
$element='ficheinter';
|
||||
$dir_output=$conf->$element->dir_output;
|
||||
@ -80,6 +90,10 @@ class FileUpload
|
||||
elseif ($element == 'invoice_supplier') {
|
||||
$pathname = 'fourn'; $filename='fournisseur.facture';
|
||||
$dir_output=$conf->fournisseur->facture->dir_output;
|
||||
}
|
||||
elseif ($element == 'action') {
|
||||
$pathname = 'comm/action'; $filename='actioncomm';
|
||||
$dir_output=$conf->agenda->dir_output;
|
||||
} else {
|
||||
$dir_output=$conf->$element->dir_output;
|
||||
}
|
||||
@ -97,11 +111,23 @@ class FileUpload
|
||||
$object = new $classname($db);
|
||||
|
||||
$object->fetch($fk_element);
|
||||
$object->fetch_thirdparty();
|
||||
if (!empty($parentForeignKey)) {
|
||||
dol_include_once('/'.$parentElement.'/class/'.$parentObject.'.class.php');
|
||||
$parent = new $parentClass($db);
|
||||
$parent->fetch($object->$parentForeignKey);
|
||||
if (!empty($parent->socid)) {
|
||||
$parent->fetch_thirdparty();
|
||||
}
|
||||
$object->$parentObject = dol_clone($parent);
|
||||
} else {
|
||||
$object->fetch_thirdparty();
|
||||
}
|
||||
|
||||
$object_ref = dol_sanitizeFileName($object->ref);
|
||||
if ($element == 'invoice_supplier') {
|
||||
$object_ref = get_exdir($object->id, 2) . $object_ref;
|
||||
} else if ($element == 'project_task') {
|
||||
$object_ref = $object->project->ref . '/' . $object_ref;
|
||||
}
|
||||
|
||||
$this->options = array(
|
||||
|
||||
@ -171,6 +171,7 @@ class Task extends CommonObject
|
||||
$sql.= " t.label,";
|
||||
$sql.= " t.description,";
|
||||
$sql.= " t.duration_effective,";
|
||||
$sql.= " t.datec,";
|
||||
$sql.= " t.dateo,";
|
||||
$sql.= " t.datee,";
|
||||
$sql.= " t.fk_user_creat,";
|
||||
|
||||
@ -93,7 +93,11 @@ if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$projectstatic->fetch($object->fk_project);
|
||||
|
||||
if (! empty($projectstatic->socid)) $projectstatic->societe->fetch($projectstatic->socid);
|
||||
if (! empty($projectstatic->socid)) {
|
||||
$projectstatic->fetch_thirdparty();
|
||||
}
|
||||
|
||||
$object->project = dol_clone($projectstatic);
|
||||
|
||||
$upload_dir = $conf->projet->dir_output.'/'.dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($object->ref);
|
||||
}
|
||||
@ -114,7 +118,7 @@ if ($action=='delete')
|
||||
{
|
||||
$langs->load("other");
|
||||
$file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
|
||||
$ret=dol_delete_file($file);
|
||||
$ret=dol_delete_file($file,0,0,0,$object);
|
||||
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile')));
|
||||
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors');
|
||||
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user