Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
utilisateur
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lib
unicaen
utilisateur
Commits
a94489a6
Commit
a94489a6
authored
2 years ago
by
Jean-Philippe Metivier
Browse files
Options
Downloads
Patches
Plain Diff
Utilisation du '''usernamefield''' pour les affichages
parent
7dbf8975
No related branches found
No related tags found
No related merge requests found
Pipeline
#17883
passed
2 years ago
Stage: release
Stage: publish
Changes
2
Pipelines
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/UnicaenUtilisateur/Controller/UtilisateurController.php
+12
-6
12 additions, 6 deletions
src/UnicaenUtilisateur/Controller/UtilisateurController.php
src/UnicaenUtilisateur/Controller/UtilisateurControllerFactory.php
+3
-0
3 additions, 0 deletions
...enUtilisateur/Controller/UtilisateurControllerFactory.php
with
15 additions
and
6 deletions
src/UnicaenUtilisateur/Controller/UtilisateurController.php
+
12
−
6
View file @
a94489a6
...
...
@@ -58,6 +58,12 @@ class UtilisateurController extends AbstractActionController
$this
->
identityProvider
=
$provider
;
}
private
?string
$usernamefield
;
public
function
setUsernamefield
(
?string
$usernamefield
):
void
{
$this
->
usernamefield
=
$usernamefield
;
}
public
function
indexAction
()
{
$roles
=
$this
->
roleService
->
findAll
();
...
...
@@ -76,13 +82,13 @@ class UtilisateurController extends AbstractActionController
if
(
isset
(
$this
->
searchServices
[
$source
]))
{
$sourceUser
=
$this
->
searchServices
[
$source
]
->
findById
(
$id
);
$newUser
=
$this
->
userService
->
importFromRechercheIndividuResultatInterface
(
$sourceUser
,
$source
);
$user
=
$this
->
userService
->
findByUsername
(
$newUser
->
getUsername
());
$user
=
$this
->
userService
->
findByUsername
(
$newUser
->
getUsername
(
$this
->
usernamefield
));
if
(
!
$user
)
{
$user
=
$this
->
userService
->
create
(
$newUser
);
}
else
{
$this
->
flashMessenger
()
->
addErrorMessage
(
sprintf
(
"L'utilisateur <strong>%s (%s)</strong> existe déjà dans l'application."
,
$user
->
getDisplayName
(),
$user
->
getUsername
())
sprintf
(
"L'utilisateur <strong>%s (%s)</strong> existe déjà dans l'application."
,
$user
->
getDisplayName
(),
$user
->
getUsername
(
$this
->
usernamefield
))
);
}
...
...
@@ -263,12 +269,12 @@ class UtilisateurController extends AbstractActionController
foreach
(
$this
->
searchServices
as
$key
=>
$service
)
{
$currentUsernames
=
array_map
(
function
(
$u
)
{
/** @var RechercheIndividuResultatInterface $u */
return
$u
->
getUsername
();
return
$u
->
getUsername
(
$this
->
usernamefield
);
},
$currentUsers
);
$users
=
$service
->
findByTerm
(
$term
);
$usersFiltered
=
array_filter
(
$users
,
function
(
$e
)
use
(
$currentUsernames
)
{
/** @var RechercheIndividuResultatInterface $e */
return
!
in_array
(
$e
->
getUsername
(),
$currentUsernames
);
return
!
in_array
(
$e
->
getUsername
(
$this
->
usernamefield
),
$currentUsernames
);
});
$currentUsers
=
array_merge
(
$currentUsers
,
$usersFiltered
);
$finalUsers
[
$key
]
=
$usersFiltered
;
...
...
@@ -281,7 +287,7 @@ class UtilisateurController extends AbstractActionController
'id'
=>
$key
.
'||'
.
$individu
->
getId
(),
'label'
=>
$individu
->
getDisplayName
(),
'extra'
=>
sprintf
(
' <span class="text-highlight">/</span> %s <span class="text-highlight">/</span> %s %s'
,
$individu
->
getUsername
(),
$individu
->
getUsername
(
$this
->
usernamefield
),
$individu
->
getEmail
()
?:
"aucun email"
,
(
$key
===
'app'
)
?
'<i title="Utilisateur existant" class="fas fa-check-circle text-success"></i>'
:
''
)
];
...
...
@@ -311,7 +317,7 @@ class UtilisateurController extends AbstractActionController
$records
=
[];
foreach
(
$users
as
$user
)
{
$item
=
[];
$item
[]
=
$user
->
getUsername
();
$item
[]
=
$user
->
getUsername
(
$this
->
usernamefield
);
$item
[]
=
$user
->
getDisplayName
();
$item
[]
=
$user
->
getState
();
...
...
This diff is collapsed.
Click to expand it.
src/UnicaenUtilisateur/Controller/UtilisateurControllerFactory.php
+
3
−
0
View file @
a94489a6
...
...
@@ -31,6 +31,7 @@ class UtilisateurControllerFactory
*/
$config
=
$container
->
get
(
'Config'
);
$moduleConfig
=
$config
[
'unicaen-utilisateur'
];
$usernamefield
=
$config
[
'unicaen-auth'
][
'local'
][
'ldap'
][
'username'
];
$roleService
=
$container
->
get
(
RoleService
::
class
);
$userService
=
$container
->
get
(
UserService
::
class
);
$initCompte
=
$container
->
get
(
'FormElementManager'
)
->
get
(
InitCompteForm
::
class
);
...
...
@@ -63,6 +64,8 @@ class UtilisateurControllerFactory
$controller
->
setUserForm
(
$userForm
);
$controller
->
setUserRechercheForm
(
$userRechercheForm
);
$controller
->
setUsernameField
(
$usernamefield
);
return
$controller
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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