Fix: try another method more clean and can be deployed on any type of
message
This commit is contained in:
parent
cdc9dda11e
commit
9cdba5bb61
@ -113,7 +113,7 @@ 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);
|
||||
$_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
|
||||
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -343,9 +343,7 @@ if ($action == 'create')
|
||||
print "</form>";
|
||||
}
|
||||
|
||||
dol_htmloutput_events($mesgs,$errors,$warnings);
|
||||
|
||||
llxFooter();
|
||||
|
||||
$db->close();
|
||||
?>
|
||||
|
||||
@ -554,9 +554,7 @@ if ($action == 'confirm_valid' && $confirm == 'yes')
|
||||
if ($object->id > 0)
|
||||
{
|
||||
$object->valid($user);
|
||||
|
||||
$_SESSION['dol_events']['mesgs']='<div class="ok">'.$langs->trans("MailingSuccessfullyValidated").'</div>';
|
||||
|
||||
setEventMessage($langs->trans("MailingSuccessfullyValidated"));
|
||||
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -281,8 +281,7 @@ else if ($action == 'add' && $user->rights->propale->creer)
|
||||
|
||||
if (empty($datep))
|
||||
{
|
||||
$errors[]=$langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date"));
|
||||
$_SESSION['dol_events']['errors']=$errors;
|
||||
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors');
|
||||
header("Location: ".DOL_URL_ROOT.'/comm/addpropal.php?socid='.$socid.'&action=create');
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ 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);
|
||||
$_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
|
||||
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
|
||||
exit;
|
||||
}
|
||||
@ -147,7 +147,6 @@ if ($object->id > 0)
|
||||
$head = propal_prepare_head($object);
|
||||
dol_fiche_head($head, 'document', $langs->trans('Proposal'), 0, 'propal');
|
||||
|
||||
|
||||
// Construit liste des fichiers
|
||||
$filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1);
|
||||
$totalsize=0;
|
||||
|
||||
@ -122,7 +122,7 @@ else 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);
|
||||
$_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
|
||||
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -1444,8 +1444,6 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
||||
$result=$mailfile->sendfile();
|
||||
if ($result)
|
||||
{
|
||||
$mesgs[]=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); // Must not contain "
|
||||
|
||||
$error=0;
|
||||
|
||||
// Initialisation donnees
|
||||
@ -1471,7 +1469,8 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
|
||||
{
|
||||
// Redirect here
|
||||
// This avoid sending mail twice if going out and then back to page
|
||||
$_SESSION['dol_events']['mesgs'] = $mesgs;
|
||||
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
|
||||
setEventMessage($mesg);
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$object->id);
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ 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);
|
||||
$_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
|
||||
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
|
||||
|
||||
$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);
|
||||
$_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
|
||||
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -3448,52 +3448,43 @@ function get_date_range($date_start,$date_end,$format = '',$outputlangs='')
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set event message in dol_events session
|
||||
*
|
||||
* @param string $mesgstring Message
|
||||
* @param string $style Which style to use ('mesgs', 'warnings', 'errors')
|
||||
* @return void
|
||||
* @see dol_htmloutput_events
|
||||
*/
|
||||
function setEventMessage($mesgstring, $style='mesgs')
|
||||
{
|
||||
$_SESSION['dol_events'][$style][] = $mesgstring;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print formated messages to output (Used to show messages on html output).
|
||||
*
|
||||
* @param array $mesgs Messages array
|
||||
* @param array $errors Errors array
|
||||
* @param array $warnings Warnings array
|
||||
* @return void
|
||||
*
|
||||
* @see dol_htmloutput_mesg
|
||||
*/
|
||||
function dol_htmloutput_events($mesgs=array(),$errors=array(),$warnings=array())
|
||||
function dol_htmloutput_events()
|
||||
{
|
||||
// Show mesgs
|
||||
if (is_array($mesgs) && ! empty($mesgs)) {
|
||||
if (isset($_SESSION['dol_events']['mesgs'])) {
|
||||
if (! is_array($_SESSION['dol_events']['mesgs'])) {
|
||||
$_SESSION['dol_events']['mesgs']=array($_SESSION['dol_events']['mesgs']); // For backward compatibility
|
||||
}
|
||||
$mesgs = array_merge($mesgs, $_SESSION['dol_events']['mesgs']);
|
||||
unset($_SESSION['dol_events']['mesgs']);
|
||||
}
|
||||
dol_htmloutput_mesg('',$mesgs);
|
||||
if (isset($_SESSION['dol_events']['mesgs'])) {
|
||||
dol_htmloutput_mesg('', $_SESSION['dol_events']['mesgs']);
|
||||
unset($_SESSION['dol_events']['mesgs']);
|
||||
}
|
||||
|
||||
// Show errors
|
||||
if (is_array($errors) && ! empty($errors)) {
|
||||
if (isset($_SESSION['dol_events']['errors'])) {
|
||||
if (! is_array($_SESSION['dol_events']['errors'])) {
|
||||
$_SESSION['dol_events']['errors']=array($_SESSION['dol_events']['errors']); // For backward compatibility
|
||||
}
|
||||
$errors = array_merge($errors, $_SESSION['dol_events']['errors']);
|
||||
unset($_SESSION['dol_events']['errors']);
|
||||
}
|
||||
dol_htmloutput_mesg('',$errors, 'error');
|
||||
if (isset($_SESSION['dol_events']['errors'])) {
|
||||
dol_htmloutput_mesg('', $_SESSION['dol_events']['errors'], 'error');
|
||||
unset($_SESSION['dol_events']['errors']);
|
||||
}
|
||||
|
||||
// Show warnings
|
||||
if (is_array($warnings) && ! empty($warnings)) {
|
||||
if (isset($_SESSION['dol_events']['warnings'])) {
|
||||
if (! is_array($_SESSION['dol_events']['warnings'])) {
|
||||
$_SESSION['dol_events']['warnings']=array($_SESSION['dol_events']['warnings']); // For backward compatibility
|
||||
}
|
||||
$warnings = array_merge($warnings, $_SESSION['dol_events']['warnings']);
|
||||
unset($_SESSION['dol_events']['warnings']);
|
||||
}
|
||||
dol_htmloutput_mesg('',$warnings, 'warning');
|
||||
if (isset($_SESSION['dol_events']['warnings'])) {
|
||||
dol_htmloutput_mesg('', $_SESSION['dol_events']['warnings'], 'warning');
|
||||
unset($_SESSION['dol_events']['warnings']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -437,8 +437,6 @@ if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile'
|
||||
$result=$mailfile->sendfile();
|
||||
if ($result)
|
||||
{
|
||||
$_SESSION['dol_events']['mesgs']=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
|
||||
|
||||
$error=0;
|
||||
|
||||
// Initialisation donnees
|
||||
@ -466,6 +464,8 @@ if ($action == 'send' && ! GETPOST('addfile','alpha') && ! GETPOST('removedfile'
|
||||
{
|
||||
// Redirect here
|
||||
// This avoid sending mail twice if going out and then back to page
|
||||
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2));
|
||||
setEventMessage($mesg);
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ else 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);
|
||||
$_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
|
||||
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ else 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);
|
||||
$_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
|
||||
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -722,24 +722,9 @@ $bcdd=array(0=>'class="impair drag drop"',1=>'class="pair drag drop"');
|
||||
$bcnd=array(0=>'class="impair nodrag nodrop"',1=>'class="pair nodrag nodrop"');
|
||||
|
||||
// Define messages variables
|
||||
$mesg=''; $mesgs=array(); $warning=''; $warnings=array(); $error=0; $errors=array();
|
||||
|
||||
// TODO For backward compatibility, see dol_htmloutput_events() in functions.lib.php
|
||||
if (isset($_SESSION['dol_events']))
|
||||
{
|
||||
if (is_array($mesgs) && isset($_SESSION['dol_events']['mesgs'])) {
|
||||
$mesgs = array_merge($mesgs, $_SESSION['dol_events']['mesgs']);
|
||||
}
|
||||
if (is_array($errors) && isset($_SESSION['dol_events']['errors'])) {
|
||||
$errors = array_merge($errors, $_SESSION['dol_events']['errors']);
|
||||
$mesgs = array_merge($mesgs, $_SESSION['dol_events']['errors']); // For backward compatibility
|
||||
}
|
||||
if (is_array($warnings) && isset($_SESSION['dol_events']['warnings'])) {
|
||||
$warnings = array_merge($warnings, $_SESSION['dol_events']['warnings']);
|
||||
}
|
||||
|
||||
unset($_SESSION['dol_events']);
|
||||
}
|
||||
$mesg=''; $warning=''; $error=0;
|
||||
// deprecated, see setEventMessage() and dol_htmloutput_events()
|
||||
$mesgs=array(); $warnings=array(); $errors=array();
|
||||
|
||||
// Constants used to defined number of lines in textarea
|
||||
if (empty($conf->browser->firefox))
|
||||
@ -1670,6 +1655,9 @@ if (! function_exists("llxFooter"))
|
||||
{
|
||||
global $conf, $langs, $dolibarr_auto_user, $micro_start_time;
|
||||
|
||||
// Global html output events ($mesgs, $errors, $warnings)
|
||||
dol_htmloutput_events();
|
||||
|
||||
// Core error message
|
||||
if (defined("MAIN_CORE_ERROR") && constant("MAIN_CORE_ERROR") == 1)
|
||||
{
|
||||
|
||||
@ -115,7 +115,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->projet->s
|
||||
$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).
|
||||
dol_delete_file($file,0,0,0,$object);
|
||||
$_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
|
||||
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ 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);
|
||||
$_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
|
||||
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id);
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ 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);
|
||||
$_SESSION['dol_events']['mesgs'] = '<div class="ok">'.$langs->trans("FileWasRemoved",GETPOST('urlfile')).'</div>';
|
||||
setEventMessage($langs->trans("FileWasRemoved",GETPOST('urlfile')));
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
|
||||
exit;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user