Verified Commit 5b483b61 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

feat(supann) Improve template support of SupAnn composite attributes

issue #6015
parent a456f9db
......@@ -74,19 +74,21 @@ class SupannCMSAffectationAttribute extends SupannCompositeAttribute
if ($attrname == 'none') {
continue;
}
$value = $attribute->getValue();
if (!isset($values[$attrname])) {
$values[$attrname] = [];
}
if ($value == '') {
continue;
}
if ($this->isValid()) {
$values[$attrname][$value] = $value;
if (!$this->isTemplate()) {
$value = $attribute->getValue();
if ($value == '') {
continue;
}
if ($this->isValid()) {
$values[$attrname][$value] = $value;
}
}
}
unset($attribute);
if ($this->isValid()) {
if ($this->isValid() && !$this->isTemplate()) {
$format = $this->attributes[1]->getValue();
$id = $this->attributes[2]->getValue();
$supannCMSIdEtiquette = '{'.$format.'}'.$id;
......
......@@ -84,19 +84,21 @@ class SupannCMSAppAffectationAttribute extends SupannCompositeAttribute
if ($attrname == 'none') {
continue;
}
$value = $attribute->getValue();
if (!isset($values[$attrname])) {
$values[$attrname] = [];
}
if ($value == '') {
continue;
}
if ($this->isValid()) {
$values[$attrname][$value] = $value;
if (!$this->isTemplate()) {
$value = $attribute->getValue();
if ($value == '') {
continue;
}
if ($this->isValid()) {
$values[$attrname][$value] = $value;
}
}
}
unset($attribute);
if ($this->isValid()) {
if ($this->isValid() && !$this->isTemplate()) {
$domains = array_column($this->getConfigAppDomains(), 0, 1);
$domain = $this->attributes[2]->getValue();
$id = $this->attributes[3]->getValue();
......
......@@ -33,7 +33,7 @@ class SupannCompositeAttribute extends CompositeAttribute
$m = [];
foreach ($this->attributes as &$attribute) {
list(, $shortname) = explode('_', $attribute->getLdapName());
if (preg_match("/\\[$shortname=([^\\]]+)\\]/", $value, $m)) {
if (preg_match('/\\['.preg_quote($shortname, '/').'=(.+?)(\\]\\[|\\]$)/', $value, $m)) {
$values[] = $m[1];
} else {
$values[] = '';
......@@ -63,14 +63,16 @@ class SupannCompositeAttribute extends CompositeAttribute
{
foreach ($this->attributes as &$attribute) {
list($attrname, ) = explode('_', $attribute->getLdapName());
$value = $attribute->getValue();
if (!isset($values[$attrname])) {
$values[$attrname] = [];
}
if ($value == '') {
continue;
if (!$this->isTemplate()) {
$value = $attribute->getValue();
if ($value == '') {
continue;
}
$values[$attrname][$value] = $value;
}
$values[$attrname][$value] = $value;
}
unset($attribute);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment