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,10 +74,11 @@ class SupannCMSAffectationAttribute extends SupannCompositeAttribute
if ($attrname == 'none') {
continue;
}
$value = $attribute->getValue();
if (!isset($values[$attrname])) {
$values[$attrname] = [];
}
if (!$this->isTemplate()) {
$value = $attribute->getValue();
if ($value == '') {
continue;
}
......@@ -85,8 +86,9 @@ class SupannCMSAffectationAttribute extends SupannCompositeAttribute
$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,10 +84,11 @@ class SupannCMSAppAffectationAttribute extends SupannCompositeAttribute
if ($attrname == 'none') {
continue;
}
$value = $attribute->getValue();
if (!isset($values[$attrname])) {
$values[$attrname] = [];
}
if (!$this->isTemplate()) {
$value = $attribute->getValue();
if ($value == '') {
continue;
}
......@@ -95,8 +96,9 @@ class SupannCMSAppAffectationAttribute extends SupannCompositeAttribute
$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,15 +63,17 @@ class SupannCompositeAttribute extends CompositeAttribute
{
foreach ($this->attributes as &$attribute) {
list($attrname, ) = explode('_', $attribute->getLdapName());
$value = $attribute->getValue();
if (!isset($values[$attrname])) {
$values[$attrname] = [];
}
if (!$this->isTemplate()) {
$value = $attribute->getValue();
if ($value == '') {
continue;
}
$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