Loading src/UnicaenLdap/Entity/Base/Group.php +1 −1 Changes for src/UnicaenLdap/Entity/Base/Group.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ class Group extends Entity { return sprintf('uid=%s,%s', self::MEMBER_NOBODY, $this->getService()->getLdapSystemService()->getBranches()[0] $this->service->getLdapSystemService()->getBranches()[0] ); } Loading src/UnicaenLdap/Entity/Base/People.php +14 −14 Changes for src/UnicaenLdap/Entity/Base/People.php: 14 added lines, 14 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()->getLdapStructureService()->getCodeStructurePrefixe(); $prefixe = $this->service->getLdapStructureService()->getCodeStructurePrefixe(); $affect = (0 !== strpos($matches['affect'], $prefixe)) ? sprintf('%s%s', $structure_prefixe, $matches['affect']) : $matches['affect']; $prefixe = $this->getService()->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $prefixe = $this->service->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()->getLdapStructureService()->getCodeStructurePrefixe(), ''), $val->get('description')); $val = sprintf('%s;%s', strtr($val->get('supannCodeEntite'), $this->service->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()->getLdapStructureService()->getCodeStructurePrefixe())) { $val = $this->getService()->getLdapStructureService()->getCodeStructurePrefixe() . $val; if (0 !== strpos($val, $this->service->getLdapStructureService()->getCodeStructurePrefixe())) { $val = $this->service->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()->getLdapStructureService()->getCodeStructurePrefixe())) { $val = $this->getService()->getLdapStructureService()->getCodeStructurePrefixe() . $val; if (0 !== strpos($val, $this->service->getLdapStructureService()->getCodeStructurePrefixe())) { $val = $this->service->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()->getLdapStructureService()->getCodeStructurePrefixe(), ''), $val->get('description')); $val = sprintf('%s;%s', strtr($val->get('supannCodeEntite'), $this->service->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()->getLdapStructureService()->getCodeStructurePrefixe(), ''), $val->get('description')); $val = sprintf('%s;%s', strtr($val->get('supannCodeEntite'), $this->service->getLdapStructureService()->getCodeStructurePrefixe(), ''), $val->get('description')); return preg_match(self::$structure_pattern, $val) ? $val : null; } else { return null; Loading @@ -1041,7 +1041,7 @@ class People extends Entity */ public function setEduPersonPrincipalName($value = null, $append = false) { $universiteDomaine = $this->getService()->getLdapRootService()->getEtablissementDomain(); $universiteDomaine = $this->service->getLdapRootService()->getEtablissementDomain(); $value = $this->preFormat($value); $value = array_map(function ($v) use ($universiteDomaine) { list($identifiant, $domaine) = array_pad(explode('@', strtolower($v)), 2, null); Loading Loading @@ -1202,7 +1202,7 @@ class People extends Entity : sprintf('%s%s', $supannLabel, $matches[$part]); } $prefixe = $this->getService()->getLdapStructureService()->getCodeStructurePrefixe(); $prefixe = $this->service->getLdapStructureService()->getCodeStructurePrefixe(); $code = (0 !== strpos($matches['code'], $prefixe)) ? sprintf('%s%s', $prefixe, $matches['code']) : $matches['code']; Loading Loading @@ -1281,7 +1281,7 @@ class People extends Entity * @var string $etape * @var string $adistance */ $prefixe = $this->getService()->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $prefixe = $this->service->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); preg_match('/^(?<etiquette>\{[\w\-:]+\})(?<identifiant>.+)$/', $matches['etape'], $parts); $val = (0 !== strpos($parts['identifiant'], $prefixe)) ? $prefixe . $parts['identifiant'] Loading Loading @@ -1653,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()->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $prefixe = $this->service->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $val = (0 !== strpos($matches['identifiant'], $prefixe)) ? $prefixe . $matches['identifiant'] : $matches['identifiant']; Loading Loading @@ -1684,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()->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $prefixe = $this->service->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $val = (0 !== strpos($matches['identifiant'], $prefixe)) ? $prefixe . $matches['identifiant'] : $matches['identifiant']; Loading src/UnicaenLdap/Entity/Base/Structure.php +2 −2 Changes for src/UnicaenLdap/Entity/Base/Structure.php: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -110,8 +110,8 @@ class Structure 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->service->getCodeStructurePrefixe())) { $val = $this->service->getCodeStructurePrefixe() . $val; } return $val; } elseif ($val instanceof StructureEntity) { Loading src/UnicaenLdap/Entity/Group.php +1 −1 Changes for src/UnicaenLdap/Entity/Group.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ class Group extends BaseGroup */ public function getMembres($orderBy = null) { $peopleService = $this->getService()->getLdapPeopleService(); $peopleService = $this->service->getLdapPeopleService(); $result = $peopleService->getAllBy($this->member, 'dn', $orderBy); return $result; Loading src/UnicaenLdap/Entity/People.php +130 −41 Changes for src/UnicaenLdap/Entity/People.php: 130 added lines, 41 removed lines. Original line number Diff line number Diff line Loading @@ -5,7 +5,9 @@ namespace UnicaenLdap\Entity; use DateTime; use UnicaenLdap\Entity\Base\People as BasePeople; use UnicaenLdap\Entity\Structure as StructureEntity; use UnicaenLdap\Entity\System as SystemEntity; use UnicaenLdap\Exception; use Zend\Ldap\Dn; /** * Classe de gestion des entités de la branche "people" de l'annuaire LDAP. Loading Loading @@ -135,6 +137,28 @@ class People extends BasePeople return DateTime::createFromFormat('Ymd h:i:s', $this->schacExpiryDate . ' 00:00:00'); } /** * Retourne le responsable de l'entrée Ldap * * @return People|SystemEntity|string|null * @throws Exception * @throws \Zend\Ldap\Exception\LdapException */ public function getParrain() { $systemService = $this->service->getLdapSystemService(); $node = $this->service->getLdap()->getNode($this->supannParrainDN); $branch = $node->getDn()->get(1); switch($branch['ou']) { case strtolower($this->service->getType()): return $this->service->getBy($node->getDnString(), 'dn'); case strtolower($systemService->getType()): return $systemService->getBy($node->getDnString(), 'dn'); default: return $this->supannParrainDN; } } /** * Retourne l'adresse postale professionnelle * Loading Loading @@ -281,30 +305,6 @@ class People extends BasePeople return $this->whichStatus(parent::STATUS_TEACHER); } /** * Établissement auquel appartient la personne * * @return StructureEntity|null */ public function getEtablissement() { $rootService = $this->getService()->getLdapRootService(); $structureService = $this->getService()->getLdapStructureService(); $dn = $this->eduPersonOrgDN; if (empty($dn)) return null; switch($dn) { case $rootService->getEtablissementDN(): return $rootService->getStructureEntity(); default: try { return $structureService->getBy($dn, 'dn'); } catch (Exception $e) { return null; } } } /** * Retourne le léocode associé à l'individu * Loading Loading @@ -383,21 +383,27 @@ class People extends BasePeople } /** * Modifie l'ensemble des attributs liés au mot de passe * Établissement auquel appartient la personne * * @param string $value * @return $this * @throws \UnicaenLdap\Exception * @throws \Zend\Ldap\Exception\LdapException * @return StructureEntity|null */ public function setPassword(string $value) public function getEtablissement() { parent::setUserPassword($value); parent::setNtPassword($value); parent::setSambaNTPassword($value); parent::setUcbnSquidHash($value); $rootService = $this->service->getLdapRootService(); $structureService = $this->service->getLdapStructureService(); $dn = $this->eduPersonOrgDN; return $this; if (empty($dn)) return null; switch($dn) { case $rootService->getEtablissementDN(): return $rootService->getStructureEntity(); default: try { return $structureService->getBy($dn, 'dn'); } catch (Exception $e) { return null; } } } /** Loading @@ -407,7 +413,7 @@ class People extends BasePeople */ public function getStructure() { $structureService = $this->getService()->getLdapStructureService(); $structureService = $this->service->getLdapStructureService(); $value = $this->eduPersonOrgUnitDN; if (empty($value)) return null; Loading @@ -422,7 +428,7 @@ class People extends BasePeople */ public function getStructurePrincipale() { $structureService = $this->getService()->getLdapStructureService(); $structureService = $this->service->getLdapStructureService(); $value = $this->eduPersonPrimaryOrgUnitDN; if (empty($value)) return null; Loading @@ -433,6 +439,41 @@ class People extends BasePeople } } /** * Vérifie l'appartenance d'une personne à une structure * * @param string|Dn|StructureEntity $value * @return bool * @throws Exception * @throws \Zend\Ldap\Exception\LdapException */ public function isInStructure($value) { $structureService = $this->service->getLdapStructureService(); $structurePrefixe = $structureService->getCodeStructurePrefixe(); if (is_string($value)) { if(Dn::checkDn($value)) { $value = $structureService->getBy($value, 'dn'); } else { if (0 !== strpos($value, $structurePrefixe)) { $value = $structurePrefixe . $value; } $value = $structureService->get($value); } } elseif ($value instanceof Dn) { $value = $structureService->getBy($value->toString(), 'dn'); } if(!$value instanceof StructureEntity) { return false; } $structures = $this->preFormat($this->supannEntiteAffectation); return in_array($value->getId(), $structures); } /** * Retourne les étapes auxquelles appartient la personne * Loading @@ -443,8 +484,8 @@ class People extends BasePeople $value = $this->preFormat($this->supannEtuEtape); if (empty($value)) return null; $label = $this->getLabel('UAI', $this->getService()->getLdapRootService()->getEtablissementUAI()); $structureService = $this->getService()->getLdapStructureService(); $label = $this->getLabel('UAI', $this->service->getLdapRootService()->getEtablissementUAI()); $structureService = $this->service->getLdapStructureService(); list($structureKey) = Entity::getNodeParams($structureService->getType()); $structureBranch = $structureService->getBranches()[0]; $value = array_map(function ($v) use ($label, $structureKey, $structureBranch) { Loading @@ -469,8 +510,8 @@ class People extends BasePeople $value = $this->preFormat($this->supannEtuElementPedagogique); if (empty($value)) return null; $label = $this->getLabel('UAI', $this->getService()->getLdapRootService()->getEtablissementUAI()); $structureService = $this->getService()->getLdapStructureService(); $label = $this->getLabel('UAI', $this->service->getLdapRootService()->getEtablissementUAI()); $structureService = $this->service->getLdapStructureService(); list($structureKey) = Entity::getNodeParams($structureService->getType()); $structureBranch = $structureService->getBranches()[0]; $value = array_map(function ($v) use ($label, $structureKey, $structureBranch) { Loading @@ -485,6 +526,36 @@ class People extends BasePeople return 1 == count($value) ? array_shift($value) : $value; } /** * Retourne les inscriptions complètes d'un étudiant * * @return array */ public function getInscription() { $value = $this->preFormat($this->supannEtuInscription); if (empty($value)) return null; $value = array_map(function ($v) { preg_match(self::$inscription_pattern, $v, $matches); $affect = $matches['affect']; $etape = str_replace($this->getLabel('UAI', $this->service->getLdapRootService()->getEtablissementUAI()), '', $matches['etape']); return [ 'etab' => str_replace($this->getLabel('UAI'), '', $matches['etab']), 'anneeinsc' => $matches['anneeinsc'], 'regimeinsc' => str_replace($this->getLabel('SISE'), '', $matches['regimeinsc']), 'sectdisc' => str_replace($this->getLabel('SISE'), '', $matches['sectdisc']), 'typedip' => str_replace($this->getLabel('SISE'), '', $matches['typedip']), 'cursusann' => str_replace($this->getLabel('SUPANN'), '', $matches['cursusann']), 'affect' => $this->service->getLdapStructureService()->get($affect) ?: $affect, 'diplome' => str_replace($this->getLabel('SISE'), '', $matches['diplome']), 'etape' => $this->service->getLdapStructureService()->get($etape) ?: $etape, ]; }, $value); return 1 == count($value) ? array_shift($value) : $value; } /** * Retourne true si l'argument est au format "supannRoleEntite". * Loading @@ -504,4 +575,22 @@ class People extends BasePeople return false; } /** * Modifie l'ensemble des attributs liés au mot de passe * * @param string $value * @return $this * @throws \UnicaenLdap\Exception * @throws \Zend\Ldap\Exception\LdapException */ public function setPassword(string $value) { parent::setUserPassword($value); parent::setNtPassword($value); parent::setSambaNTPassword($value); parent::setUcbnSquidHash($value); return $this; } } No newline at end of file Loading
src/UnicaenLdap/Entity/Base/Group.php +1 −1 Changes for src/UnicaenLdap/Entity/Base/Group.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ class Group extends Entity { return sprintf('uid=%s,%s', self::MEMBER_NOBODY, $this->getService()->getLdapSystemService()->getBranches()[0] $this->service->getLdapSystemService()->getBranches()[0] ); } Loading
src/UnicaenLdap/Entity/Base/People.php +14 −14 Changes for src/UnicaenLdap/Entity/Base/People.php: 14 added lines, 14 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()->getLdapStructureService()->getCodeStructurePrefixe(); $prefixe = $this->service->getLdapStructureService()->getCodeStructurePrefixe(); $affect = (0 !== strpos($matches['affect'], $prefixe)) ? sprintf('%s%s', $structure_prefixe, $matches['affect']) : $matches['affect']; $prefixe = $this->getService()->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $prefixe = $this->service->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()->getLdapStructureService()->getCodeStructurePrefixe(), ''), $val->get('description')); $val = sprintf('%s;%s', strtr($val->get('supannCodeEntite'), $this->service->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()->getLdapStructureService()->getCodeStructurePrefixe())) { $val = $this->getService()->getLdapStructureService()->getCodeStructurePrefixe() . $val; if (0 !== strpos($val, $this->service->getLdapStructureService()->getCodeStructurePrefixe())) { $val = $this->service->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()->getLdapStructureService()->getCodeStructurePrefixe())) { $val = $this->getService()->getLdapStructureService()->getCodeStructurePrefixe() . $val; if (0 !== strpos($val, $this->service->getLdapStructureService()->getCodeStructurePrefixe())) { $val = $this->service->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()->getLdapStructureService()->getCodeStructurePrefixe(), ''), $val->get('description')); $val = sprintf('%s;%s', strtr($val->get('supannCodeEntite'), $this->service->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()->getLdapStructureService()->getCodeStructurePrefixe(), ''), $val->get('description')); $val = sprintf('%s;%s', strtr($val->get('supannCodeEntite'), $this->service->getLdapStructureService()->getCodeStructurePrefixe(), ''), $val->get('description')); return preg_match(self::$structure_pattern, $val) ? $val : null; } else { return null; Loading @@ -1041,7 +1041,7 @@ class People extends Entity */ public function setEduPersonPrincipalName($value = null, $append = false) { $universiteDomaine = $this->getService()->getLdapRootService()->getEtablissementDomain(); $universiteDomaine = $this->service->getLdapRootService()->getEtablissementDomain(); $value = $this->preFormat($value); $value = array_map(function ($v) use ($universiteDomaine) { list($identifiant, $domaine) = array_pad(explode('@', strtolower($v)), 2, null); Loading Loading @@ -1202,7 +1202,7 @@ class People extends Entity : sprintf('%s%s', $supannLabel, $matches[$part]); } $prefixe = $this->getService()->getLdapStructureService()->getCodeStructurePrefixe(); $prefixe = $this->service->getLdapStructureService()->getCodeStructurePrefixe(); $code = (0 !== strpos($matches['code'], $prefixe)) ? sprintf('%s%s', $prefixe, $matches['code']) : $matches['code']; Loading Loading @@ -1281,7 +1281,7 @@ class People extends Entity * @var string $etape * @var string $adistance */ $prefixe = $this->getService()->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $prefixe = $this->service->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); preg_match('/^(?<etiquette>\{[\w\-:]+\})(?<identifiant>.+)$/', $matches['etape'], $parts); $val = (0 !== strpos($parts['identifiant'], $prefixe)) ? $prefixe . $parts['identifiant'] Loading Loading @@ -1653,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()->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $prefixe = $this->service->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $val = (0 !== strpos($matches['identifiant'], $prefixe)) ? $prefixe . $matches['identifiant'] : $matches['identifiant']; Loading Loading @@ -1684,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()->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $prefixe = $this->service->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $val = (0 !== strpos($matches['identifiant'], $prefixe)) ? $prefixe . $matches['identifiant'] : $matches['identifiant']; Loading
src/UnicaenLdap/Entity/Base/Structure.php +2 −2 Changes for src/UnicaenLdap/Entity/Base/Structure.php: 2 added lines, 2 removed lines. Original line number Diff line number Diff line Loading @@ -110,8 +110,8 @@ class Structure 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->service->getCodeStructurePrefixe())) { $val = $this->service->getCodeStructurePrefixe() . $val; } return $val; } elseif ($val instanceof StructureEntity) { Loading
src/UnicaenLdap/Entity/Group.php +1 −1 Changes for src/UnicaenLdap/Entity/Group.php: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -48,7 +48,7 @@ class Group extends BaseGroup */ public function getMembres($orderBy = null) { $peopleService = $this->getService()->getLdapPeopleService(); $peopleService = $this->service->getLdapPeopleService(); $result = $peopleService->getAllBy($this->member, 'dn', $orderBy); return $result; Loading
src/UnicaenLdap/Entity/People.php +130 −41 Changes for src/UnicaenLdap/Entity/People.php: 130 added lines, 41 removed lines. Original line number Diff line number Diff line Loading @@ -5,7 +5,9 @@ namespace UnicaenLdap\Entity; use DateTime; use UnicaenLdap\Entity\Base\People as BasePeople; use UnicaenLdap\Entity\Structure as StructureEntity; use UnicaenLdap\Entity\System as SystemEntity; use UnicaenLdap\Exception; use Zend\Ldap\Dn; /** * Classe de gestion des entités de la branche "people" de l'annuaire LDAP. Loading Loading @@ -135,6 +137,28 @@ class People extends BasePeople return DateTime::createFromFormat('Ymd h:i:s', $this->schacExpiryDate . ' 00:00:00'); } /** * Retourne le responsable de l'entrée Ldap * * @return People|SystemEntity|string|null * @throws Exception * @throws \Zend\Ldap\Exception\LdapException */ public function getParrain() { $systemService = $this->service->getLdapSystemService(); $node = $this->service->getLdap()->getNode($this->supannParrainDN); $branch = $node->getDn()->get(1); switch($branch['ou']) { case strtolower($this->service->getType()): return $this->service->getBy($node->getDnString(), 'dn'); case strtolower($systemService->getType()): return $systemService->getBy($node->getDnString(), 'dn'); default: return $this->supannParrainDN; } } /** * Retourne l'adresse postale professionnelle * Loading Loading @@ -281,30 +305,6 @@ class People extends BasePeople return $this->whichStatus(parent::STATUS_TEACHER); } /** * Établissement auquel appartient la personne * * @return StructureEntity|null */ public function getEtablissement() { $rootService = $this->getService()->getLdapRootService(); $structureService = $this->getService()->getLdapStructureService(); $dn = $this->eduPersonOrgDN; if (empty($dn)) return null; switch($dn) { case $rootService->getEtablissementDN(): return $rootService->getStructureEntity(); default: try { return $structureService->getBy($dn, 'dn'); } catch (Exception $e) { return null; } } } /** * Retourne le léocode associé à l'individu * Loading Loading @@ -383,21 +383,27 @@ class People extends BasePeople } /** * Modifie l'ensemble des attributs liés au mot de passe * Établissement auquel appartient la personne * * @param string $value * @return $this * @throws \UnicaenLdap\Exception * @throws \Zend\Ldap\Exception\LdapException * @return StructureEntity|null */ public function setPassword(string $value) public function getEtablissement() { parent::setUserPassword($value); parent::setNtPassword($value); parent::setSambaNTPassword($value); parent::setUcbnSquidHash($value); $rootService = $this->service->getLdapRootService(); $structureService = $this->service->getLdapStructureService(); $dn = $this->eduPersonOrgDN; return $this; if (empty($dn)) return null; switch($dn) { case $rootService->getEtablissementDN(): return $rootService->getStructureEntity(); default: try { return $structureService->getBy($dn, 'dn'); } catch (Exception $e) { return null; } } } /** Loading @@ -407,7 +413,7 @@ class People extends BasePeople */ public function getStructure() { $structureService = $this->getService()->getLdapStructureService(); $structureService = $this->service->getLdapStructureService(); $value = $this->eduPersonOrgUnitDN; if (empty($value)) return null; Loading @@ -422,7 +428,7 @@ class People extends BasePeople */ public function getStructurePrincipale() { $structureService = $this->getService()->getLdapStructureService(); $structureService = $this->service->getLdapStructureService(); $value = $this->eduPersonPrimaryOrgUnitDN; if (empty($value)) return null; Loading @@ -433,6 +439,41 @@ class People extends BasePeople } } /** * Vérifie l'appartenance d'une personne à une structure * * @param string|Dn|StructureEntity $value * @return bool * @throws Exception * @throws \Zend\Ldap\Exception\LdapException */ public function isInStructure($value) { $structureService = $this->service->getLdapStructureService(); $structurePrefixe = $structureService->getCodeStructurePrefixe(); if (is_string($value)) { if(Dn::checkDn($value)) { $value = $structureService->getBy($value, 'dn'); } else { if (0 !== strpos($value, $structurePrefixe)) { $value = $structurePrefixe . $value; } $value = $structureService->get($value); } } elseif ($value instanceof Dn) { $value = $structureService->getBy($value->toString(), 'dn'); } if(!$value instanceof StructureEntity) { return false; } $structures = $this->preFormat($this->supannEntiteAffectation); return in_array($value->getId(), $structures); } /** * Retourne les étapes auxquelles appartient la personne * Loading @@ -443,8 +484,8 @@ class People extends BasePeople $value = $this->preFormat($this->supannEtuEtape); if (empty($value)) return null; $label = $this->getLabel('UAI', $this->getService()->getLdapRootService()->getEtablissementUAI()); $structureService = $this->getService()->getLdapStructureService(); $label = $this->getLabel('UAI', $this->service->getLdapRootService()->getEtablissementUAI()); $structureService = $this->service->getLdapStructureService(); list($structureKey) = Entity::getNodeParams($structureService->getType()); $structureBranch = $structureService->getBranches()[0]; $value = array_map(function ($v) use ($label, $structureKey, $structureBranch) { Loading @@ -469,8 +510,8 @@ class People extends BasePeople $value = $this->preFormat($this->supannEtuElementPedagogique); if (empty($value)) return null; $label = $this->getLabel('UAI', $this->getService()->getLdapRootService()->getEtablissementUAI()); $structureService = $this->getService()->getLdapStructureService(); $label = $this->getLabel('UAI', $this->service->getLdapRootService()->getEtablissementUAI()); $structureService = $this->service->getLdapStructureService(); list($structureKey) = Entity::getNodeParams($structureService->getType()); $structureBranch = $structureService->getBranches()[0]; $value = array_map(function ($v) use ($label, $structureKey, $structureBranch) { Loading @@ -485,6 +526,36 @@ class People extends BasePeople return 1 == count($value) ? array_shift($value) : $value; } /** * Retourne les inscriptions complètes d'un étudiant * * @return array */ public function getInscription() { $value = $this->preFormat($this->supannEtuInscription); if (empty($value)) return null; $value = array_map(function ($v) { preg_match(self::$inscription_pattern, $v, $matches); $affect = $matches['affect']; $etape = str_replace($this->getLabel('UAI', $this->service->getLdapRootService()->getEtablissementUAI()), '', $matches['etape']); return [ 'etab' => str_replace($this->getLabel('UAI'), '', $matches['etab']), 'anneeinsc' => $matches['anneeinsc'], 'regimeinsc' => str_replace($this->getLabel('SISE'), '', $matches['regimeinsc']), 'sectdisc' => str_replace($this->getLabel('SISE'), '', $matches['sectdisc']), 'typedip' => str_replace($this->getLabel('SISE'), '', $matches['typedip']), 'cursusann' => str_replace($this->getLabel('SUPANN'), '', $matches['cursusann']), 'affect' => $this->service->getLdapStructureService()->get($affect) ?: $affect, 'diplome' => str_replace($this->getLabel('SISE'), '', $matches['diplome']), 'etape' => $this->service->getLdapStructureService()->get($etape) ?: $etape, ]; }, $value); return 1 == count($value) ? array_shift($value) : $value; } /** * Retourne true si l'argument est au format "supannRoleEntite". * Loading @@ -504,4 +575,22 @@ class People extends BasePeople return false; } /** * Modifie l'ensemble des attributs liés au mot de passe * * @param string $value * @return $this * @throws \UnicaenLdap\Exception * @throws \Zend\Ldap\Exception\LdapException */ public function setPassword(string $value) { parent::setUserPassword($value); parent::setNtPassword($value); parent::setSambaNTPassword($value); parent::setUcbnSquidHash($value); return $this; } } No newline at end of file