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
7b7a5218
Verified
Commit
7b7a5218
authored
2 months ago
by
dockx thibault
Browse files
Options
Download
Patches
Plain Diff
(User) - locking mechanism
Lock induces a read only for all tabs.
parent
38aa3a29
dev
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
6378-orcid-test-method-is-wrong-and-break-orcid-saving
core-php8
master
fusiondirectory-1.5
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/simpleplugin/class_simplePlugin.inc
+13
-0
include/simpleplugin/class_simplePlugin.inc
plugins/personal/generic/class_user.inc
+9
-6
plugins/personal/generic/class_user.inc
with
22 additions
and
6 deletions
+22
-6
include/simpleplugin/class_simplePlugin.inc
+
13
−
0
View file @
7b7a5218
...
@@ -38,6 +38,8 @@ class simplePlugin implements SimpleTab
...
@@ -38,6 +38,8 @@ class simplePlugin implements SimpleTab
* associative array that stores attributeLdapName => reference on object
* associative array that stores attributeLdapName => reference on object
*/
*/
public
$attributesAccess
=
[];
public
$attributesAccess
=
[];
// This allows children class to get readOnly automatically via static state or class-level state
private
static
bool
$user_locked
=
FALSE
;
/*!
/*!
\brief Mark plugin as account
\brief Mark plugin as account
...
@@ -158,6 +160,11 @@ class simplePlugin implements SimpleTab
...
@@ -158,6 +160,11 @@ class simplePlugin implements SimpleTab
$this
->
parent
=
$parent
;
$this
->
parent
=
$parent
;
$this
->
mainTab
=
$mainTab
;
$this
->
mainTab
=
$mainTab
;
// This class-level state allows children to get readOnly automatically.
if
(
self
::
$user_locked
)
{
$this
->
read_only
=
true
;
}
try
{
try
{
$plInfo
=
pluglist
::
pluginInfos
(
get_class
(
$this
));
$plInfo
=
pluglist
::
pluginInfos
(
get_class
(
$this
));
}
catch
(
UnknownClassException
$e
)
{
}
catch
(
UnknownClassException
$e
)
{
...
@@ -299,6 +306,12 @@ class simplePlugin implements SimpleTab
...
@@ -299,6 +306,12 @@ class simplePlugin implements SimpleTab
}
}
}
}
public
static
function
setUserLocked
(
bool
$locked
):
void
{
self
::
$user_locked
=
$locked
;
}
protected
function
loadAttributes
()
protected
function
loadAttributes
()
{
{
// We load attributes values
// We load attributes values
...
...
This diff is collapsed.
Click to expand it.
plugins/personal/generic/class_user.inc
+
9
−
6
View file @
7b7a5218
...
@@ -45,6 +45,7 @@ class PostalAddressAttribute extends TextAreaAttribute
...
@@ -45,6 +45,7 @@ class PostalAddressAttribute extends TextAreaAttribute
class
user
extends
simplePlugin
class
user
extends
simplePlugin
{
{
// This is used to see if the password is locked. The "was" is better interpreted as "is" - it is historical here.
private
$was_locked
;
private
$was_locked
;
static
function
plInfo
():
array
static
function
plInfo
():
array
...
@@ -262,6 +263,14 @@ class user extends simplePlugin
...
@@ -262,6 +263,14 @@ class user extends simplePlugin
global
$config
;
global
$config
;
parent
::
__construct
(
$dn
,
$object
,
$parent
,
$mainTab
);
parent
::
__construct
(
$dn
,
$object
,
$parent
,
$mainTab
);
// verify if the attribute password is locked
$this
->
was_locked
=
$this
->
attributesAccess
[
'userPassword'
]
->
isLocked
();
if
(
$this
->
was_locked
){
$this
->
read_only
=
TRUE
;
// This will update the parent class (simplePlugin) via class-level state allowing children to get read only state.
self
::
setUserLocked
(
true
);
}
if
(
$this
->
is_template
&&
!
$this
->
initially_was_account
)
{
if
(
$this
->
is_template
&&
!
$this
->
initially_was_account
)
{
$this
->
attributesAccess
[
'userPassword'
]
->
setValue
(
'%askme%'
);
$this
->
attributesAccess
[
'userPassword'
]
->
setValue
(
'%askme%'
);
...
@@ -274,13 +283,7 @@ class user extends simplePlugin
...
@@ -274,13 +283,7 @@ class user extends simplePlugin
$filename
=
'./plugins/users/images/default.jpg'
;
$filename
=
'./plugins/users/images/default.jpg'
;
$fd
=
fopen
(
$filename
,
'rb'
);
$fd
=
fopen
(
$filename
,
'rb'
);
$this
->
attributesAccess
[
'jpegPhoto'
]
->
setPlaceholder
(
fread
(
$fd
,
filesize
(
$filename
)));
$this
->
attributesAccess
[
'jpegPhoto'
]
->
setPlaceholder
(
fread
(
$fd
,
filesize
(
$filename
)));
$this
->
was_locked
=
$this
->
attributesAccess
[
'userPassword'
]
->
isLocked
();
if
(
$this
->
was_locked
){
$this
->
read_only
=
TRUE
;
$warning
=
new
FusionDirectoryWarning
(
nl2br
(
htmlescape
(
sprintf
(
_
(
"This user account is locked ! Unlock to edit first."
)))));
$warning
->
display
();
}
// Do not apply automatic snap on templates nor if the DN is not yet processed (new creation from template)
// Do not apply automatic snap on templates nor if the DN is not yet processed (new creation from template)
if
(
$this
->
is_template
!==
TRUE
&&
$this
->
dn
!==
'new'
)
{
if
(
$this
->
is_template
!==
TRUE
&&
$this
->
dn
!==
'new'
)
{
...
...
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