26 define(
'INFO_DIALOG', 10001);
27 define(
'WARNING_DIALOG', 10002);
28 define(
'ERROR_DIALOG', 10003);
30 define(
'LDAP_ERROR', 10003);
31 define(
'CONFIRM_DIALOG', 10004);
32 define(
'FATAL_ERROR_DIALOG', 10006);
57 public function __construct (
string $title,
string $message,
int $type = INFO_DIALOG, array $trace = [])
59 if (!in_array($type, [INFO_DIALOG,WARNING_DIALOG,ERROR_DIALOG,CONFIRM_DIALOG,FATAL_ERROR_DIALOG])) {
60 trigger_error(
'Invalid msg_dialog type.');
64 $this->i_ID = (int)preg_replace(
'/[^0-9]*/',
'', microtime());
65 $this->s_Title = $title;
66 $this->s_Message = $message;
67 $this->i_Type = $type;
68 $this->a_Trace = $trace;
71 protected function show ()
75 if (empty($this->s_Message)) {
83 $errorsAlreadyPosted =
session::get(
'errorsAlreadyPosted');
84 if (!isset($errorsAlreadyPosted[$this->s_Title.$this->s_Message])) {
85 $errorsAlreadyPosted[$this->s_Title.$this->s_Message] = 0;
87 $errorsAlreadyPosted[$this->s_Title.$this->s_Message]++;
89 session::set(
'errorsAlreadyPosted', $errorsAlreadyPosted);
91 if ($errorsAlreadyPosted[$this->s_Title.$this->s_Message] > 1) {
97 if (isset($config) && is_object($config) &&
98 $config->get_cfg_value(
'displayerrors') ==
'TRUE') {
99 if (empty($this->a_Trace)) {
100 $this->a_Trace = debug_backtrace();
110 $msg_dialogs[] = $this;
125 public static function display ($title,
string $message,
int $type = INFO_DIALOG, array $trace = [])
127 if ($type === FATAL_ERROR_DIALOG) {
132 static::display(...$title->computeMsgDialogParameters());
135 $dialog =
new msg_dialog($title, $message, $type, $trace);
144 public static function displayChecks ($messages)
146 foreach ($messages as $error) {
148 static::display(...$error->computeMsgDialogParameters());
150 static::display(_(
'Error'), $error, ERROR_DIALOG);
160 public function getId ():
int 172 return isset($_POST[
'MSG_OK'.$this->i_ID]);
182 'type' => $this->i_Type,
183 'title' => $this->s_Title,
184 'message' => $this->s_Message,
185 'trace' => ((count($this->a_Trace) > 0) ? print_a($this->a_Trace, TRUE) :
''),
202 foreach ($msg_dialogs as $dialog) {
203 $dialogInfos[] = $dialog->getDialogInfos();
204 $dialogIds[] = $dialog->getId();
208 $smarty->assign(
'dialogInfos', $dialogInfos);
209 $smarty->assign(
'dialogIds', $dialogIds);
get_template_path($filename='', $plugin=FALSE, $path='')
Return themed path for specified base file.
static get($name)
Accessor of a session var.
static get_dialogs()
Accessor of the message dialog rendered HTML.
is_confirmed()
Check if the message is confirmed by user.
__construct(string $title, string $message, int $type=INFO_DIALOG, array $trace=[])
Message dialog constructor.
static display($title, string $message, int $type=INFO_DIALOG, array $trace=[])
Display a message dialog.
static set($name, $value)
Set a value in a session.
getDialogInfos()
Return an array with infos for the template.
& get_smarty()
Get global smarty object.
This class contains all the function needed to make messages dialogs.
Fatal error class. Does not extend FusionDirectoryError.
Parent class for all errors in FusionDirectory.
static is_set($name)
Check if the name of the session is set.