Unverified Commit 02e77f6c authored by Thibault Dockx's avatar Thibault Dockx
Browse files

Feat(SupannEx) - Adds auto-update, fix local codes

Fix local population code selection and creation as well as
implementing auto update for fields within conf backend
parent f3e7960d
......@@ -36,37 +36,12 @@ class supannExtConfig extends simplePlugin
static function getAttributesInfo (): array
{
return [
'localPopulationCodeConf' => [
'name' => _('Local Population Codes'),
'attrs' => [
new SetAttribute(
new CompositeAttribute(
_('Code Configuration'),
'fdLocalPopulationCodeConf',
[
new SelectAttribute(
'Main Code', _('Main Population Code'),
'fdMainPopulationCode', FALSE,
),
new StringAttribute(
_('Local Population Code'), _('Local Population Code'),
'fdLocalPopulationCode', FALSE, ''
),
],
'/^{/',
'{%s}:%s',
'',
_('Local Population Codes')
)
),
]
],
'mainPopulationCodeConf' => [
'name' => _('Main Population Codes'),
'attrs' => [
new SetAttribute(
new CompositeAttribute(
_('Code Configuration'),
_('Main Codes Configuration'),
'fdMainPopulationCodeConf',
[
new SelectAttribute(
......@@ -87,13 +62,37 @@ class supannExtConfig extends simplePlugin
),
]
],
'localPopulationCodeConf' => [
'name' => _('Local Population Codes'),
'attrs' => [
new SetAttribute(
new CompositeAttribute(
_('Local Codes Configuration'),
'fdLocalPopulationCodeConf',
[
new SelectAttribute(
'Main Code', _('Main Population Code'),
'fdMainPopulationCodeSet', FALSE,
),
new StringAttribute(
_('Local Population Code'), _('Local Population Code'),
'fdLocalPopulationCode', FALSE, ''
),
],
'/.*/',
'%s:%s',
'',
_('Local Population Codes')
)
),
]
],
];
}
function __construct ($dn = NULL, $object = NULL, $parent = NULL, $mainTab = FALSE)
{
global $config;
parent::__construct($dn, $object, $parent, $mainTab);
$populationCodeMaster = [
......@@ -104,11 +103,11 @@ class supannExtConfig extends simplePlugin
'{SUPANN}RGPFT' => _('{SUPANN}RGPFT'),
];
//Getting values from LDAP already registered and add the default ones, making array unique if already defined.
$populationCodeMaster += $this->attributesAccess['fdMainPopulationCodeConf']->getValue();
$populationCodeMaster = array_unique($populationCodeMaster);
$this->attributesAccess['fdLocalPopulationCodeConf']->attribute->attributes[0]->setChoices(
array_keys($populationCodeMaster),
array_values($populationCodeMaster)
);
}
......@@ -134,4 +133,23 @@ class supannExtConfig extends simplePlugin
return $populationCodeMaster;
}
/*
* Must return bool to be compliant with the interface
*/
public function update (): bool
{
parent::update();
$this->updateFieldsChoicesAndValues();
return TRUE;
}
protected function updateFieldsChoicesAndValues ()
{
$this->attributesAccess['fdLocalPopulationCodeConf']->attribute->attributes[0]->setChoices(
$this->attributesAccess['fdMainPopulationCodeConf']->getValue(),
$this->attributesAccess['fdMainPopulationCodeConf']->getDisplayValues()
);
}
}
Supports Markdown
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