From 158930eb7bde177a199d12c4b8190077878d3845 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Jun 2012 23:48:53 +0200 Subject: [PATCH] Fix: function is loaded once and not overwritten if loaded by another ajax page. So if we need inputok/ko and pageyes/no to be different according to ajax calls (to have several confirm box loaded from different ajax parts of page, we must place such variables outside of function. For this $useglobalvars must be set to 1. --- htdocs/core/ajax/ajaxdirpreview.php | 25 ++---------------------- htdocs/core/class/html.form.class.php | 7 ++++--- htdocs/core/tpl/ajax/formconfirm.tpl.php | 20 ++++++++++++++++++- htdocs/ecm/index.php | 2 +- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index b0f5c89f66d..9bdf51d701e 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -93,34 +93,12 @@ if (preg_match('/\.\./',$upload_dir) || preg_match('/[<>|]/',$upload_dir)) } - /* * Action */ -/* - if ($action == 'remove_file') // Remove a file -{ -clearstatcache(); +// None -dol_syslog(__FILE__." remove $original_file $urlsource", LOG_DEBUG); - -// This test should be useless. We keep it to find bug more easily -if (! file_exists($original_file_osencoded)) -{ -dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$_GET["file"])); -exit; -} - -dol_delete_file($original_file); - -dol_syslog(__FILE__." back to ".urldecode($urlsource), LOG_DEBUG); - -header("Location: ".urldecode($urlsource)); - -return; -} -*/ /* @@ -260,6 +238,7 @@ if (! empty($conf->use_javascript_ajax) && empty($conf->global->MAIN_ECM_DISABLE if ($section) { require_once(DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'); + $useglobalvars=1; $form = new Form($db); $formquestion=array('urlfile'=>array('type'=>'hidden','value'=>'','name'=>'urlfile')); print $form->formconfirm(DOL_URL_ROOT.'/ecm/index.php'.($param?'?':'').(preg_replace('/^&/','',$param)),$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",'deletefile'); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 72f3c809d2d..d0f621fd09b 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2143,6 +2143,7 @@ class Form function formconfirm($page, $title, $question, $action, $formquestion='', $selectedchoice="", $useajax=0, $height=170, $width=500) { global $langs,$conf; + global $useglobalvars; $more=''; $formconfirm=''; @@ -2241,13 +2242,13 @@ class Form } } - // New code using jQuery only + // Show JQuery confirm box. Note that global var $useglobalvars is used inside this template include(DOL_DOCUMENT_ROOT.'/core/tpl/ajax/formconfirm.tpl.php'); } else { $formconfirm.= "\n\n"; - + $formconfirm.= '
'."\n"; $formconfirm.= ''; $formconfirm.= ''."\n"; @@ -2279,7 +2280,7 @@ class Form $formconfirm.= "
\n"; $formconfirm.= '
'; - + $formconfirm.= "\n"; } diff --git a/htdocs/core/tpl/ajax/formconfirm.tpl.php b/htdocs/core/tpl/ajax/formconfirm.tpl.php index d3367c7a7c1..7f5bb51910e 100644 --- a/htdocs/core/tpl/ajax/formconfirm.tpl.php +++ b/htdocs/core/tpl/ajax/formconfirm.tpl.php @@ -25,6 +25,20 @@