2
0
forked from Wavyzz/dolibarr

Prepare feature "Never show this message again"

This commit is contained in:
Laurent Destailleur
2019-08-18 18:36:18 +02:00
parent 729340420f
commit 2f46b40da2
3 changed files with 21 additions and 9 deletions

View File

@@ -6398,10 +6398,11 @@ function setEventMessage($mesgs, $style = 'mesgs')
* @param string $mesg Message string
* @param array $mesgs Message array
* @param string $style Which style to use ('mesgs' by default, 'warnings', 'errors')
* @param string $messagekey A key to be used to allow the feature "Never show this message again"
* @return void
* @see dol_htmloutput_events()
*/
function setEventMessages($mesg, $mesgs, $style = 'mesgs')
function setEventMessages($mesg, $mesgs, $style = 'mesgs', $messagekey = '')
{
if (empty($mesg) && empty($mesgs))
{
@@ -6409,12 +6410,21 @@ function setEventMessages($mesg, $mesgs, $style = 'mesgs')
}
else
{
if (! in_array((string) $style, array('mesgs','warnings','errors'))) dol_print_error('', 'Bad parameter style='.$style.' for setEventMessages');
if (empty($mesgs)) setEventMessage($mesg, $style);
else
if ($messagekey)
{
if (! empty($mesg) && ! in_array($mesg, $mesgs)) setEventMessage($mesg, $style); // Add message string if not already into array
setEventMessage($mesgs, $style);
// Complete message with a js link to set a cookie "DOLHIDEMESSAGE".$messagekey;
// TODO
$mesg.='';
}
if (empty($messagekey) || empty($_COOKIE["DOLHIDEMESSAGE".$messagekey]))
{
if (! in_array((string) $style, array('mesgs','warnings','errors'))) dol_print_error('', 'Bad parameter style='.$style.' for setEventMessages');
if (empty($mesgs)) setEventMessage($mesg, $style);
else
{
if (! empty($mesg) && ! in_array($mesg, $mesgs)) setEventMessage($mesg, $style); // Add message string if not already into array
setEventMessage($mesgs, $style);
}
}
}
}