Loading config/module.config.php +10 −3 Changes for config/module.config.php: 10 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -14,14 +14,14 @@ use UnicaenLdap\Service\Group as LdapGroupService; use UnicaenLdap\Service\GroupFactory as GroupServiceFactory; use UnicaenLdap\Service\People as LdapPeopleService; use UnicaenLdap\Service\PeopleFactory as PeopleServiceFactory; use UnicaenLdap\Service\Root as LdapRootService; use UnicaenLdap\Service\RootFactory as RootServiceFactory; use UnicaenLdap\Service\Structure as LdapStructureService; use UnicaenLdap\Service\StructureFactory as StructureServiceFactory; use UnicaenLdap\Service\System as LdapSystemService; use UnicaenLdap\Service\SystemFactory as SystemServiceFactory; use Zend\ServiceManager\Proxy\LazyServiceFactory; ;; return array( 'unicaen-ldap' => [ Loading @@ -33,6 +33,7 @@ return array( 'LdapServiceGeneric' => GenericServiceFactory::class, 'LdapServiceGroup' => GroupServiceFactory::class, 'LdapServicePeople' => PeopleServiceFactory::class, 'LdapServiceRoot' => RootServiceFactory::class, 'LdapServiceStructure' => StructureServiceFactory::class, 'LdapServiceSystem' => SystemServiceFactory::class, ], Loading @@ -42,11 +43,13 @@ return array( 'ldapServiceGeneric' => 'LdapServiceGeneric', 'ldapServiceGroup' => 'LdapServiceGroup', 'ldapServicePeople' => 'LdapServicePeople', 'ldapServiceRoot' => 'LdapServiceRoot', 'ldapServiceStructure' => 'LdapServiceStructure', 'ldapServiceSystem' => 'LdapServiceSystem', LdapGenericService::class => 'LdapServiceGeneric', LdapPeopleService::class => 'LdapServicePeople', LdapGroupService ::class => 'LdapServiceGroup', LdapPeopleService::class => 'LdapServicePeople', LdapRootService::class => 'LdapServiceRoot', LdapStructureService::class => 'LdapServiceStructure', LdapSystemService::class => 'LdapServiceSystem', ], Loading @@ -56,6 +59,7 @@ return array( 'LdapServicePeople' => LdapPeopleService::class, 'LdapServiceGeneric' => LdapGenericService::class, 'LdapServiceGroup' => LdapGroupService::class, 'LdapServiceRoot' => LdapRootService::class, 'LdapServiceStructure' => LdapStructureService::class, 'LdapServiceSystem' => LdapSystemService::class, ], Loading @@ -70,6 +74,9 @@ return array( 'LdapServiceGroup' => [ LazyServiceFactory::class, ], 'LdapServiceRoot' => [ LazyServiceFactory::class, ], 'LdapServiceStructure' => [ LazyServiceFactory::class, ], Loading src/UnicaenLdap/Entity/Base/People.php +17 −16 Changes for src/UnicaenLdap/Entity/Base/People.php: 17 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -730,12 +730,12 @@ class People extends Entity : sprintf('%s%s', $supannLabel, $matches[$part]); } $prefixe = $this->getService()->getCodeStructurePrefixe(); $prefixe = $this->getService()->getLdapStructureService()->getCodeStructurePrefixe(); $affect = (0 !== strpos($matches['affect'], $prefixe)) ? sprintf('%s%s', $structure_prefixe, $matches['affect']) : $matches['affect']; $prefixe = $this->getService()->getCodeModuleEnseignementPrefixe(); $prefixe = $this->getService()->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); preg_match('/^(?<etiquette>\{[\w\-:]+\})(?<identifiant>.+)$/', $matches['etape'], $parts); $val = (0 !== strpos($parts['identifiant'], $prefixe)) ? $prefixe . $parts['identifiant'] Loading Loading @@ -852,7 +852,7 @@ class People extends Entity if (is_string($val)) { return preg_match(self::$structure_pattern, $val) ? $val : null; } elseif ($val instanceof StructureEntity) { $val = sprintf('%s;%s', strtr($val->get('supannCodeEntite'), $this->getService()->getCodeStructurePrefixe(), ''), $val->get('description')); $val = sprintf('%s;%s', strtr($val->get('supannCodeEntite'), $this->getService()->getLdapStructureService()->getCodeStructurePrefixe(), ''), $val->get('description')); return preg_match(self::$structure_pattern, $val) ? $val : null; } else { return null; Loading @@ -878,8 +878,8 @@ class People extends Entity $value = $this->preFormat($value); $value = array_map(function ($val) { if (is_string($val)) { if (0 !== strpos($val, $this->getService()->getCodeStructurePrefixe())) { $val = $this->getService()->getCodeStructurePrefixe() . $val; if (0 !== strpos($val, $this->getService()->getLdapStructureService()->getCodeStructurePrefixe())) { $val = $this->getService()->getLdapStructureService()->getCodeStructurePrefixe() . $val; } return $val; } elseif ($val instanceof StructureEntity) { Loading Loading @@ -908,8 +908,8 @@ class People extends Entity $value = $this->preFormat($value); $value = array_map(function ($val) { if (is_string($val)) { if (0 !== strpos($val, $this->getService()->getCodeStructurePrefixe())) { $val = $this->getService()->getCodeStructurePrefixe() . $val; if (0 !== strpos($val, $this->getService()->getLdapStructureService()->getCodeStructurePrefixe())) { $val = $this->getService()->getLdapStructureService()->getCodeStructurePrefixe() . $val; } return $val; } elseif ($val instanceof StructureEntity) { Loading Loading @@ -990,7 +990,7 @@ class People extends Entity if (is_string($val)) { return preg_match(self::$structure_pattern, $val) ? $val : null; } elseif ($val instanceof StructureEntity) { $val = sprintf('%s;%s', strtr($val->get('supannCodeEntite'), $this->getService()->getCodeStructurePrefixe(), ''), $val->get('description')); $val = sprintf('%s;%s', strtr($val->get('supannCodeEntite'), $this->getService()->getLdapStructureService()->getCodeStructurePrefixe(), ''), $val->get('description')); return preg_match(self::$structure_pattern, $val) ? $val : null; } else { return null; Loading Loading @@ -1018,7 +1018,7 @@ class People extends Entity if (is_string($val)) { return preg_match(self::$structure_pattern, $val) ? $val : null; } elseif ($val instanceof StructureEntity) { $val = sprintf('%s;%s', strtr($val->get('supannCodeEntite'), $this->getService()->getCodeStructurePrefixe(), ''), $val->get('description')); $val = sprintf('%s;%s', strtr($val->get('supannCodeEntite'), $this->getService()->getLdapStructureService()->getCodeStructurePrefixe(), ''), $val->get('description')); return preg_match(self::$structure_pattern, $val) ? $val : null; } else { return null; Loading @@ -1041,16 +1041,17 @@ class People extends Entity */ public function setEduPersonPrincipalName($value = null, $append = false) { $universiteDomaine = $this->getService()->getLdapRootService()->getEtablissementDomain(); $value = $this->preFormat($value); $value = array_map(function ($v) { list($identifiant, $domaine) = array_pad(explode('@', strtolower($v)), 2, null); if ($domaine != self::$etablissement_domaine) { $v = sprintf('%s@%s', $v, self::$etablissement_domaine); if ($domaine != $universiteDomaine) { $v = sprintf('%s@%s', $v, $universiteDomaine); } return $v; }, $value); $value = array_filter($value, function ($v) { return preg_match('/^[0-9a-z\-]+@' . self::$etablissement_domaine . '$/', $v); return preg_match('/^[0-9a-z\-]+@' . $universiteDomaine . '$/', $v); }); $this->appendOrNot('eduPersonPrincipalName', $value, $append); Loading Loading @@ -1201,7 +1202,7 @@ class People extends Entity : sprintf('%s%s', $supannLabel, $matches[$part]); } $prefixe = $this->getService()->getCodeStructurePrefixe(); $prefixe = $this->getService()->getLdapStructureService()->getCodeStructurePrefixe(); $code = (0 !== strpos($matches['code'], $prefixe)) ? sprintf('%s%s', $prefixe, $matches['code']) : $matches['code']; Loading Loading @@ -1280,7 +1281,7 @@ class People extends Entity * @var string $etape * @var string $adistance */ $prefixe = $this->getService()->getCodeModuleEnseignementPrefixe(); $prefixe = $this->getService()->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); preg_match('/^(?<etiquette>\{[\w\-:]+\})(?<identifiant>.+)$/', $matches['etape'], $parts); $val = (0 !== strpos($parts['identifiant'], $prefixe)) ? $prefixe . $parts['identifiant'] Loading Loading @@ -1652,7 +1653,7 @@ class People extends Entity $value = array_map(function ($val) { if (is_string($val)) { if (preg_match(self::$attribute_with_label_pattern, $val, $matches)) { $prefixe = $this->getService()->getCodeModuleEnseignementPrefixe(); $prefixe = $this->getService()->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $val = (0 !== strpos($matches['identifiant'], $prefixe)) ? $prefixe . $matches['identifiant'] : $matches['identifiant']; Loading Loading @@ -1683,7 +1684,7 @@ class People extends Entity $value = array_map(function ($val) { if (is_string($val)) { if (preg_match(self::$attribute_with_label_pattern, $val, $matches)) { $prefixe = $this->getService()->getCodeModuleEnseignementPrefixe(); $prefixe = $this->getService()->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $val = (0 !== strpos($matches['identifiant'], $prefixe)) ? $prefixe . $matches['identifiant'] : $matches['identifiant']; Loading src/UnicaenLdap/Entity/Base/Root.php 0 → 100644 +271 −0 Changes for src/UnicaenLdap/Entity/Base/Root.php: 271 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace UnicaenLdap\Entity\Base; use UnicaenLdap\Entity\Entity; use UnicaenLdap\Entity\Structure as StructureEntity; use UnicaenLdap\Exception; use Zend\Ldap\Exception\LdapException; /** * Classe mère de l'entité racine de l'annuaire LDAP. * * @author David Surville <david.surville@unicaen.fr> */ class Root extends Entity { protected $type = 'Root'; /** * Liste des classes d'objet nécessaires à la création d'une structure * * @var string[] */ protected $objectClass = [ 'top', 'dcObject', 'organization', 'eduOrg', 'supannOrg', ]; /** * Liste des attributs autorisés pour l'entité "Root" * * @var array */ protected $authorizedAttributes = [ // Attributes classes 'objectClass', // Attributes 'description', 'eduOrgHomePageURI', 'eduOrgLegalName', 'eduOrgSuperiorURI', 'eduOrgWhitePagesURI', 'facsimileTelephoneNumber', 'l', 'o', 'postalAddress', 'supannEtablissement', 'telephoneNumber', ]; /** * Liste des attributs contenant des dates * * @var array */ protected $dateTimeAttributes = []; /** * Liste des attributs monovalués * * @var array */ protected $monoValuedAttributes = [ 'eduOrgLegalName', ]; /** * Attribut Ldap "description" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setDescription($value = null, $append = false) { $value = $this->preFormat($value); $this->appendOrNot('description', $value, $append); return $this; } /** * Attribut Ldap "eduOrgHomePageURI" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setEduOrgHomePageURI($value = null, $append = false) { $value = $this->preFormat($value); $value = filter_var_array($value, FILTER_VALIDATE_URL); $this->appendOrNot('eduOrgHomePageURI', $value, $append); return $this; } /** * Attribut Ldap "eduOrgLegalName" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setEduOrgLegalName($value = null, $append = false) { $value = $this->preFormat($value); $this->appendOrNot('eduOrgLegalName', $value, $append); return $this; } /** * Attribut Ldap "eduOrgSuperiorURI" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setEduOrgSuperiorURI($value = null, $append = false) { $value = $this->preFormat($value); $value = filter_var_array($value, FILTER_VALIDATE_URL); $this->appendOrNot('eduOrgSuperiorURI', $value, $append); return $this; } /** * Attribut Ldap "eduOrgWhitePagesURI" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setEduOrgWhitePagesURI($value = null, $append = false) { $value = $this->preFormat($value); $value = filter_var_array($value, FILTER_VALIDATE_URL); $this->appendOrNot('eduOrgWhitePagesURI', $value, $append); return $this; } /** * Attribut Ldap "facsimileTelephoneNumber" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setFacsimileTelephoneNumber($value = null, $append = false) { $value = $this->preFormat($value); $value = array_map([$this, 'formatTel'], $value); $this->appendOrNot('facsimileTelephoneNumber', $value, $append); return $this; } /** * Attribut Ldap "l" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setL($value = null, $append = false) { $value = $this->preFormat($value); $this->appendOrNot('l', $value, $append); return $this; } /** * Attribut Ldap "o" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setO($value = null, $append = false) { $value = $this->preFormat($value); $this->appendOrNot('o', $value, $append); return $this; } /** * Attribut Ldap "postalAddress" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setPostalAddress($value = null, $append = false) { $value = $this->preFormat($value); $value = array_filter($value, function ($v) { return preg_match(self::$postal_address_pattern, $v); }); $this->appendOrNot('postalAddress', $value, $append); return $this; } /** * Attribut Ldap "supannEtablissement" * * @param array|string|null $value * @param bool $append * @return $this * @throws Exception * @throws LdapException */ public function setSupannEtablissement($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('supannEtablissement', $value, $append); return $this; } /** * Attribut Ldap "telephoneNumber" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setTelephoneNumber($value = null, $append = false) { $value = $this->preFormat($value); $value = array_map([$this, 'formatTel'], $value); $this->appendOrNot('telephoneNumber', $value, $append); return $this; } } No newline at end of file src/UnicaenLdap/Entity/Entity.php +1 −2 Changes for src/UnicaenLdap/Entity/Entity.php: 1 added line, 2 removed lines. Original line number Diff line number Diff line Loading @@ -16,8 +16,6 @@ use Zend\Ldap\Exception\LdapException; */ abstract class Entity { static protected $etablissement_domaine = 'unicaen.fr'; /** * Type d'entité * Loading Loading @@ -95,6 +93,7 @@ abstract class Entity 'Generic' => ['uid', 'UnicaenLdap\\Entity\\Generic'], 'Group' => ['cn', 'UnicaenLdap\\Entity\\Group'], 'People' => ['uid', 'UnicaenLdap\\Entity\\People'], 'Root' => ['dc', 'UnicaenLdap\\Entity\\Root'], 'Structure' => ['supannCodeEntite', 'UnicaenLdap\\Entity\\Structure'], 'System' => ['uid', 'UnicaenLdap\\Entity\\System'], ]; Loading src/UnicaenLdap/Entity/People.php +11 −0 Changes for src/UnicaenLdap/Entity/People.php: 11 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -115,6 +115,8 @@ class People extends BasePeople } /** * Test si une valeur est renseignée pour le champ "eduPersonAffiliation" * * @param string $status * @return bool */ Loading Loading @@ -242,6 +244,15 @@ class People extends BasePeople return $this->whichStatus(parent::STATUS_TEACHER); } public function getEduPersonOrg() { $structureService = $this->getService()->getLdapStructureService(); $dn = $this->eduPersonOrgDN; if (empty($dn)) return null; return $structureService->getAllBy($dn, 'dn'); } /** * Retourne l'identifiant Octopus de l'individu * Loading Loading
config/module.config.php +10 −3 Changes for config/module.config.php: 10 added lines, 3 removed lines. Original line number Diff line number Diff line Loading @@ -14,14 +14,14 @@ use UnicaenLdap\Service\Group as LdapGroupService; use UnicaenLdap\Service\GroupFactory as GroupServiceFactory; use UnicaenLdap\Service\People as LdapPeopleService; use UnicaenLdap\Service\PeopleFactory as PeopleServiceFactory; use UnicaenLdap\Service\Root as LdapRootService; use UnicaenLdap\Service\RootFactory as RootServiceFactory; use UnicaenLdap\Service\Structure as LdapStructureService; use UnicaenLdap\Service\StructureFactory as StructureServiceFactory; use UnicaenLdap\Service\System as LdapSystemService; use UnicaenLdap\Service\SystemFactory as SystemServiceFactory; use Zend\ServiceManager\Proxy\LazyServiceFactory; ;; return array( 'unicaen-ldap' => [ Loading @@ -33,6 +33,7 @@ return array( 'LdapServiceGeneric' => GenericServiceFactory::class, 'LdapServiceGroup' => GroupServiceFactory::class, 'LdapServicePeople' => PeopleServiceFactory::class, 'LdapServiceRoot' => RootServiceFactory::class, 'LdapServiceStructure' => StructureServiceFactory::class, 'LdapServiceSystem' => SystemServiceFactory::class, ], Loading @@ -42,11 +43,13 @@ return array( 'ldapServiceGeneric' => 'LdapServiceGeneric', 'ldapServiceGroup' => 'LdapServiceGroup', 'ldapServicePeople' => 'LdapServicePeople', 'ldapServiceRoot' => 'LdapServiceRoot', 'ldapServiceStructure' => 'LdapServiceStructure', 'ldapServiceSystem' => 'LdapServiceSystem', LdapGenericService::class => 'LdapServiceGeneric', LdapPeopleService::class => 'LdapServicePeople', LdapGroupService ::class => 'LdapServiceGroup', LdapPeopleService::class => 'LdapServicePeople', LdapRootService::class => 'LdapServiceRoot', LdapStructureService::class => 'LdapServiceStructure', LdapSystemService::class => 'LdapServiceSystem', ], Loading @@ -56,6 +59,7 @@ return array( 'LdapServicePeople' => LdapPeopleService::class, 'LdapServiceGeneric' => LdapGenericService::class, 'LdapServiceGroup' => LdapGroupService::class, 'LdapServiceRoot' => LdapRootService::class, 'LdapServiceStructure' => LdapStructureService::class, 'LdapServiceSystem' => LdapSystemService::class, ], Loading @@ -70,6 +74,9 @@ return array( 'LdapServiceGroup' => [ LazyServiceFactory::class, ], 'LdapServiceRoot' => [ LazyServiceFactory::class, ], 'LdapServiceStructure' => [ LazyServiceFactory::class, ], Loading
src/UnicaenLdap/Entity/Base/People.php +17 −16 Changes for src/UnicaenLdap/Entity/Base/People.php: 17 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -730,12 +730,12 @@ class People extends Entity : sprintf('%s%s', $supannLabel, $matches[$part]); } $prefixe = $this->getService()->getCodeStructurePrefixe(); $prefixe = $this->getService()->getLdapStructureService()->getCodeStructurePrefixe(); $affect = (0 !== strpos($matches['affect'], $prefixe)) ? sprintf('%s%s', $structure_prefixe, $matches['affect']) : $matches['affect']; $prefixe = $this->getService()->getCodeModuleEnseignementPrefixe(); $prefixe = $this->getService()->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); preg_match('/^(?<etiquette>\{[\w\-:]+\})(?<identifiant>.+)$/', $matches['etape'], $parts); $val = (0 !== strpos($parts['identifiant'], $prefixe)) ? $prefixe . $parts['identifiant'] Loading Loading @@ -852,7 +852,7 @@ class People extends Entity if (is_string($val)) { return preg_match(self::$structure_pattern, $val) ? $val : null; } elseif ($val instanceof StructureEntity) { $val = sprintf('%s;%s', strtr($val->get('supannCodeEntite'), $this->getService()->getCodeStructurePrefixe(), ''), $val->get('description')); $val = sprintf('%s;%s', strtr($val->get('supannCodeEntite'), $this->getService()->getLdapStructureService()->getCodeStructurePrefixe(), ''), $val->get('description')); return preg_match(self::$structure_pattern, $val) ? $val : null; } else { return null; Loading @@ -878,8 +878,8 @@ class People extends Entity $value = $this->preFormat($value); $value = array_map(function ($val) { if (is_string($val)) { if (0 !== strpos($val, $this->getService()->getCodeStructurePrefixe())) { $val = $this->getService()->getCodeStructurePrefixe() . $val; if (0 !== strpos($val, $this->getService()->getLdapStructureService()->getCodeStructurePrefixe())) { $val = $this->getService()->getLdapStructureService()->getCodeStructurePrefixe() . $val; } return $val; } elseif ($val instanceof StructureEntity) { Loading Loading @@ -908,8 +908,8 @@ class People extends Entity $value = $this->preFormat($value); $value = array_map(function ($val) { if (is_string($val)) { if (0 !== strpos($val, $this->getService()->getCodeStructurePrefixe())) { $val = $this->getService()->getCodeStructurePrefixe() . $val; if (0 !== strpos($val, $this->getService()->getLdapStructureService()->getCodeStructurePrefixe())) { $val = $this->getService()->getLdapStructureService()->getCodeStructurePrefixe() . $val; } return $val; } elseif ($val instanceof StructureEntity) { Loading Loading @@ -990,7 +990,7 @@ class People extends Entity if (is_string($val)) { return preg_match(self::$structure_pattern, $val) ? $val : null; } elseif ($val instanceof StructureEntity) { $val = sprintf('%s;%s', strtr($val->get('supannCodeEntite'), $this->getService()->getCodeStructurePrefixe(), ''), $val->get('description')); $val = sprintf('%s;%s', strtr($val->get('supannCodeEntite'), $this->getService()->getLdapStructureService()->getCodeStructurePrefixe(), ''), $val->get('description')); return preg_match(self::$structure_pattern, $val) ? $val : null; } else { return null; Loading Loading @@ -1018,7 +1018,7 @@ class People extends Entity if (is_string($val)) { return preg_match(self::$structure_pattern, $val) ? $val : null; } elseif ($val instanceof StructureEntity) { $val = sprintf('%s;%s', strtr($val->get('supannCodeEntite'), $this->getService()->getCodeStructurePrefixe(), ''), $val->get('description')); $val = sprintf('%s;%s', strtr($val->get('supannCodeEntite'), $this->getService()->getLdapStructureService()->getCodeStructurePrefixe(), ''), $val->get('description')); return preg_match(self::$structure_pattern, $val) ? $val : null; } else { return null; Loading @@ -1041,16 +1041,17 @@ class People extends Entity */ public function setEduPersonPrincipalName($value = null, $append = false) { $universiteDomaine = $this->getService()->getLdapRootService()->getEtablissementDomain(); $value = $this->preFormat($value); $value = array_map(function ($v) { list($identifiant, $domaine) = array_pad(explode('@', strtolower($v)), 2, null); if ($domaine != self::$etablissement_domaine) { $v = sprintf('%s@%s', $v, self::$etablissement_domaine); if ($domaine != $universiteDomaine) { $v = sprintf('%s@%s', $v, $universiteDomaine); } return $v; }, $value); $value = array_filter($value, function ($v) { return preg_match('/^[0-9a-z\-]+@' . self::$etablissement_domaine . '$/', $v); return preg_match('/^[0-9a-z\-]+@' . $universiteDomaine . '$/', $v); }); $this->appendOrNot('eduPersonPrincipalName', $value, $append); Loading Loading @@ -1201,7 +1202,7 @@ class People extends Entity : sprintf('%s%s', $supannLabel, $matches[$part]); } $prefixe = $this->getService()->getCodeStructurePrefixe(); $prefixe = $this->getService()->getLdapStructureService()->getCodeStructurePrefixe(); $code = (0 !== strpos($matches['code'], $prefixe)) ? sprintf('%s%s', $prefixe, $matches['code']) : $matches['code']; Loading Loading @@ -1280,7 +1281,7 @@ class People extends Entity * @var string $etape * @var string $adistance */ $prefixe = $this->getService()->getCodeModuleEnseignementPrefixe(); $prefixe = $this->getService()->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); preg_match('/^(?<etiquette>\{[\w\-:]+\})(?<identifiant>.+)$/', $matches['etape'], $parts); $val = (0 !== strpos($parts['identifiant'], $prefixe)) ? $prefixe . $parts['identifiant'] Loading Loading @@ -1652,7 +1653,7 @@ class People extends Entity $value = array_map(function ($val) { if (is_string($val)) { if (preg_match(self::$attribute_with_label_pattern, $val, $matches)) { $prefixe = $this->getService()->getCodeModuleEnseignementPrefixe(); $prefixe = $this->getService()->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $val = (0 !== strpos($matches['identifiant'], $prefixe)) ? $prefixe . $matches['identifiant'] : $matches['identifiant']; Loading Loading @@ -1683,7 +1684,7 @@ class People extends Entity $value = array_map(function ($val) { if (is_string($val)) { if (preg_match(self::$attribute_with_label_pattern, $val, $matches)) { $prefixe = $this->getService()->getCodeModuleEnseignementPrefixe(); $prefixe = $this->getService()->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $val = (0 !== strpos($matches['identifiant'], $prefixe)) ? $prefixe . $matches['identifiant'] : $matches['identifiant']; Loading
src/UnicaenLdap/Entity/Base/Root.php 0 → 100644 +271 −0 Changes for src/UnicaenLdap/Entity/Base/Root.php: 271 added lines, 0 removed lines. Original line number Diff line number Diff line <?php namespace UnicaenLdap\Entity\Base; use UnicaenLdap\Entity\Entity; use UnicaenLdap\Entity\Structure as StructureEntity; use UnicaenLdap\Exception; use Zend\Ldap\Exception\LdapException; /** * Classe mère de l'entité racine de l'annuaire LDAP. * * @author David Surville <david.surville@unicaen.fr> */ class Root extends Entity { protected $type = 'Root'; /** * Liste des classes d'objet nécessaires à la création d'une structure * * @var string[] */ protected $objectClass = [ 'top', 'dcObject', 'organization', 'eduOrg', 'supannOrg', ]; /** * Liste des attributs autorisés pour l'entité "Root" * * @var array */ protected $authorizedAttributes = [ // Attributes classes 'objectClass', // Attributes 'description', 'eduOrgHomePageURI', 'eduOrgLegalName', 'eduOrgSuperiorURI', 'eduOrgWhitePagesURI', 'facsimileTelephoneNumber', 'l', 'o', 'postalAddress', 'supannEtablissement', 'telephoneNumber', ]; /** * Liste des attributs contenant des dates * * @var array */ protected $dateTimeAttributes = []; /** * Liste des attributs monovalués * * @var array */ protected $monoValuedAttributes = [ 'eduOrgLegalName', ]; /** * Attribut Ldap "description" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setDescription($value = null, $append = false) { $value = $this->preFormat($value); $this->appendOrNot('description', $value, $append); return $this; } /** * Attribut Ldap "eduOrgHomePageURI" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setEduOrgHomePageURI($value = null, $append = false) { $value = $this->preFormat($value); $value = filter_var_array($value, FILTER_VALIDATE_URL); $this->appendOrNot('eduOrgHomePageURI', $value, $append); return $this; } /** * Attribut Ldap "eduOrgLegalName" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setEduOrgLegalName($value = null, $append = false) { $value = $this->preFormat($value); $this->appendOrNot('eduOrgLegalName', $value, $append); return $this; } /** * Attribut Ldap "eduOrgSuperiorURI" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setEduOrgSuperiorURI($value = null, $append = false) { $value = $this->preFormat($value); $value = filter_var_array($value, FILTER_VALIDATE_URL); $this->appendOrNot('eduOrgSuperiorURI', $value, $append); return $this; } /** * Attribut Ldap "eduOrgWhitePagesURI" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setEduOrgWhitePagesURI($value = null, $append = false) { $value = $this->preFormat($value); $value = filter_var_array($value, FILTER_VALIDATE_URL); $this->appendOrNot('eduOrgWhitePagesURI', $value, $append); return $this; } /** * Attribut Ldap "facsimileTelephoneNumber" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setFacsimileTelephoneNumber($value = null, $append = false) { $value = $this->preFormat($value); $value = array_map([$this, 'formatTel'], $value); $this->appendOrNot('facsimileTelephoneNumber', $value, $append); return $this; } /** * Attribut Ldap "l" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setL($value = null, $append = false) { $value = $this->preFormat($value); $this->appendOrNot('l', $value, $append); return $this; } /** * Attribut Ldap "o" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setO($value = null, $append = false) { $value = $this->preFormat($value); $this->appendOrNot('o', $value, $append); return $this; } /** * Attribut Ldap "postalAddress" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setPostalAddress($value = null, $append = false) { $value = $this->preFormat($value); $value = array_filter($value, function ($v) { return preg_match(self::$postal_address_pattern, $v); }); $this->appendOrNot('postalAddress', $value, $append); return $this; } /** * Attribut Ldap "supannEtablissement" * * @param array|string|null $value * @param bool $append * @return $this * @throws Exception * @throws LdapException */ public function setSupannEtablissement($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('supannEtablissement', $value, $append); return $this; } /** * Attribut Ldap "telephoneNumber" * * @param array|string|null $value * @param bool $append * @return self * @throws Exception * @throws LdapException */ public function setTelephoneNumber($value = null, $append = false) { $value = $this->preFormat($value); $value = array_map([$this, 'formatTel'], $value); $this->appendOrNot('telephoneNumber', $value, $append); return $this; } } No newline at end of file
src/UnicaenLdap/Entity/Entity.php +1 −2 Changes for src/UnicaenLdap/Entity/Entity.php: 1 added line, 2 removed lines. Original line number Diff line number Diff line Loading @@ -16,8 +16,6 @@ use Zend\Ldap\Exception\LdapException; */ abstract class Entity { static protected $etablissement_domaine = 'unicaen.fr'; /** * Type d'entité * Loading Loading @@ -95,6 +93,7 @@ abstract class Entity 'Generic' => ['uid', 'UnicaenLdap\\Entity\\Generic'], 'Group' => ['cn', 'UnicaenLdap\\Entity\\Group'], 'People' => ['uid', 'UnicaenLdap\\Entity\\People'], 'Root' => ['dc', 'UnicaenLdap\\Entity\\Root'], 'Structure' => ['supannCodeEntite', 'UnicaenLdap\\Entity\\Structure'], 'System' => ['uid', 'UnicaenLdap\\Entity\\System'], ]; Loading
src/UnicaenLdap/Entity/People.php +11 −0 Changes for src/UnicaenLdap/Entity/People.php: 11 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -115,6 +115,8 @@ class People extends BasePeople } /** * Test si une valeur est renseignée pour le champ "eduPersonAffiliation" * * @param string $status * @return bool */ Loading Loading @@ -242,6 +244,15 @@ class People extends BasePeople return $this->whichStatus(parent::STATUS_TEACHER); } public function getEduPersonOrg() { $structureService = $this->getService()->getLdapStructureService(); $dn = $this->eduPersonOrgDN; if (empty($dn)) return null; return $structureService->getAllBy($dn, 'dn'); } /** * Retourne l'identifiant Octopus de l'individu * Loading