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 string $mesg Message string
* @param array $mesgs Message array * @param array $mesgs Message array
* @param string $style Which style to use ('mesgs' by default, 'warnings', 'errors') * @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 * @return void
* @see dol_htmloutput_events() * @see dol_htmloutput_events()
*/ */
function setEventMessages($mesg, $mesgs, $style = 'mesgs') function setEventMessages($mesg, $mesgs, $style = 'mesgs', $messagekey = '')
{ {
if (empty($mesg) && empty($mesgs)) if (empty($mesg) && empty($mesgs))
{ {
@@ -6409,12 +6410,21 @@ function setEventMessages($mesg, $mesgs, $style = 'mesgs')
} }
else else
{ {
if (! in_array((string) $style, array('mesgs','warnings','errors'))) dol_print_error('', 'Bad parameter style='.$style.' for setEventMessages'); if ($messagekey)
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 // Complete message with a js link to set a cookie "DOLHIDEMESSAGE".$messagekey;
setEventMessage($mesgs, $style); // 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);
}
} }
} }
} }

View File

@@ -415,9 +415,11 @@ function redirectToContainer($containerref, $containeraliasalt = '', $containeri
if (defined('USEDOLIBARREDITOR')) if (defined('USEDOLIBARREDITOR'))
{ {
print '<div class="margintoponly marginleftonly">'; /*print '<div class="margintoponly marginleftonly">';
print "This page contains dynamic code that make a redirect to '".$containerref."' in your current context. Redirect has been canceled as it is not supported in edition mode."; print "This page contains dynamic code that make a redirect to '".$containerref."' in your current context. Redirect has been canceled as it is not supported in edition mode.";
print '</div>'; print '</div>';*/
$text = "This page contains dynamic code that make a redirect to '".$containerref."' in your current context. Redirect has been canceled as it is not supported in edition mode.";
setEventMessages($text, null, 'warnings', 'WEBSITEREDIRECTDISABLED'.$containerref);
return; return;
} }

View File

@@ -1969,8 +1969,8 @@ if (! GETPOST('hide_websitemenu'))
} }
//print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditMenu")).'" name="editmenu">'; //print '<input type="submit" class="button"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditMenu")).'" name="editmenu">';
print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("CloneSite")).'" name="createfromclone">';
print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("ExportSite")).'" name="exportsite">'; print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("ExportSite")).'" name="exportsite">';
print '<input type="submit" class="button bordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("CloneSite")).'" name="createfromclone">';
print '<input type="submit" class="buttonDelete bordertransp" name="deletesite" value="'.$langs->trans("Delete").'"'.($atleastonepage?' disabled="disabled"':'').'>'; print '<input type="submit" class="buttonDelete bordertransp" name="deletesite" value="'.$langs->trans("Delete").'"'.($atleastonepage?' disabled="disabled"':'').'>';