Loading src/UnicaenLdap/Entity/Base/People.php +37 −93 Changes for src/UnicaenLdap/Entity/Base/People.php: 37 added lines, 93 removed lines. Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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) { Loading Loading @@ -941,8 +941,7 @@ class People extends Entity if (is_string($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); } } Loading Loading @@ -1163,8 +1162,7 @@ class People extends Entity if (is_string($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); } } Loading Loading @@ -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; } Loading Loading @@ -1516,8 +1533,7 @@ class People extends Entity if (is_string($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); } } Loading Loading @@ -1588,8 +1604,7 @@ class People extends Entity if (is_string($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); } } Loading Loading @@ -1701,8 +1716,7 @@ class People extends Entity if (is_string($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); } } Loading Loading @@ -1731,8 +1745,7 @@ class People extends Entity if (is_string($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); } } Loading Loading @@ -1761,8 +1774,7 @@ class People extends Entity if (is_string($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); } } Loading Loading @@ -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) { Loading @@ -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 +2 −1 Changes for src/UnicaenLdap/Entity/People.php: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -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. Loading Loading
src/UnicaenLdap/Entity/Base/People.php +37 −93 Changes for src/UnicaenLdap/Entity/Base/People.php: 37 added lines, 93 removed lines. Original line number Diff line number Diff line Loading @@ -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) { Loading Loading @@ -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) { Loading Loading @@ -941,8 +941,7 @@ class People extends Entity if (is_string($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); } } Loading Loading @@ -1163,8 +1162,7 @@ class People extends Entity if (is_string($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); } } Loading Loading @@ -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; } Loading Loading @@ -1516,8 +1533,7 @@ class People extends Entity if (is_string($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); } } Loading Loading @@ -1588,8 +1604,7 @@ class People extends Entity if (is_string($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); } } Loading Loading @@ -1701,8 +1716,7 @@ class People extends Entity if (is_string($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); } } Loading Loading @@ -1731,8 +1745,7 @@ class People extends Entity if (is_string($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); } } Loading Loading @@ -1761,8 +1774,7 @@ class People extends Entity if (is_string($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); } } Loading Loading @@ -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) { Loading @@ -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 +2 −1 Changes for src/UnicaenLdap/Entity/People.php: 2 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -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. Loading