Commit f87f4205 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Merge branch...

Merge branch '5918-sinaps-acquisition-couldn-t-be-sent-because-primary-affectation-isn-t-set' into '1.4-dev'

Resolve "SINAPS : acquisition couldn't be sent because primary affectation isn't set"

See merge request fusiondirectory/fd-plugins!529

(cherry picked from commit f77745c0)

4ecf6baf 🚑 fix(sinaps) Respect quotite tag in affectations
fdb837dc 🚑 fix(sinaps) Avoid useless search in referenceCroisee
d041fb4d 🚑 fix(sinaps) Fix user role detection for typeExterne
parent 58379678
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2017-2018 FusionDirectory
Copyright (C) 2017-2019 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -261,7 +261,7 @@ class sinapsRequest
/* Check if the user still has at least one role which means he exists, otherwise this is a deletion */
$userRoleExists = array();
foreach ($userRoles as $typeRole) {
if (preg_match('^([^/]+)/(.+)$', $typeRole, $m)) {
if (preg_match('|^([^/]+)/(.+)$|', $typeRole, $m)) {
$userRoleExists[$m[1]][] = $m[2];
} else {
$userRoleExists[$typeRole] = TRUE;
......@@ -361,18 +361,23 @@ class sinapsRequest
continue;
}
if (isset($role->personneRessource->affectations->affectation)) {
$quotiteMax = NULL;
foreach ($role->personneRessource->affectations->affectation as $affectation) {
if (!$this->checkValidite($affectation, $now)) {
continue;
}
$UUID = $this->getUUIDFromReferenceCroisee($identifiantApplication, $affectation->referenceCroisee);
$UUID = (string)$affectation->identifiantStructureInterne;
$quotite = (isset($affectation->quotite) ? (int)$affectation->quotite : 0);
if (!empty($UUID)) {
$entite = $ldapUuidToCodeEntiteCallback($UUID);
if (isset($entite['supannTypeEntite'])) {
$values['supannAccount']['supannTypeEntiteAffectation'][] = $entite['supannTypeEntite'];
}
$values['supannAccount']['supannEntiteAffectation'][] = $entite['supannCodeEntite'];
$values['supannAccount']['supannEntiteAffectationPrincipale'] = $entite['supannCodeEntite'];
if (($quotiteMax === NULL) || ($quotite > $quotiteMax)) {
$quotiteMax = $quotite;
$values['supannAccount']['supannEntiteAffectationPrincipale'] = $entite['supannCodeEntite'];
}
}
}
}
......@@ -398,7 +403,7 @@ class sinapsRequest
continue;
}
$values['supannAccount']['supannRoleGenerique'][] = (string)$fonctionOccupee->fonctionRh;
$UUID = $this->getUUIDFromReferenceCroisee($identifiantApplication, $fonctionOccupee->referenceCroisee);
$UUID = (string)$fonctionOccupee->identifiantStructureInterne;
if (!empty($UUID)) {
$entite = $ldapUuidToCodeEntiteCallback($UUID, TRUE);
$values['supannAccount']['supannTypeEntiteAffectation'][] = $entite['supannTypeEntite'];
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment