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.
This commit is contained in:
parent
1022c73c24
commit
158930eb7b
@ -93,34 +93,12 @@ if (preg_match('/\.\./',$upload_dir) || preg_match('/[<>|]/',$upload_dir))
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Action
|
* Action
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
// None
|
||||||
if ($action == 'remove_file') // Remove a file
|
|
||||||
{
|
|
||||||
clearstatcache();
|
|
||||||
|
|
||||||
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)
|
if ($section)
|
||||||
{
|
{
|
||||||
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php');
|
require_once(DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php');
|
||||||
|
$useglobalvars=1;
|
||||||
$form = new Form($db);
|
$form = new Form($db);
|
||||||
$formquestion=array('urlfile'=>array('type'=>'hidden','value'=>'','name'=>'urlfile'));
|
$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');
|
print $form->formconfirm(DOL_URL_ROOT.'/ecm/index.php'.($param?'?':'').(preg_replace('/^&/','',$param)),$langs->trans("DeleteFile"),$langs->trans("ConfirmDeleteFile"),'confirm_deletefile',$formquestion,"no",'deletefile');
|
||||||
|
|||||||
@ -2143,6 +2143,7 @@ class Form
|
|||||||
function formconfirm($page, $title, $question, $action, $formquestion='', $selectedchoice="", $useajax=0, $height=170, $width=500)
|
function formconfirm($page, $title, $question, $action, $formquestion='', $selectedchoice="", $useajax=0, $height=170, $width=500)
|
||||||
{
|
{
|
||||||
global $langs,$conf;
|
global $langs,$conf;
|
||||||
|
global $useglobalvars;
|
||||||
|
|
||||||
$more='';
|
$more='';
|
||||||
$formconfirm='';
|
$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');
|
include(DOL_DOCUMENT_ROOT.'/core/tpl/ajax/formconfirm.tpl.php');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$formconfirm.= "\n<!-- begin form_confirm page=".$page." -->\n";
|
$formconfirm.= "\n<!-- begin form_confirm page=".$page." -->\n";
|
||||||
|
|
||||||
$formconfirm.= '<form method="POST" action="'.$page.'" class="notoptoleftroright">'."\n";
|
$formconfirm.= '<form method="POST" action="'.$page.'" class="notoptoleftroright">'."\n";
|
||||||
$formconfirm.= '<input type="hidden" name="action" value="'.$action.'">';
|
$formconfirm.= '<input type="hidden" name="action" value="'.$action.'">';
|
||||||
$formconfirm.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n";
|
$formconfirm.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n";
|
||||||
@ -2279,7 +2280,7 @@ class Form
|
|||||||
|
|
||||||
$formconfirm.= "</form>\n";
|
$formconfirm.= "</form>\n";
|
||||||
$formconfirm.= '<br>';
|
$formconfirm.= '<br>';
|
||||||
|
|
||||||
$formconfirm.= "<!-- end form_confirm -->\n";
|
$formconfirm.= "<!-- end form_confirm -->\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,20 @@
|
|||||||
<?php echo img_help('','').' '.$question; ?>
|
<?php echo img_help('','').' '.$question; ?>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Warning: 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
<?php if (! empty($useglobalvars)) { ?>
|
||||||
|
var inputok=<?php echo json_encode($inputok); ?>;
|
||||||
|
var inputko=<?php echo json_encode($inputko); ?>;
|
||||||
|
var pageyes='<?php echo dol_escape_js($pageyes?$pageyes:''); ?>';
|
||||||
|
var pageno='<?php echo dol_escape_js($pageno?$pageno:''); ?>';
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
$( "#<?php echo $dialogconfirm; ?>" ).dialog({
|
$( "#<?php echo $dialogconfirm; ?>" ).dialog({
|
||||||
autoOpen: <?php echo ($autoOpen ? 'true' : 'false'); ?>,
|
autoOpen: <?php echo ($autoOpen ? 'true' : 'false'); ?>,
|
||||||
@ -36,8 +50,10 @@ $(function() {
|
|||||||
buttons: {
|
buttons: {
|
||||||
'<?php echo dol_escape_js($langs->transnoentities("Yes")); ?>': function() {
|
'<?php echo dol_escape_js($langs->transnoentities("Yes")); ?>': function() {
|
||||||
var options="";
|
var options="";
|
||||||
var inputok = <?php echo json_encode($inputok); ?>;
|
<?php if (empty($useglobalvars)) { ?>
|
||||||
|
var inputok = <?php echo json_encode($inputok); ?>;
|
||||||
var pageyes = '<?php echo dol_escape_js($pageyes?$pageyes:''); ?>';
|
var pageyes = '<?php echo dol_escape_js($pageyes?$pageyes:''); ?>';
|
||||||
|
<?php } ?>
|
||||||
if (inputok.length>0) {
|
if (inputok.length>0) {
|
||||||
$.each(inputok, function(i, inputname) {
|
$.each(inputok, function(i, inputname) {
|
||||||
var more = '';
|
var more = '';
|
||||||
@ -54,8 +70,10 @@ $(function() {
|
|||||||
},
|
},
|
||||||
'<?php echo dol_escape_js($langs->transnoentities("No")); ?>': function() {
|
'<?php echo dol_escape_js($langs->transnoentities("No")); ?>': function() {
|
||||||
var options = '';
|
var options = '';
|
||||||
|
<?php if (empty($useglobalvars)) { ?>
|
||||||
var inputko = <?php echo json_encode($inputko); ?>;
|
var inputko = <?php echo json_encode($inputko); ?>;
|
||||||
var pageno='<?php echo dol_escape_js($pageno?$pageno:''); ?>';
|
var pageno='<?php echo dol_escape_js($pageno?$pageno:''); ?>';
|
||||||
|
<?php } ?>
|
||||||
if (inputko.length>0) {
|
if (inputko.length>0) {
|
||||||
$.each(inputko, function(i, inputname) {
|
$.each(inputko, function(i, inputname) {
|
||||||
var more = '';
|
var more = '';
|
||||||
|
|||||||
@ -379,7 +379,7 @@ print $langs->trans("ECMAreaDesc2")."<br>";
|
|||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
|
|
||||||
// Confirm remove file
|
// Confirm remove file
|
||||||
if ($action == 'delete')
|
if ($action == 'delete' && empty($conf->use_javascript_ajax))
|
||||||
{
|
{
|
||||||
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?section='.$section.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile','','',1);
|
$ret=$form->form_confirm($_SERVER["PHP_SELF"].'?section='.$section.'&urlfile='.urlencode($_GET["urlfile"]), $langs->trans('DeleteFile'), $langs->trans('ConfirmDeleteFile'), 'confirm_deletefile','','',1);
|
||||||
if ($ret == 'html') print '<br>';
|
if ($ret == 'html') print '<br>';
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user