From 274734b8281afa7fe3f28ca3e4e88088cdbc2234 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 31 May 2012 17:48:03 +0200 Subject: [PATCH] Fix: stock message in session and reload the page for avoid url problem with jQuery fileupload --- htdocs/adherents/document.php | 12 ++++++++++-- htdocs/comm/propal/document.php | 11 ++++++++++- htdocs/commande/document.php | 12 ++++++++++-- htdocs/compta/facture/document.php | 11 ++++++++++- htdocs/fourn/commande/document.php | 11 ++++++++++- htdocs/projet/document.php | 11 ++++++++++- htdocs/projet/tasks/document.php | 11 ++++++++++- htdocs/societe/document.php | 12 ++++++++++-- 8 files changed, 80 insertions(+), 11 deletions(-) diff --git a/htdocs/adherents/document.php b/htdocs/adherents/document.php index cc7a4cda3b7..b838294770b 100644 --- a/htdocs/adherents/document.php +++ b/htdocs/adherents/document.php @@ -39,7 +39,13 @@ $langs->load('other'); $id=GETPOST('id','int'); $action=GETPOST('action','alpha'); $confirm=GETPOST('confirm','alpha'); -$mesg = ""; + +$mesg=''; +if (isset($_SESSION['DolMessage'])) +{ + $mesg=$_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); +} // Security check if ($user->societe_id > 0) @@ -114,7 +120,9 @@ 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). dol_delete_file($file); - $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + exit; } diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index 0f55592a291..6d3be75c529 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -39,6 +39,13 @@ $confirm = GETPOST('confirm'); $id = GETPOST('id','int'); $ref = GETPOST('ref'); +$mesg=''; +if (isset($_SESSION['DolMessage'])) +{ + $mesg=$_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); +} + // Security check if ($user->societe_id) { @@ -120,7 +127,9 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $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). dol_delete_file($file,0,0,0,$object); - $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + exit; } } diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index f9497759637..0002771ee7d 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -40,6 +40,13 @@ $confirm = GETPOST('confirm'); $id = GETPOST('id','int'); $ref = GETPOST('ref'); +$mesg=''; +if (isset($_SESSION['DolMessage'])) +{ + $mesg=$_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); +} + // Security check if ($user->societe_id) { @@ -59,7 +66,6 @@ $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="name"; - $object = new Commande($db); @@ -123,7 +129,9 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $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). dol_delete_file($file,0,0,0,$object); - $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + exit; } } diff --git a/htdocs/compta/facture/document.php b/htdocs/compta/facture/document.php index 941f3a8157c..bdb0990f4b3 100644 --- a/htdocs/compta/facture/document.php +++ b/htdocs/compta/facture/document.php @@ -43,6 +43,13 @@ $confirm = GETPOST('confirm'); $id = GETPOST('facid','int'); $ref = GETPOST('ref'); +$mesg=''; +if (isset($_SESSION['DolMessage'])) +{ + $mesg=$_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); +} + // Security check if ($user->societe_id) { @@ -125,7 +132,9 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $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). dol_delete_file($file,0,0,0,$object); - $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + exit; } } diff --git a/htdocs/fourn/commande/document.php b/htdocs/fourn/commande/document.php index d5fe4ac022a..07f0f2e354d 100644 --- a/htdocs/fourn/commande/document.php +++ b/htdocs/fourn/commande/document.php @@ -41,6 +41,13 @@ $langs->load('deliveries'); $langs->load('products'); $langs->load('stocks'); +$mesg=''; +if (isset($_SESSION['DolMessage'])) +{ + $mesg=$_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); +} + // Security check $id=empty($_GET['id']) ? 0 : intVal($_GET['id']); $action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action']; @@ -119,7 +126,9 @@ if ($action=='delete') $upload_dir = $conf->fournisseur->dir_output . "/commande/" . dol_sanitizeFileName($commande->ref); $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file); - $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + exit; } diff --git a/htdocs/projet/document.php b/htdocs/projet/document.php index 39ae5148024..aa70351fdde 100644 --- a/htdocs/projet/document.php +++ b/htdocs/projet/document.php @@ -38,6 +38,13 @@ $mine = $_REQUEST['mode']=='mine' ? 1 : 0; $id = GETPOST('id','int'); $ref= GETPOST('ref'); +$mesg=''; +if (isset($_SESSION['DolMessage'])) +{ + $mesg=$_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); +} + $project = new Project($db); if (! $project->fetch($id,$ref) > 0) { @@ -115,7 +122,9 @@ if ($action == 'confirm_delete' && $_REQUEST['confirm'] == 'yes' && $user->right $upload_dir = $conf->projet->dir_output . "/" . dol_sanitizeFileName($project->ref); $file = $upload_dir . '/' . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file); - $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + exit; } diff --git a/htdocs/projet/tasks/document.php b/htdocs/projet/tasks/document.php index 5c1d3bc0c90..e9038d1c768 100644 --- a/htdocs/projet/tasks/document.php +++ b/htdocs/projet/tasks/document.php @@ -44,6 +44,13 @@ $ref= GETPOST('ref','alpha'); $withproject=GETPOST('withproject','int'); $project_ref = GETPOST('project_ref','alpha'); +$mesg=''; +if (isset($_SESSION['DolMessage'])) +{ + $mesg=$_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); +} + // Security check $socid=0; if ($user->societe_id > 0) $socid = $user->societe_id; @@ -112,7 +119,9 @@ 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); - $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + 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 diff --git a/htdocs/societe/document.php b/htdocs/societe/document.php index d37ced68e01..a0a10011946 100644 --- a/htdocs/societe/document.php +++ b/htdocs/societe/document.php @@ -33,13 +33,19 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/html.formfile.class.php"); $langs->load("companies"); $langs->load('other'); -$mesg=''; $action=GETPOST('action'); $confirm=GETPOST('confirm'); $id=(GETPOST('socid','int') ? GETPOST('socid','int') : GETPOST('id','int')); $ref = GETPOST('ref', 'alpha'); +$mesg=''; +if (isset($_SESSION['DolMessage'])) +{ + $mesg=$_SESSION['DolMessage']; + unset($_SESSION['DolMessage']); +} + // Security check if ($user->societe_id > 0) { @@ -125,7 +131,9 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). dol_delete_file($file,0,0,0,$object); - $mesg = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + $_SESSION['DolMessage'] = '
'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'
'; + Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; } }