Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Maarch
MaarchCourrier
Commits
27923634
Commit
27923634
authored
Jul 09, 2021
by
ludo
Browse files
Amélioration import ldap
parent
f3c2f56a
Changes
1
Hide whitespace changes
Inline
Side-by-side
bin/ldap/synchronizationScriptAFD.php
View file @
27923634
...
...
@@ -73,13 +73,13 @@ function main($argv)
}
if
(
$synchronizeUsers
)
{
synchronizeUsers
(
$ldapUsers
,
$maarchUsers
);
$usersNotDeleted
=
synchronizeUsers
(
$ldapUsers
,
$maarchUsers
);
}
if
(
$synchronizeEntities
)
{
synchronizeEntities
(
$ldapEntities
,
$maarchEntities
);
}
sendDiff
(
$xmlfile
,
$ldapEntities
,
$
ldapUsers
);
sendDiff
(
$xmlfile
,
$ldapEntities
,
$
usersNotDeleted
);
}
function
initialize
(
$customId
)
...
...
@@ -222,6 +222,7 @@ function getEntitiesEntries($xmlfile)
function
synchronizeUsers
(
array
$ldapUsers
,
array
$maarchUsers
)
{
$usersNotDeleted
=
[];
$maarchUsersLogin
=
[];
foreach
(
$maarchUsers
as
$maarchUser
)
{
$maarchUsersLogin
[
$maarchUser
[
'user_id'
]]
=
$maarchUser
;
...
...
@@ -301,11 +302,12 @@ function synchronizeUsers(array $ldapUsers, array $maarchUsers)
]);
if
(
$curlResponse
[
'code'
]
!=
204
)
{
writeLog
([
'message'
=>
"[ERROR] Delete user failed : user in use"
]);
array_push
(
$usersNotDeleted
,
$user
);
}
}
}
return
true
;
return
$usersNotDeleted
;
}
function
synchronizeEntities
(
array
$ldapEntities
,
array
$maarchEntities
)
...
...
@@ -501,7 +503,7 @@ function sendMail($email)
return
true
;
}
function
sendDiff
(
$xmlfile
,
$ldapEntities
,
$
ldapUsers
)
function
sendDiff
(
$xmlfile
,
$ldapEntities
,
$
usersNotDeleted
)
{
$email
[
'subject'
]
=
(
string
)
$xmlfile
->
mailing
->
subject
;
...
...
@@ -526,18 +528,12 @@ function sendDiff($xmlfile, $ldapEntities, $ldapUsers)
$compare
=
false
;
$tabulation
=
'<tr>'
;
foreach
(
$finalMaarchUsers
as
$value
)
{
$compare
=
true
;
foreach
(
$ldapUsers
as
$v
)
{
if
(
$value
[
'user_id'
]
==
$v
[
'user_id'
])
$compare
=
false
;
}
if
(
$compare
){
$bodyUser
.
=
'<tr>'
;
$bodyUser
.
=
'<td>'
.
$value
[
'user_id'
]
.
'</td>'
;
$bodyUser
.
=
'<td>'
.
$value
[
'firstname'
]
.
'</td>'
;
$bodyUser
.
=
'<td>'
.
' '
.
$value
[
'lastname'
]
.
'</td>'
;
$bodyUser
.
=
'</tr>'
;
}
foreach
(
$usersNotDeleted
as
$value
)
{
$bodyUser
.
=
'<tr>'
;
$bodyUser
.
=
'<td>'
.
$value
[
'user_id'
]
.
'</td>'
;
$bodyUser
.
=
'<td>'
.
$value
[
'firstname'
]
.
'</td>'
;
$bodyUser
.
=
'<td>'
.
' '
.
$value
[
'lastname'
]
.
'</td>'
;
$bodyUser
.
=
'</tr>'
;
}
foreach
(
$finalMaarchEntities
as
$key
=>
$value
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment