diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index f1a5894a78e..f084164efe3 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2013 Cédric Salvador * * 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 @@ -60,47 +61,31 @@ if (! $sortfield) $sortfield="name"; $upload_dir = $conf->adherent->dir_output . "/" . get_exdir($id,2,0,1) . '/' . $id; - - - +$form = new Form($db); +$object=new Adherent($db); +$membert=new AdherentType($db); +$result=$object->fetch($id); +if ($result < 0) +{ + dol_print_error($db); + exit; +} /* * Actions */ -// Envoie fichier -if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - dol_add_file_process($upload_dir,0,1,'userfile'); -} - -// Suppression fichier -if ($action == 'confirm_deletefile' && $confirm == 'yes') -{ - $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); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); - exit; -} +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions.tpl.php'; /* * View */ -$form = new Form($db); -$object=new Adherent($db); -$membert=new AdherentType($db); llxHeader(); if ($id > 0) { - $result=$object->fetch($id); $result=$membert->fetch($object->typeid); if ($result > 0) { diff --git a/htdocs/comm/action/document.php b/htdocs/comm/action/document.php index 7f50eaabd7e..e73fddb7574 100644 --- a/htdocs/comm/action/document.php +++ b/htdocs/comm/action/document.php @@ -4,6 +4,7 @@ * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2005 Simon TOSSER + * Copyright (C) 2013 Cédric Salvador * * 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 @@ -79,26 +80,9 @@ if (! $sortfield) $sortfield="name"; /* - * Action envoie fichier + * Actions */ -if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) -{ - $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($objectid); - dol_add_file_process($upload_dir,0,1,'userfile'); -} - -/* - * Efface fichier - */ -if ($action == 'delete') -{ - $upload_dir = $conf->agenda->dir_output.'/'.dol_sanitizeFileName($objectid); - $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,$act); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); - $action=''; -} +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions.tpl.php'; /* diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 3d6bc97319b..266ee77b7d9 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2013 Cédric Salvador * * 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 @@ -64,38 +65,14 @@ $object->fetch($id,$ref); if ($object->id > 0) { $object->fetch_thirdparty(); + $upload_dir = $conf->propal->dir_output.'/'.dol_sanitizeFileName($object->ref); + include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions.tpl.php'; } /* * Actions */ -// Envoi fichier -if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) -{ - if ($object->id > 0) - { - $upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); - dol_add_file_process($upload_dir,0,1,'userfile'); - } -} - -// Delete -if ($action == 'confirm_deletefile' && $confirm == 'yes') -{ - if ($object->id > 0) - { - $langs->load("other"); - - $upload_dir = $conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); - $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); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); - exit; - } -} /* diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index 0f2925cf455..32e666d1a7b 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2013 Cédric Salvador * * 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 @@ -65,35 +66,13 @@ $object = new Commande($db); /* * Actions */ - -// Envoi fichier -if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) +if ($object->fetch($id)) { - if ($object->fetch($id)) - { - $object->fetch_thirdparty(); - $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); - dol_add_file_process($upload_dir,0,1,'userfile'); - } + $object->fetch_thirdparty(); + $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); } -// Delete -else if ($action == 'confirm_deletefile' && $confirm == 'yes') -{ - if ($object->fetch($id)) - { - $langs->load("other"); - $object->fetch_thirdparty(); - - $upload_dir = $conf->commande->dir_output . "/" . dol_sanitizeFileName($object->ref); - $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); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); - exit; - } -} +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions.tpl.php'; /* @@ -107,10 +86,10 @@ $form = new Form($db); if ($id > 0 || ! empty($ref)) { if ($object->fetch($id, $ref)) - { - $object->fetch_thirdparty(); + { + $object->fetch_thirdparty(); - $upload_dir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($object->ref); + $upload_dir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($object->ref); $head = commande_prepare_head($object); dol_fiche_head($head, 'documents', $langs->trans('CustomerOrder'), 0, 'order'); @@ -140,7 +119,7 @@ if ($id > 0 || ! empty($ref)) print "\n"; print "\n"; - /* + /* * Confirmation suppression fichier */ if ($action == 'delete') diff --git a/htdocs/compta/deplacement/document.php b/htdocs/compta/deplacement/document.php index 26cdf746f46..93258ab2297 100644 --- a/htdocs/compta/deplacement/document.php +++ b/htdocs/compta/deplacement/document.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2005 Simon TOSSER * Copyright (C) 2011-2012 Juanjo Menent + * Copyright (C) 2013 Cédric Salvador * * 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 @@ -71,29 +72,7 @@ $modulepart='trip'; * Actions */ -if (GETPOST('sendit','alpha') && ! empty($conf->global->MAIN_UPLOAD_DOC)) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - dol_add_file_process($upload_dir,0,1,'userfile'); -} - -// Delete -else if ($action == 'confirm_deletefile' && $confirm == 'yes') -{ - if ($object->id > 0) - { - $langs->load("other"); - $object->fetch_thirdparty(); - - $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); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); - exit; - } -} +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions.tpl.php'; /* diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 8aae07746e9..92292375ac4 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2013 Cédric Salvador * * 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 @@ -64,40 +65,17 @@ if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="name"; $object = new Facture($db); - +if ($object->fetch($id)) +{ + $object->fetch_thirdparty(); + $upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref); +} /* * Actions */ +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions.tpl.php'; -// Envoi fichier -if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) -{ - if ($object->fetch($id)) - { - $object->fetch_thirdparty(); - $upload_dir = $conf->facture->dir_output . "/" . dol_sanitizeFileName($object->ref); - dol_add_file_process($upload_dir,0,1,'userfile'); - } -} - -// Delete -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 . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). - $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); - exit; - } -} /* * View diff --git a/htdocs/compta/sociales/document.php b/htdocs/compta/sociales/document.php index 452de21285a..dcef5eb1561 100644 --- a/htdocs/compta/sociales/document.php +++ b/htdocs/compta/sociales/document.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2005 Simon TOSSER * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2013 Cédric Salvador * * 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 @@ -71,18 +72,7 @@ $modulepart='tax'; * Actions */ -if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC)) -{ - dol_add_file_process($upload_dir,0,1,'userfile'); -} - -if ($action == 'delete') -{ - $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); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); -} +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions.tpl.php'; /* diff --git a/htdocs/contrat/document.php b/htdocs/contrat/document.php index 1dba64f57d7..2c9e4b42166 100644 --- a/htdocs/contrat/document.php +++ b/htdocs/contrat/document.php @@ -74,28 +74,9 @@ $modulepart='contract'; /* - * Action envoie fichier + * Actions */ -if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) -{ - dol_add_file_process($upload_dir,0,1,'userfile'); -} - -// Delete -if ($action == 'confirm_deletefile' && $confirm == 'yes') -{ - if ($object->id) - { - $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,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='.$object->id); - exit; - } -} +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions.tpl.php'; /* diff --git a/htdocs/core/tpl/document_actions.tpl.php b/htdocs/core/tpl/document_actions.tpl.php new file mode 100644 index 00000000000..576e6139639 --- /dev/null +++ b/htdocs/core/tpl/document_actions.tpl.php @@ -0,0 +1,35 @@ +global->MAIN_UPLOAD_DOC)) +{ + if ($object->id) + { + dol_add_file_process($upload_dir,0,1,'userfile'); + } +} +//test code for the link feature, need to mutualize it to avoid copy/paste on every document page +elseif (GETPOST('linkit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) { + if ($object->id) { + $link = GETPOST('link', 'alpha'); + if (!strpos(substr($link, 0, 7), 'http://') && !strpos(substr($link, 0, 8), 'https://')) { + $link = 'http://' . $link; + } + dol_add_file_process($upload_dir,0,1,'userfile', $link); + } +} + +// Delete file +if ($action == 'confirm_deletefile' && $confirm == 'yes') +{ + if ($object->id) + { + $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); + if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); + else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } +} +?> diff --git a/htdocs/fichinter/document.php b/htdocs/fichinter/document.php index 30349e5bc09..6638d031651 100644 --- a/htdocs/fichinter/document.php +++ b/htdocs/fichinter/document.php @@ -71,29 +71,7 @@ $modulepart='fichinter'; * Actions */ -if (GETPOST('sendit','alpha') && ! empty($conf->global->MAIN_UPLOAD_DOC)) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - dol_add_file_process($upload_dir,0,1,'userfile'); -} - -// Delete -else if ($action == 'confirm_deletefile' && $confirm == 'yes') -{ - if ($object->id > 0) - { - $langs->load("other"); - $object->fetch_thirdparty(); - - $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); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); - exit; - } -} +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions.tpl.php'; /* diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php index 63c5a43f912..581fac2df66 100644 --- a/htdocs/fourn/commande/document.php +++ b/htdocs/fourn/commande/document.php @@ -4,6 +4,7 @@ * Copyright (C) 2005 Marc Barilley / Ocebo * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012 Marcos García + * Copyright (C) 2013 Cédric Salvador * * 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 @@ -77,26 +78,7 @@ $object->fetch_thirdparty(); * Actions */ -// Envoi fichier -if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) -{ - dol_add_file_process($upload_dir,0,1,'userfile'); -} - -else if ($action == 'confirm_deletefile' && $confirm == 'yes') -{ - if ($object->id > 0) - { - $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,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); - exit; - } -} +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions.tpl.php'; /* diff --git a/htdocs/fourn/facture/document.php b/htdocs/fourn/facture/document.php index d75b81f402a..3e288899d1d 100644 --- a/htdocs/fourn/facture/document.php +++ b/htdocs/fourn/facture/document.php @@ -71,29 +71,7 @@ if ($object->fetch($id, $ref)) * Actions */ -// Envoi fichier -if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) -{ - if ($object->id > 0) - { - dol_add_file_process($upload_dir, 0, 1, 'userfile', GETPOST('savingdocmask')); - } -} - -// Delete -else if ($action == 'confirm_deletefile' && $confirm == 'yes') -{ - if ($object->id > 0) - { - $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,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); - exit; - } -} +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions.tpl.php'; /* @@ -218,4 +196,4 @@ else llxFooter(); $db->close(); -?> \ No newline at end of file +?> diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 22de2273820..9aefbe18dad 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2005 Simon TOSSER * Copyright (C) 2013 Florian Henry + * Copyright (C) 2013 Cédric Salvador * * 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 @@ -80,22 +81,7 @@ $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); * Action envoie fichier */ -if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) -{ - dol_add_file_process($upload_dir,0,1,'userfile'); -} - -// 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). - $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); - exit; -} +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions.tpl.php'; /* diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index 66ffc0443b0..84c9f1e109c 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -1,6 +1,7 @@ * Copyright (C) 2012 Laurent Destailleur + * Copyright (C) 2013 Cédric Salvador * * 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 @@ -49,6 +50,7 @@ $object->fetch($id,$ref); if ($object->id > 0) { $object->fetch_thirdparty(); + $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); } // Get parameters @@ -68,25 +70,7 @@ if (! $sortfield) $sortfield="name"; * Actions */ -// Envoi fichier -if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) -{ - $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); - dol_add_file_process($upload_dir,0,1,'userfile'); -} - -// Delete -if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->projet->supprimer) -{ - $langs->load("other"); - $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($object->ref); - $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); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; -} +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions.tpl.php'; /* diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index 90adc2925c2..1a01958b230 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -1,7 +1,8 @@ +/* Copyright (C) 2010-2012 Regis Houssin * Copyright (C) 2006-2012 Laurent Destailleur - * Copyright (C) 2012 Florian Henry + * Copyright (C) 2012 Florian Henry + * Copyright (C) 2013 Cédric Salvador * * 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 @@ -107,23 +108,7 @@ if ($id > 0 || ! empty($ref)) } } -// Envoi fichier -if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) -{ - dol_add_file_process($upload_dir,0,1,'userfile'); -} - -// 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). - $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); - exit; -} +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions.tpl.php'; /* * View diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index 4a14c58dd9b..27e01eec7bc 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010 Juanjo Menent + * Copyright (C) 2013 Cédric Salvador * * 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 @@ -72,31 +73,7 @@ if ($id > 0 || ! empty($ref)) * Actions */ -// TODO Use an include to mutualize this code for action sendit and confirm_deletefile - -// Post file -if (GETPOST('sendit') && ! empty($conf->global->MAIN_UPLOAD_DOC)) -{ - if ($object->id) - { - dol_add_file_process($upload_dir,0,1,'userfile'); - } -} - -// Delete file -if ($action == 'confirm_deletefile' && $confirm == 'yes') -{ - if ($object->id) - { - $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); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } -} +include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions.tpl.php'; /*