From 561a1a1aacf1541b4245c04c4f8a9a98dd3f2177 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 14 Mar 2014 02:07:54 +0100 Subject: [PATCH] Fix: Miscellaneous problems on task tabs (withproject parameter lost and download fails). --- htdocs/core/class/html.formfile.class.php | 36 ++++++++++--------- .../tpl/document_actions_post_headers.tpl.php | 13 +++---- .../tpl/document_actions_pre_headers.tpl.php | 2 +- htdocs/projet/document.php | 3 +- htdocs/projet/tasks/document.php | 7 ++-- 5 files changed, 33 insertions(+), 28 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 1319ad766d0..5317d49c23c 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -764,8 +764,9 @@ class FormFile if (empty($relativepath)) { $relativepath=(! empty($object->ref)?dol_sanitizeFileName($object->ref):'').'/'; - if ($object->element == 'invoice_supplier') $relativepath=get_exdir($object->id,2).$relativepath; - if ($object->element == 'member') $relativepath=get_exdir($object->id,2).$relativepath; + if ($object->element == 'invoice_supplier') $relativepath=get_exdir($object->id,2).$relativepath; // TODO Call using a defined value for $relativepath + if ($object->element == 'member') $relativepath=get_exdir($object->id,2).$relativepath; // TODO Call using a defined value for $relativepath + if ($object->element == 'project_task') $relativepath='Call_not_supported_._Call_function_using_a_defined_relative_path_.'; } $var=!$var; @@ -1052,9 +1053,10 @@ class FormFile * @param int $permtodelete Deletion is allowed * @param string $action Action * @param string $selected ??? + * @param string $param More param to add into URL * @return int Number of links */ - public function listOfLinks($object, $permtodelete=1, $action=null, $selected=null) + public function listOfLinks($object, $permtodelete=1, $action=null, $selected=null, $param='') { global $user, $conf, $langs, $user; global $bc; @@ -1071,17 +1073,17 @@ class FormFile $sortfield = null; } $res = $link->fetchAll($links, $object->element, $object->id, $sortfield, $sortorder); - $param = (isset($object->id)?'&id=' . $object->id : ''); + $param .= (isset($object->id)?'&id=' . $object->id : ''); // Show list of associated links print_titre($langs->trans("LinkedFiles")); - print '
'; + print ''; print ''; print ''; print_liste_field_titre( - $langs->trans("Documents2"), + $langs->trans("Links"), $_SERVER['PHP_SELF'], "name", "", @@ -1135,34 +1137,34 @@ class FormFile print ''; print $langs->trans('Link') . ': '; print ''; - print ''; print ''; print ''; - print ''; } - else { + else + { print '\n"; + print ''."\n"; print ''; print ''; print ''; print '"; + print ''; } print "\n"; } diff --git a/htdocs/core/tpl/document_actions_post_headers.tpl.php b/htdocs/core/tpl/document_actions_post_headers.tpl.php index 2ae7b9ad595..a662bd5be3d 100644 --- a/htdocs/core/tpl/document_actions_post_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_post_headers.tpl.php @@ -1,6 +1,6 @@ - * Copyright (C) 2013 Laurent Destailleur +/* Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2013-2014 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,16 +18,17 @@ */ $langs->load("link"); +if (empty($relativepathwithnofile)) $relativepathwithnofile=''; /* - * Confirm suppression + * Confirm form to delete */ if ($action == 'delete') { $langs->load("companies"); // Need for string DeleteFile+ConfirmDeleteFiles $ret = $form->form_confirm( - $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&urlfile=' . urlencode(GETPOST("urlfile")) . '&linkid=' . GETPOST('linkid', 'int'), + $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&urlfile=' . urlencode(GETPOST("urlfile")) . '&linkid=' . GETPOST('linkid', 'int') . (empty($param)?'':$param), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile', @@ -58,11 +59,11 @@ $formfile->list_of_documents( $modulepart, $param, 0, - '', + $relativepathwithnofile, // relative path with no file. For example "moduledir/0/1" $permission ); print "
"; //List of links -$formfile->listOfLinks($object, $permission, $action, GETPOST('linkid', 'int')); +$formfile->listOfLinks($object, $permission, $action, GETPOST('linkid', 'int'), $param); print "
"; diff --git a/htdocs/core/tpl/document_actions_pre_headers.tpl.php b/htdocs/core/tpl/document_actions_pre_headers.tpl.php index 989a3bcaf73..ca6929331ec 100644 --- a/htdocs/core/tpl/document_actions_pre_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_pre_headers.tpl.php @@ -74,7 +74,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') setEventMessage($langs->trans("ErrorFailedToDeleteLink", $link->label), 'errors'); } } - header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id); + header('Location: ' . $_SERVER["PHP_SELF"] . '?id=' . $object->id.($withproject?'&withproject=1':'')); exit; } } diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index 89fc9549156..8d545bf1e6a 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -144,9 +144,8 @@ if ($object->id > 0) print "
'; + print ''; print $langs->trans('Label') . ': '; print '' . dol_print_date(dol_now(), "dayhour", "tzuser") . ''; - print ''; + print ''; + print ''; + print ''; print ''; - print ''; + print ''; print $link->label; print ''; - print "' . dol_print_date($link->datea, "dayhour", "tzuser") . ''; - print '' . img_edit().''; + print '' . img_edit() . ''; // id= is included into $param if ($permtodelete) { - print '   ' . img_delete() . ''; + print '   ' . img_delete() . ''; // id= is included into $param } else { print ' '; } - print "
\n"; print "\n"; - $modulepart = 'projet'; + $modulepart = 'project'; $permission = ($userWrite > 0); - $param = '&id=' . $object->id; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; } diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index 8dd80223e6c..0b876d0490a 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -110,6 +110,7 @@ if ($id > 0 || ! empty($ref)) include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_pre_headers.tpl.php'; + /* * View */ @@ -229,9 +230,11 @@ if ($object->id > 0) print '
'; - $modulepart = 'projet'; + $param=''; + if ($withproject) $param .= '&withproject=1'; + $modulepart = 'project_task'; $permission = $user->rights->projet->creer; - $param = '&id=' . $object->id; + $relativepathwithnofile=dol_sanitizeFileName($projectstatic->ref).'/'.dol_sanitizeFileName($object->ref).'/'; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; } else