Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
fusiondirectory
fusiondirectory
Commits
e1e52839
Commit
e1e52839
authored
8 years ago
by
Côme Chilliet
Browse files
Options
Download
Patches
Plain Diff
Improved msg_dialog code
parent
3ba59e98
dev
6342-update-the-locales-for-1-5
6344-template-issue-when-creating-a-template-with-empty-password-error-message-should-not-be-seen
6365-core-locking-mechanism-is-not-changing-the-mail-ressource-it-does-lock-the-mail-account
6365-core-when-lock-mechanism-is-trigger-the-user-should-not-be-editable-if-not-unlock
6378-orcid-test-method-is-wrong-and-break-orcid-saving
core-php8
master
fusiondirectory-1.5
fusiondirectory-1.4
fusiondirectory-1.3.1
fusiondirectory-1.3
fusiondirectory-1.2.3
fusiondirectory-1.2.2
fusiondirectory-1.2.1
fusiondirectory-1.2
fusiondirectory-1.1.1
fusiondirectory-1.1
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
include/class_msg_dialog.inc
+48
-41
include/class_msg_dialog.inc
with
48 additions
and
41 deletions
+48
-41
include/class_msg_dialog.inc
+
48
−
41
View file @
e1e52839
...
...
@@ -23,12 +23,12 @@
* Source code for class message dialog
*/
define
(
"
INFO_DIALOG
"
,
10001
);
define
(
"
WARNING_DIALOG
"
,
10002
);
define
(
"
ERROR_DIALOG
"
,
10003
);
define
(
"
LDAP_ERROR
"
,
10003
);
// LDAP_ERROR is the same as ERROR_DIALOG
define
(
"
CONFIRM_DIALOG
"
,
10004
);
define
(
"
FATAL_ERROR_DIALOG
"
,
10006
);
define
(
'
INFO_DIALOG
'
,
10001
);
define
(
'
WARNING_DIALOG
'
,
10002
);
define
(
'
ERROR_DIALOG
'
,
10003
);
define
(
'
LDAP_ERROR
'
,
10003
);
// LDAP_ERROR is the same as ERROR_DIALOG
define
(
'
CONFIRM_DIALOG
'
,
10004
);
define
(
'
FATAL_ERROR_DIALOG
'
,
10006
);
/*!
* \brief This class contains all the function needed to make messages
...
...
@@ -36,13 +36,12 @@ define("FATAL_ERROR_DIALOG", 10006);
*/
class
msg_dialog
{
private
$s_Title
=
"
Undefined
"
;
private
$s_Message
=
"
Undefined
"
;
private
$s_Title
=
'
Undefined
'
;
private
$s_Message
=
'
Undefined
'
;
private
$i_Type
=
INFO_DIALOG
;
private
$i_ID
=
0
;
private
$a_Trace
=
array
();
/*!
* \brief Message dialog constructor
*
...
...
@@ -53,54 +52,61 @@ class msg_dialog
* \param string $i_type The type of the message dialog, by default = INFO_DIALOG
*/
public
function
__construct
(
$s_title
,
$s_message
,
$i_type
)
{
if
(
!
in_array
(
$i_type
,
array
(
INFO_DIALOG
,
WARNING_DIALOG
,
ERROR_DIALOG
,
CONFIRM_DIALOG
,
FATAL_ERROR_DIALOG
)))
{
trigger_error
(
'Invalid msg_dialog type.'
);
$i_type
=
INFO_DIALOG
;
}
$this
->
i_ID
=
preg_replace
(
'/[^0-9]*/'
,
''
,
microtime
());
$this
->
s_Title
=
$s_title
;
$this
->
s_Message
=
$s_message
;
$this
->
i_Type
=
$i_type
;
}
protected
function
show
()
{
global
$config
;
if
(
empty
(
$s_
m
essage
))
{
if
(
empty
(
$
this
->
s_
M
essage
))
{
return
;
}
if
(
!
in_array
(
$i_type
,
array
(
INFO_DIALOG
,
WARNING_DIALOG
,
ERROR_DIALOG
,
CONFIRM_DIALOG
,
FATAL_ERROR_DIALOG
)))
{
trigger_error
(
"Invalid msg_dialog type."
);
$i_type
=
INFO_DIALOG
;
}
if
((
!
session
::
is_set
(
'errorsAlreadyPosted'
))
||
!
is_array
(
session
::
get
(
'errorsAlreadyPosted'
)))
{
session
::
set
(
'errorsAlreadyPosted'
,
array
());
}
$errorsAlreadyPosted
=
session
::
get
(
'errorsAlreadyPosted'
);
if
(
!
isset
(
$errorsAlreadyPosted
[
$s_
t
itle
.
$s_
m
essage
]))
{
$errorsAlreadyPosted
[
$s_
t
itle
.
$s_
m
essage
]
=
0
;
if
(
!
isset
(
$errorsAlreadyPosted
[
$
this
->
s_
T
itle
.
$
this
->
s_
M
essage
]))
{
$errorsAlreadyPosted
[
$
this
->
s_
T
itle
.
$
this
->
s_
M
essage
]
=
0
;
}
$errorsAlreadyPosted
[
$s_
t
itle
.
$s_
m
essage
]
++
;
$errorsAlreadyPosted
[
$
this
->
s_
T
itle
.
$
this
->
s_
M
essage
]
++
;
if
(
$
errorsAlreadyPosted
[
$s_title
.
$s_message
]
<=
1
)
{
session
::
set
(
'
errorsAlreadyPosted
'
,
$errorsAlreadyPosted
);
$this
->
i_ID
=
preg_replace
(
"/[^0-9]*/"
,
""
,
microtime
());
$this
->
s_Title
=
$s_title
;
$this
->
s_Message
=
$s_message
;
$this
->
i_Type
=
$i_type
;
if
(
$errorsAlreadyPosted
[
$this
->
s_Title
.
$this
->
s_Message
]
>
1
)
{
/* Skip if the same message was already reported once */
return
;
}
/* Append trace information, only if error messages are enabled */
if
(
isset
(
$config
)
&&
is_object
(
$config
)
&&
$config
->
get_cfg_value
(
"
displayerrors
"
)
==
"
TRUE
"
)
{
$this
->
a_Trace
=
debug_backtrace
();
}
if
(
!
session
::
is_set
(
'msg_dialogs'
)
)
{
session
::
set
(
'msg_dialogs'
,
array
()
);
}
if
(
$this
->
i_Type
==
FATAL_ERROR_DIALOG
)
{
restore_error_handler
();
error_reporting
(
E_ALL
);
echo
$this
->
execute
(
);
/* Append trace information, only if error messages are enabled */
if
(
isset
(
$config
)
&&
is_object
(
$config
)
&&
$config
->
get_cfg_value
(
'
displayerrors
'
)
==
'
TRUE
'
)
{
$this
->
a_Trace
=
debug_backtrace
();
}
if
(
$this
->
i_Type
==
FATAL_ERROR_DIALOG
)
{
restore_error_handler
(
);
error_reporting
(
E_ALL
);
echo
$this
->
execute
();
}
else
{
if
(
session
::
is_set
(
'msg_dialogs'
))
{
$msg_dialogs
=
session
::
get
(
'msg_dialogs'
);
}
else
{
$msg_dialogs
=
session
::
get
(
'msg_dialogs'
);
$msg_dialogs
[]
=
$this
;
session
::
set
(
'msg_dialogs'
,
$msg_dialogs
);
$msg_dialogs
=
array
();
}
$msg_dialogs
[]
=
$this
;
session
::
set
(
'msg_dialogs'
,
$msg_dialogs
);
}
session
::
set
(
'errorsAlreadyPosted'
,
$errorsAlreadyPosted
);
}
/*!
...
...
@@ -114,7 +120,8 @@ class msg_dialog
*/
public
static
function
display
(
$s_title
,
$s_message
,
$i_type
=
INFO_DIALOG
)
{
new
msg_dialog
(
$s_title
,
$s_message
,
$i_type
);
$dialog
=
new
msg_dialog
(
$s_title
,
$s_message
,
$i_type
);
$dialog
->
show
();
}
/*
...
...
@@ -125,7 +132,7 @@ class msg_dialog
public
static
function
displayChecks
(
$messages
)
{
foreach
(
$messages
as
$error
)
{
msg_dialog
::
display
(
_
(
'Error'
),
$error
,
ERROR_DIALOG
);
static
::
display
(
_
(
'Error'
),
$error
,
ERROR_DIALOG
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets