Verified Commit 2a70172e authored by Côme Chilliet's avatar Côme Chilliet
Browse files

🚑 fix(supann) Fix duplicated id problems

issue #6015
parent fbfb4fe3
...@@ -30,32 +30,32 @@ class SupannCMSAffectationAttribute extends SupannCompositeAttribute ...@@ -30,32 +30,32 @@ class SupannCMSAffectationAttribute extends SupannCompositeAttribute
$attributes = [ $attributes = [
new SelectAttribute( new SelectAttribute(
_('Type'), _('supannCMSType - Card type'), _('Type'), _('supannCMSType - Card type'),
'supannCMSType_type', TRUE, 'supannCMSType_type_'.$ldapName, TRUE,
$types, '', $typeLabels $types, '', $typeLabels
), ),
new SelectAttribute( new SelectAttribute(
_('Format'), _('Card format'), _('Format'), _('Card format'),
'none_format', TRUE, 'none_format_'.$ldapName, TRUE,
$formats, '', $formatLabels $formats, '', $formatLabels
), ),
new StringAttribute( new StringAttribute(
_('Id'), _('Card id'), _('Id'), _('Card id'),
'none_id', TRUE 'none_id_'.$ldapName, TRUE
), ),
new BooleanAttribute( new BooleanAttribute(
_('Valid'), _('Card validity'), _('Valid'), _('Card validity'),
'none_valide', TRUE, 'none_valide_'.$ldapName, TRUE,
TRUE, '', TRUE, '',
'vrai', 'faux' 'vrai', 'faux'
), ),
new SelectAttribute( new SelectAttribute(
_('Source'), _('Card managing system and establishment'), _('Source'), _('Card managing system and establishment'),
'supannCMSSource_source', FALSE, 'supannCMSSource_source_'.$ldapName, FALSE,
$config->get_cfg_value('supannCMSSources', []) $config->get_cfg_value('supannCMSSources', [])
), ),
new GeneralizedTimeDateAttribute( new GeneralizedTimeDateAttribute(
_('End date'), _('End of validity date, if any'), _('End date'), _('End of validity date, if any'),
'supannCMSDateFin_datefin', FALSE, 'supannCMSDateFin_datefin_'.$ldapName, FALSE,
'' ''
), ),
]; ];
...@@ -70,19 +70,19 @@ class SupannCMSAffectationAttribute extends SupannCompositeAttribute ...@@ -70,19 +70,19 @@ class SupannCMSAffectationAttribute extends SupannCompositeAttribute
function supannGetValues (&$values) function supannGetValues (&$values)
{ {
foreach ($this->attributes as &$attribute) { foreach ($this->attributes as &$attribute) {
$shortname = preg_replace('/^([^_]+)_.*$/', '\\1', $attribute->getLdapName()); list($attrname, ) = explode('_', $attribute->getLdapName());
if ($shortname == 'none') { if ($attrname == 'none') {
continue; continue;
} }
$value = $attribute->getValue(); $value = $attribute->getValue();
if (!isset($values[$shortname])) { if (!isset($values[$attrname])) {
$values[$shortname] = []; $values[$attrname] = [];
} }
if ($value == '') { if ($value == '') {
continue; continue;
} }
if ($this->isValid()) { if ($this->isValid()) {
$values[$shortname][$value] = $value; $values[$attrname][$value] = $value;
} }
} }
unset($attribute); unset($attribute);
......
...@@ -29,32 +29,32 @@ class SupannCMSAppAffectationAttribute extends SupannCompositeAttribute ...@@ -29,32 +29,32 @@ class SupannCMSAppAffectationAttribute extends SupannCompositeAttribute
$attributes = [ $attributes = [
new SelectAttribute( new SelectAttribute(
_('Type'), _('supannCMSType - Card type'), _('Type'), _('supannCMSType - Card type'),
'supannCMSType_type', TRUE, 'supannCMSType_type_'.$ldapName, TRUE,
$types, '', $typeLabels $types, '', $typeLabels
), ),
new SelectAttribute( new SelectAttribute(
_('Source'), _('Card managing system and establishment'), _('Source'), _('Card managing system and establishment'),
'supannCMSSource_source', TRUE, 'supannCMSSource_source_'.$ldapName, TRUE,
$config->get_cfg_value('supannCMSSources', []) $config->get_cfg_value('supannCMSSources', [])
), ),
new SelectAttribute( new SelectAttribute(
_('Domain'), _('Application domain'), _('Domain'), _('Application domain'),
'none_domaine', TRUE, 'none_domaine_'.$ldapName, TRUE,
array_column($this->getConfigAppDomains(), 1) array_column($this->getConfigAppDomains(), 1)
), ),
new StringAttribute( new StringAttribute(
_('Id'), _('Application id'), _('Id'), _('Application id'),
'none_id', TRUE 'none_id_'.$ldapName, TRUE
), ),
new BooleanAttribute( new BooleanAttribute(
_('Valid'), _('Application validity'), _('Valid'), _('Application validity'),
'none_valide', TRUE, 'none_valide_'.$ldapName, TRUE,
TRUE, '', TRUE, '',
'vrai', 'faux' 'vrai', 'faux'
), ),
new GeneralizedTimeDateAttribute( new GeneralizedTimeDateAttribute(
_('End date'), _('End of validity date, if any'), _('End date'), _('End of validity date, if any'),
'supannCMSDateFin_datefin', FALSE, 'supannCMSDateFin_datefin_'.$ldapName, FALSE,
'' ''
), ),
]; ];
...@@ -80,19 +80,19 @@ class SupannCMSAppAffectationAttribute extends SupannCompositeAttribute ...@@ -80,19 +80,19 @@ class SupannCMSAppAffectationAttribute extends SupannCompositeAttribute
function supannGetValues (&$values) function supannGetValues (&$values)
{ {
foreach ($this->attributes as &$attribute) { foreach ($this->attributes as &$attribute) {
$shortname = preg_replace('/^([^_]+)_.*$/', '\\1', $attribute->getLdapName()); list($attrname, ) = explode('_', $attribute->getLdapName());
if ($shortname == 'none') { if ($attrname == 'none') {
continue; continue;
} }
$value = $attribute->getValue(); $value = $attribute->getValue();
if (!isset($values[$shortname])) { if (!isset($values[$attrname])) {
$values[$shortname] = []; $values[$attrname] = [];
} }
if ($value == '') { if ($value == '') {
continue; continue;
} }
if ($this->isValid()) { if ($this->isValid()) {
$values[$shortname][$value] = $value; $values[$attrname][$value] = $value;
} }
} }
unset($attribute); unset($attribute);
......
...@@ -32,11 +32,11 @@ class SupannCompositeAttribute extends CompositeAttribute ...@@ -32,11 +32,11 @@ class SupannCompositeAttribute extends CompositeAttribute
$values = []; $values = [];
$m = []; $m = [];
foreach ($this->attributes as &$attribute) { foreach ($this->attributes as &$attribute) {
$shortname = preg_replace('/^[^_]+_/', '', $attribute->getLdapName()); list(, $shortname) = explode('_', $attribute->getLdapName());
if (preg_match("/\\[$shortname=([^\\]]+)\\]/", $value, $m)) { if (preg_match("/\\[$shortname=([^\\]]+)\\]/", $value, $m)) {
$values[] = $m[1]; $values[] = $m[1];
} else { } else {
$values[] = ""; $values[] = '';
} }
} }
unset($attribute); unset($attribute);
...@@ -50,7 +50,7 @@ class SupannCompositeAttribute extends CompositeAttribute ...@@ -50,7 +50,7 @@ class SupannCompositeAttribute extends CompositeAttribute
$i = 0; $i = 0;
foreach ($this->attributes as &$attribute) { foreach ($this->attributes as &$attribute) {
if ($values[$i] != '') { if ($values[$i] != '') {
$shortname = preg_replace('/^[^_]+_/', '', $attribute->getLdapName()); list(, $shortname) = explode('_', $attribute->getLdapName());
$value .= "[$shortname=".$values[$i]."]"; $value .= "[$shortname=".$values[$i]."]";
} }
$i++; $i++;
...@@ -62,15 +62,15 @@ class SupannCompositeAttribute extends CompositeAttribute ...@@ -62,15 +62,15 @@ class SupannCompositeAttribute extends CompositeAttribute
function supannGetValues (&$values) function supannGetValues (&$values)
{ {
foreach ($this->attributes as &$attribute) { foreach ($this->attributes as &$attribute) {
$shortname = preg_replace('/^([^_]+)_.*$/', '\\1', $attribute->getLdapName()); list($attrname, ) = explode('_', $attribute->getLdapName());
$value = $attribute->getValue(); $value = $attribute->getValue();
if (!isset($values[$shortname])) { if (!isset($values[$attrname])) {
$values[$shortname] = []; $values[$attrname] = [];
} }
if ($value == "") { if ($value == '') {
continue; continue;
} }
$values[$shortname][$value] = $value; $values[$attrname][$value] = $value;
} }
unset($attribute); 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