Loading src/UnicaenLdap/Entity/Base/Group.php +33 −4 Original line number Diff line number Diff line Loading @@ -269,11 +269,40 @@ class Group 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); if(empty($value)) { $this->appendOrNot('supannRefId', $value, false); } if ($append) { $this->appendOrNot('supannRefId', $value, true); } $newValues = []; foreach ($value as $v) { if (preg_match(self::$attribute_with_label_pattern, $v, $matches)) { $newValues[$matches['etiquette']][] = $matches['value']; } }; foreach ($newValues as $label => $values) { $currentValues = $this->preFormat($this->supannRefId); array_walk($currentValues, function (&$cv) use ($label, $values) { if (preg_match("/^".$label."(?<value>.*)$/", $cv, $matches)) { if(!in_array($matches['value'], $values)) { $this->remove('supannRefId', $cv); $cv = null; } } }); foreach($values as $v) { $v = $label.$v; if (!in_array($v, $currentValues)) { $currentValues[] = $v; } } $this->appendOrNot('supannRefId', array_filter($currentValues), false); } return $this; } Loading src/UnicaenLdap/Entity/Base/People.php +12 −12 Original line number Diff line number Diff line Loading @@ -1540,15 +1540,15 @@ class People extends Entity $newValues = []; foreach ($value as $v) { if (preg_match(self::$attribute_with_label_pattern, $v, $matches)) { $newValues[$matches['etiquette']][] = $matches['identifiant']; $newValues[$matches['etiquette']][] = $matches['value']; } }; foreach ($newValues as $label => $values) { $currentValues = $this->preFormat($this->supannRefId); array_walk($currentValues, function (&$cv) use ($label, $values) { if (preg_match("/^".$label."(?<identifiant>.+)$/", $cv, $matches)) { if(!in_array($matches['identifiant'], $values)) { if (preg_match("/^".$label."(?<value>.*)$/", $cv, $matches)) { if(!in_array($matches['value'], $values)) { $this->remove('supannRefId', $cv); $cv = null; } Loading Loading @@ -1738,15 +1738,15 @@ class People extends Entity $newValues = []; foreach ($value as $v) { if (preg_match(self::$attribute_with_label_pattern, $v, $matches)) { $newValues[$matches['etiquette']][] = $matches['identifiant']; $newValues[$matches['etiquette']][] = $matches['value']; } }; foreach ($newValues as $label => $values) { $currentValues = $this->preFormat($this->unicaenTermsOfUse); array_walk($currentValues, function (&$cv) use ($label, $values) { if (preg_match("/^".$label."(?<identifiant>.+)$/", $cv, $matches)) { if(!in_array($matches['identifiant'], $values)) { if (preg_match("/^".$label."(?<value>.+)$/", $cv, $matches)) { if(!in_array($matches['value'], $values)) { $this->remove('unicaenTermsOfUse', $cv); $cv = null; } Loading Loading @@ -1944,9 +1944,9 @@ class People extends Entity if (is_string($val)) { if (preg_match(self::$attribute_with_label_pattern, $val, $matches)) { $prefixe = $this->service->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $val = (0 !== strpos($matches['identifiant'], $prefixe)) ? $prefixe . $matches['identifiant'] : $matches['identifiant']; $val = (0 !== strpos($matches['value'], $prefixe)) ? $prefixe . $matches['value'] : $matches['value']; return sprintf('%s%s', $matches['etiquette'], $val); } return null; Loading Loading @@ -1975,9 +1975,9 @@ class People extends Entity if (is_string($val)) { if (preg_match(self::$attribute_with_label_pattern, $val, $matches)) { $prefixe = $this->service->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $val = (0 !== strpos($matches['identifiant'], $prefixe)) ? $prefixe . $matches['identifiant'] : $matches['identifiant']; $val = (0 !== strpos($matches['value'], $prefixe)) ? $prefixe . $matches['value'] : $matches['value']; return sprintf('%s%s', $matches['etiquette'], $val); } return null; Loading src/UnicaenLdap/Entity/Base/Structure.php +33 −4 Original line number Diff line number Diff line Loading @@ -220,11 +220,40 @@ class Structure 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); if(empty($value)) { $this->appendOrNot('supannRefId', $value, false); } if ($append) { $this->appendOrNot('supannRefId', $value, true); } $newValues = []; foreach ($value as $v) { if (preg_match(self::$attribute_with_label_pattern, $v, $matches)) { $newValues[$matches['etiquette']][] = $matches['value']; } }; foreach ($newValues as $label => $values) { $currentValues = $this->preFormat($this->supannRefId); array_walk($currentValues, function (&$cv) use ($label, $values) { if (preg_match("/^".$label."(?<value>.*)$/", $cv, $matches)) { if(!in_array($matches['value'], $values)) { $this->remove('supannRefId', $cv); $cv = null; } } }); foreach($values as $v) { $v = $label.$v; if (!in_array($v, $currentValues)) { $currentValues[] = $v; } } $this->appendOrNot('supannRefId', array_filter($currentValues), false); } return $this; } Loading src/UnicaenLdap/Entity/Entity.php +1 −1 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ abstract class Entity /** * Liste des patterns génériques utilisés pour différents attributs */ static protected $attribute_with_label_pattern = '/^(?<etiquette>\{[\w\-:]+\})(?<identifiant>.+)$/'; static protected $attribute_with_label_pattern = '/^(?<etiquette>\{[\w\-:]+\})(?<value>.*)$/'; /** * Liste des patterns spécifiques utilisés pour différents attributs Loading Loading
src/UnicaenLdap/Entity/Base/Group.php +33 −4 Original line number Diff line number Diff line Loading @@ -269,11 +269,40 @@ class Group 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); if(empty($value)) { $this->appendOrNot('supannRefId', $value, false); } if ($append) { $this->appendOrNot('supannRefId', $value, true); } $newValues = []; foreach ($value as $v) { if (preg_match(self::$attribute_with_label_pattern, $v, $matches)) { $newValues[$matches['etiquette']][] = $matches['value']; } }; foreach ($newValues as $label => $values) { $currentValues = $this->preFormat($this->supannRefId); array_walk($currentValues, function (&$cv) use ($label, $values) { if (preg_match("/^".$label."(?<value>.*)$/", $cv, $matches)) { if(!in_array($matches['value'], $values)) { $this->remove('supannRefId', $cv); $cv = null; } } }); foreach($values as $v) { $v = $label.$v; if (!in_array($v, $currentValues)) { $currentValues[] = $v; } } $this->appendOrNot('supannRefId', array_filter($currentValues), false); } return $this; } Loading
src/UnicaenLdap/Entity/Base/People.php +12 −12 Original line number Diff line number Diff line Loading @@ -1540,15 +1540,15 @@ class People extends Entity $newValues = []; foreach ($value as $v) { if (preg_match(self::$attribute_with_label_pattern, $v, $matches)) { $newValues[$matches['etiquette']][] = $matches['identifiant']; $newValues[$matches['etiquette']][] = $matches['value']; } }; foreach ($newValues as $label => $values) { $currentValues = $this->preFormat($this->supannRefId); array_walk($currentValues, function (&$cv) use ($label, $values) { if (preg_match("/^".$label."(?<identifiant>.+)$/", $cv, $matches)) { if(!in_array($matches['identifiant'], $values)) { if (preg_match("/^".$label."(?<value>.*)$/", $cv, $matches)) { if(!in_array($matches['value'], $values)) { $this->remove('supannRefId', $cv); $cv = null; } Loading Loading @@ -1738,15 +1738,15 @@ class People extends Entity $newValues = []; foreach ($value as $v) { if (preg_match(self::$attribute_with_label_pattern, $v, $matches)) { $newValues[$matches['etiquette']][] = $matches['identifiant']; $newValues[$matches['etiquette']][] = $matches['value']; } }; foreach ($newValues as $label => $values) { $currentValues = $this->preFormat($this->unicaenTermsOfUse); array_walk($currentValues, function (&$cv) use ($label, $values) { if (preg_match("/^".$label."(?<identifiant>.+)$/", $cv, $matches)) { if(!in_array($matches['identifiant'], $values)) { if (preg_match("/^".$label."(?<value>.+)$/", $cv, $matches)) { if(!in_array($matches['value'], $values)) { $this->remove('unicaenTermsOfUse', $cv); $cv = null; } Loading Loading @@ -1944,9 +1944,9 @@ class People extends Entity if (is_string($val)) { if (preg_match(self::$attribute_with_label_pattern, $val, $matches)) { $prefixe = $this->service->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $val = (0 !== strpos($matches['identifiant'], $prefixe)) ? $prefixe . $matches['identifiant'] : $matches['identifiant']; $val = (0 !== strpos($matches['value'], $prefixe)) ? $prefixe . $matches['value'] : $matches['value']; return sprintf('%s%s', $matches['etiquette'], $val); } return null; Loading Loading @@ -1975,9 +1975,9 @@ class People extends Entity if (is_string($val)) { if (preg_match(self::$attribute_with_label_pattern, $val, $matches)) { $prefixe = $this->service->getLdapStructureService()->getCodeModuleEnseignementPrefixe(); $val = (0 !== strpos($matches['identifiant'], $prefixe)) ? $prefixe . $matches['identifiant'] : $matches['identifiant']; $val = (0 !== strpos($matches['value'], $prefixe)) ? $prefixe . $matches['value'] : $matches['value']; return sprintf('%s%s', $matches['etiquette'], $val); } return null; Loading
src/UnicaenLdap/Entity/Base/Structure.php +33 −4 Original line number Diff line number Diff line Loading @@ -220,11 +220,40 @@ class Structure 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); if(empty($value)) { $this->appendOrNot('supannRefId', $value, false); } if ($append) { $this->appendOrNot('supannRefId', $value, true); } $newValues = []; foreach ($value as $v) { if (preg_match(self::$attribute_with_label_pattern, $v, $matches)) { $newValues[$matches['etiquette']][] = $matches['value']; } }; foreach ($newValues as $label => $values) { $currentValues = $this->preFormat($this->supannRefId); array_walk($currentValues, function (&$cv) use ($label, $values) { if (preg_match("/^".$label."(?<value>.*)$/", $cv, $matches)) { if(!in_array($matches['value'], $values)) { $this->remove('supannRefId', $cv); $cv = null; } } }); foreach($values as $v) { $v = $label.$v; if (!in_array($v, $currentValues)) { $currentValues[] = $v; } } $this->appendOrNot('supannRefId', array_filter($currentValues), false); } return $this; } Loading
src/UnicaenLdap/Entity/Entity.php +1 −1 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ abstract class Entity /** * Liste des patterns génériques utilisés pour différents attributs */ static protected $attribute_with_label_pattern = '/^(?<etiquette>\{[\w\-:]+\})(?<identifiant>.+)$/'; static protected $attribute_with_label_pattern = '/^(?<etiquette>\{[\w\-:]+\})(?<value>.*)$/'; /** * Liste des patterns spécifiques utilisés pour différents attributs Loading