Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
lib
unicaen
ldap
Commits
fdd3d01d
Commit
fdd3d01d
authored
Jun 26, 2020
by
David Surville
Browse files
Merge branch 'zf-3.0' of
https://git.unicaen.fr/lib/unicaen/ldap
into zf-3.0
parents
f5e8085d
b53066f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/UnicaenLdap/Entity/Base/People.php
View file @
fdd3d01d
...
...
@@ -267,14 +267,14 @@ class People extends Entity
static
protected
$secteur_disciplinaire_pattern
=
'/^(?<code>\d+);(?<libelle>.+)$/'
;
static
protected
$inscription_pattern
=
'/^\[etab=(?<etab>\{[\w\-:]+\}.+)\]'
.
'\[anneeinsc=(?<anneeinsc>\d{4})\]'
.
'\[regimeinsc=(?<regimeinsc>\{[\w\-:]+\}\w*)\]'
.
// {SISE}.* ou {INCONNU}
'\[sectdisc=(?<sectdisc>\{[\w\-:]+\}\w*)\]'
.
// {SISE}.* ou {INCONNU}
'\[typedip=(?<typedip>\{[\w\-:]+\}\w*)\]'
.
// {SISE}.* ou {INCONNU}
'\[cursusann=(?<cursusann>\{SUPANN\}\w+)\]'
.
'\[affect=(?<affect>[\w\-]+)\]'
.
'\[diplome=(?<diplome>\{[\w\-:]+\}\w+)\]'
.
'\[etape=(?<etape>\{[\w\-:]+\}.+)\]$/'
;
'\[anneeinsc=(?<anneeinsc>\d{4})\]'
.
'\[regimeinsc=(?<regimeinsc>\{[\w\-:]+\}\w*)\]'
.
// {SISE}.* ou {INCONNU}
'\[sectdisc=(?<sectdisc>\{[\w\-:]+\}\w*)\]'
.
// {SISE}.* ou {INCONNU}
'\[typedip=(?<typedip>\{[\w\-:]+\}\w*)\]'
.
// {SISE}.* ou {INCONNU}
'\[cursusann=(?<cursusann>\{SUPANN\}\w+)\]'
.
'\[affect=(?<affect>[\w\-]+)\]'
.
'\[diplome=(?<diplome>\{[\w\-:]+\}\w+)\]'
.
'\[etape=(?<etape>\{[\w\-:]+\}.+)\]$/'
;
static
protected
$inscription_complement_pattern
=
'/^\[anneeinsc=(?<anneeinsc>\d{4})\]\[etape=(?<etape>\{[\w\-:]+\}.+)\]\[adistance=(?<adistance>\{[\w\-:]+\}\w{1})\]$/'
;
static
protected
$role_pattern
=
'/^\[role=(?<role>\{SUPANN\}[\w\-]+)\]\[type=(?<type>\{SUPANN\}[\w\-]+)\]\[code=(?<code>[\w\-]+)\]\[libelle=(?<libelle>.+)\]$/'
;
static
protected
$role_src_pattern
=
'/^(?<code>\d{4});(?<libelle>.+)$/'
;
...
...
@@ -360,13 +360,13 @@ class People extends Entity
/**
* Attribut Ldap "dateDeNaissance"
*
* @deprecated Deprecated, use {@link self::setSchacDateOfBirth}
*
* @param array|string|DateTime|null $value
* @param bool $append
* @return self
* @throws Exception
* @throws LdapException
* @deprecated Deprecated, use {@link self::setSchacDateOfBirth}
*
*/
public
function
setDateDeNaissance
(
$value
=
null
,
$append
=
false
)
{
...
...
@@ -410,13 +410,13 @@ class People extends Entity
/**
* Attribut Ldap "dateFinInscription"
*
* @deprecated Deprecated, use {@link self::setSchacExpiryDate}
*
* @param array|string|DateTime|null $value
* @param bool $append
* @return self
* @throws Exception
* @throws LdapException
* @deprecated Deprecated, use {@link self::setSchacExpiryDate}
*
*/
public
function
setDateFinInscription
(
$value
=
null
,
$append
=
false
)
{
...
...
@@ -939,10 +939,9 @@ class People extends Entity
$supannLabel
=
$this
->
getLabel
(
'SUPANN'
);
$value
=
array_map
(
function
(
$val
)
use
(
$supannLabel
)
{
if
(
is_string
(
$val
))
{
if
(
preg_match
(
"/^"
.
$supannLabel
.
"[\w\-]+$/"
,
$val
))
{
if
(
preg_match
(
"/^"
.
$supannLabel
.
"[\w\-]+$/"
,
$val
))
{
return
$val
;
}
elseif
(
preg_match
(
"/^[\w\-]+$/"
,
$val
))
{
}
elseif
(
preg_match
(
"/^[\w\-]+$/"
,
$val
))
{
return
sprintf
(
'%s%s'
,
$supannLabel
,
$val
);
}
}
...
...
@@ -1161,10 +1160,9 @@ class People extends Entity
$supannLabel
=
$this
->
getLabel
(
'SUPANN'
);
$value
=
array_map
(
function
(
$val
)
use
(
$supannLabel
)
{
if
(
is_string
(
$val
))
{
if
(
preg_match
(
"/^"
.
$supannLabel
.
"[\w\-]+$/"
,
$val
))
{
if
(
preg_match
(
"/^"
.
$supannLabel
.
"[\w\-]+$/"
,
$val
))
{
return
$val
;
}
elseif
(
preg_match
(
"/^[\w\-]+$/"
,
$val
))
{
}
elseif
(
preg_match
(
"/^[\w\-]+$/"
,
$val
))
{
return
sprintf
(
'%s%s'
,
$supannLabel
,
$val
);
}
}
...
...
@@ -1198,7 +1196,7 @@ class People extends Entity
* @var string $code
*/
foreach
([
'role'
,
'type'
]
as
$part
)
{
$$part
=
preg_match
(
"/^"
.
$supannLabel
.
"[\w\-]+$/"
,
$matches
[
$part
])
$$part
=
preg_match
(
"/^"
.
$supannLabel
.
"[\w\-]+$/"
,
$matches
[
$part
])
?
$matches
[
$part
]
:
sprintf
(
'%s%s'
,
$supannLabel
,
$matches
[
$part
]);
}
...
...
@@ -1409,11 +1407,30 @@ class People extends Entity
public
function
setSupannRefId
(
$value
=
null
,
$append
=
false
)
{
$value
=
$this
->
preFormat
(
$value
);
$value
=
array_filter
(
$value
,
function
(
$v
)
{
return
preg_match
(
self
::
$attribute_with_label_pattern
,
$v
);
});
$this
->
appendOrNot
(
'supannRefId'
,
$value
,
$append
);
foreach
(
$value
as
$v
)
{
if
(
preg_match
(
self
::
$attribute_with_label_pattern
,
$v
,
$matches
))
{
if
(
$append
)
{
$this
->
appendOrNot
(
'supannRefId'
,
$v
,
true
);
}
else
{
$label
=
$matches
[
'etiquette'
];
$identifiant
=
$matches
[
'identifiant'
];
$currentValues
=
$this
->
preFormat
(
$this
->
supannRefId
);
array_walk
(
$currentValues
,
function
(
&
$cv
)
use
(
$label
,
$identifiant
)
{
if
(
preg_match
(
"/^"
.
$label
.
"(?<identifiant>.+)$/"
,
$cv
,
$matches
))
{
if
(
$matches
[
'identifiant'
]
!=
$identifiant
)
{
$this
->
remove
(
'supannRefId'
,
$cv
);
$cv
=
null
;
}
}
});
if
(
!
in_array
(
$v
,
$currentValues
))
{
$currentValues
[]
=
$v
;
}
$this
->
appendOrNot
(
'supannRefId'
,
array_filter
(
$currentValues
),
false
);
}
}
}
return
$this
;
}
...
...
@@ -1514,10 +1531,9 @@ class People extends Entity
$corpsLabel
=
$this
->
getLabel
(
'NCORPS'
);
$value
=
array_map
(
function
(
$val
)
use
(
$corpsLabel
)
{
if
(
is_string
(
$val
))
{
if
(
preg_match
(
"/^
$corpsLabel
\w+$/"
,
$val
))
{
if
(
preg_match
(
"/^
$corpsLabel
\w+$/"
,
$val
))
{
return
$val
;
}
elseif
(
preg_match
(
"/^\w+$/"
,
$val
))
{
}
elseif
(
preg_match
(
"/^\w+$/"
,
$val
))
{
return
sprintf
(
'%s%s'
,
$corpsLabel
,
$val
);
}
}
...
...
@@ -1586,10 +1602,9 @@ class People extends Entity
$supannLabel
=
$this
->
getLabel
(
'SUPANN'
);
$value
=
array_map
(
function
(
$val
)
use
(
$supannLabel
)
{
if
(
is_string
(
$val
))
{
if
(
preg_match
(
"/^
$supannLabel
\w+$/"
,
$val
))
{
if
(
preg_match
(
"/^
$supannLabel
\w+$/"
,
$val
))
{
return
$val
;
}
elseif
(
preg_match
(
"/^\w+$/"
,
$val
))
{
}
elseif
(
preg_match
(
"/^\w+$/"
,
$val
))
{
return
sprintf
(
'%s%s'
,
$supannLabel
,
$val
);
}
}
...
...
@@ -1636,7 +1651,7 @@ class People extends Entity
$value
=
$this
->
preFormat
(
$value
);
$value
=
array_map
(
function
(
$val
)
{
if
(
is_string
(
$val
))
{
if
(
preg_match
(
self
::
$attribute_with_label_pattern
,
$val
,
$matches
))
{
if
(
preg_match
(
self
::
$attribute_with_label_pattern
,
$val
,
$matches
))
{
$prefixe
=
$this
->
getService
()
->
getCodeModuleEnseignementPrefixe
();
$val
=
(
0
!==
strpos
(
$matches
[
'identifiant'
],
$prefixe
))
?
$prefixe
.
$matches
[
'identifiant'
]
...
...
@@ -1667,7 +1682,7 @@ class People extends Entity
$value
=
$this
->
preFormat
(
$value
);
$value
=
array_map
(
function
(
$val
)
{
if
(
is_string
(
$val
))
{
if
(
preg_match
(
self
::
$attribute_with_label_pattern
,
$val
,
$matches
))
{
if
(
preg_match
(
self
::
$attribute_with_label_pattern
,
$val
,
$matches
))
{
$prefixe
=
$this
->
getService
()
->
getCodeModuleEnseignementPrefixe
();
$val
=
(
0
!==
strpos
(
$matches
[
'identifiant'
],
$prefixe
))
?
$prefixe
.
$matches
[
'identifiant'
]
...
...
@@ -1699,10 +1714,9 @@ class People extends Entity
$siseLabel
=
$this
->
getLabel
(
'SISE'
);
$value
=
array_map
(
function
(
$val
)
use
(
$siseLabel
)
{
if
(
is_string
(
$val
))
{
if
(
preg_match
(
"/^
$siseLabel
\w+$/"
,
$val
))
{
if
(
preg_match
(
"/^
$siseLabel
\w+$/"
,
$val
))
{
return
$val
;
}
elseif
(
preg_match
(
"/^\w+$/"
,
$val
))
{
}
elseif
(
preg_match
(
"/^\w+$/"
,
$val
))
{
return
sprintf
(
'%s%s'
,
$siseLabel
,
$val
);
}
}
...
...
@@ -1729,10 +1743,9 @@ class People extends Entity
$siseLabel
=
$this
->
getLabel
(
'SISE'
);
$value
=
array_map
(
function
(
$val
)
use
(
$siseLabel
)
{
if
(
is_string
(
$val
))
{
if
(
preg_match
(
"/^
$siseLabel
\w+$/"
,
$val
))
{
if
(
preg_match
(
"/^
$siseLabel
\w+$/"
,
$val
))
{
return
$val
;
}
elseif
(
preg_match
(
"/^\w+$/"
,
$val
))
{
}
elseif
(
preg_match
(
"/^\w+$/"
,
$val
))
{
return
sprintf
(
'%s%s'
,
$siseLabel
,
$val
);
}
}
...
...
@@ -1759,10 +1772,9 @@ class People extends Entity
$siseLabel
=
$this
->
getLabel
(
'SISE'
);
$value
=
array_map
(
function
(
$val
)
use
(
$siseLabel
)
{
if
(
is_string
(
$val
))
{
if
(
preg_match
(
"/^
$siseLabel
\w+$/"
,
$val
))
{
if
(
preg_match
(
"/^
$siseLabel
\w+$/"
,
$val
))
{
return
$val
;
}
elseif
(
preg_match
(
"/^\w+$/"
,
$val
))
{
}
elseif
(
preg_match
(
"/^\w+$/"
,
$val
))
{
return
sprintf
(
'%s%s'
,
$siseLabel
,
$val
);
}
}
...
...
@@ -1923,12 +1935,12 @@ class People extends Entity
/**
* Attribut Ldap "sambaNTPassword"
* @see setNtPassword
*
* @param string $value
* @return $this
* @throws Exception
* @throws LdapException
* @see setNtPassword
*
*/
public
function
setSambaNTPassword
(
string
$value
)
{
...
...
@@ -1955,77 +1967,9 @@ class People extends Entity
*/
public
function
setUcbnSquidHash
(
string
$value
)
{
$value
=
"Unicaen:"
.
md5
(
sprintf
(
'%s:Unicaen:%s'
,
$this
->
get
(
'
supannAliasLogin
'
)
,
$value
));
$value
=
"Unicaen:"
.
md5
(
sprintf
(
'%s:Unicaen:%s'
,
$this
->
supannAliasLogin
,
$value
));
$this
->
appendOrNot
(
'ucbnSquidHash'
,
$value
,
false
);
return
$this
;
}
/**
* Retourne les structures auxquelles appartiennent la personne
*
* @return Structure[]
*/
public
function
getEduPersonOrgUnit
()
{
$structure
=
$this
->
getService
()
->
getServiceLocator
()
->
get
(
'ldapServiceStructure'
);
$dn
=
$this
->
eduPersonOrgUnitDN
;
if
(
empty
(
$dn
))
return
null
;
return
$structure
->
getAllBy
(
$dn
,
'dn'
);
}
/**
* Retourne la structure principale à laquelle appartient la personne
*
* @return Structure
*/
public
function
getEduPersonPrimaryOrgUnit
()
{
$structure
=
$this
->
getService
()
->
getServiceLocator
()
->
get
(
'ldapServiceStructure'
);
$dn
=
$this
->
eduPersonPrimaryOrgUnitDN
;
if
(
empty
(
$dn
))
return
null
;
return
$structure
->
getBy
(
$dn
,
'dn'
);
}
/**
* Retourne la structure d'affectation de la personne
*
* @todo à terminer
* @return Structure[]
* @throws \Exception
*/
public
function
getSupannEntiteAffectation
()
{
throw
new
\
Exception
(
'Méthode pas finie'
);
$structure
=
$this
->
getService
()
->
getServiceLocator
()
->
get
(
'ldapServiceStructure'
);
$codes
=
$this
->
getNode
()
->
getAttribute
(
'supannEntiteAffectation'
);
var_dump
(
$codes
);
return
$structure
->
getBy
(
$dn
,
'dn'
);
}
/**
* Retourne la structure d'affectation de la personne
*
* @todo à terminer
* @return Structure
* @throws \Exception
*/
public
function
getSupannEntiteAffectationPrincipale
()
{
throw
new
\
Exception
(
'Méthode pas finie'
);
$structure
=
$this
->
getService
()
->
getServiceLocator
()
->
get
(
'ldapServiceStructure'
);
$codes
=
[];
$affectations
=
$this
->
getNode
()
->
getAttribute
(
'supannAffectation'
);
list
(
$code
,
$description
)
=
explode
(
';'
,
$this
->
supannAffectation
);
$code
=
$this
->
supannAffectation
;
if
(
empty
(
$dn
))
return
null
;
return
$structure
->
getBy
(
$dn
,
'dn'
);
}
}
\ No newline at end of file
src/UnicaenLdap/Entity/People.php
View file @
fdd3d01d
...
...
@@ -2,8 +2,9 @@
namespace
UnicaenLdap\Entity
;
use
UnicaenLdap\Entity\Base\People
as
BasePeople
;
use
DateTime
;
use
UnicaenLdap\Entity\Base\People
as
BasePeople
;
use
UnicaenLdap\Entity\Base\Structure
;
/**
* Classe de gestion des entités de la branche "people" de l'annuaire LDAP.
...
...
Write
Preview
Markdown
is supported
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