Commit 87446ad8 authored by Côme Chilliet's avatar Côme Chilliet
Browse files

Merge branch '5956-add-mapping-sinaps-to-fd-mapping-for-diffusion' into '1.4-dev'

Resolve "add mapping sinaps to Fd mapping for diffusion"

See merge request fusiondirectory/fd-plugins!632
parents 86f0db15 6f48eb94
......@@ -107,7 +107,7 @@ class sinapsConfig extends simplePlugin
'fdSinapsUserDiffusionMap',
[
new StringAttribute(
'', _('Name of the Sinaps attribute'),
'', _('XPath for the XML value to fetch'),
'fdSinapsUserDiffusionMap_sinaps', TRUE
),
new StringAttribute(
......@@ -138,7 +138,7 @@ class sinapsConfig extends simplePlugin
'fdSinapsStructureDiffusionMap',
[
new StringAttribute(
'', _('Name of the Sinaps attribute'),
'', _('XPath for the XML value to fetch'),
'fdSinapsStructureDiffusionMap_sinaps', TRUE
),
new StringAttribute(
......@@ -226,7 +226,7 @@ class sinapsConfig extends simplePlugin
parent::__construct($dn, $object, $parent, $mainTab, $attributesInfo);
$this->attributesAccess['fdSinapsAcquisitionContactMethodMap']->setHeaders([_('LDAP'), _('Sinaps')]);
$this->attributesAccess['fdSinapsUserDiffusionMap']->setHeaders([_('Sinaps'), _('Tab'), _('Field')]);
$this->attributesAccess['fdSinapsStructureDiffusionMap']->setHeaders([_('Sinaps'), _('Tab'), _('Field')]);
$this->attributesAccess['fdSinapsUserDiffusionMap']->setHeaders([_('XPath'), _('Tab'), _('Field')]);
$this->attributesAccess['fdSinapsStructureDiffusionMap']->setHeaders([_('XPath'), _('Tab'), _('Field')]);
}
}
......@@ -145,11 +145,13 @@ class sinapsRequest
array_unshift($values['entite']['supannRefId'], '{'.$uuidPrefix.'}'.$uuid);
foreach ($mapping as $sinapsAttr => list($fdTab, $fdAttr)) {
if (isset($structure->$sinapsAttr)) {
$values[$fdTab][$fdAttr] = (string)$structure->$sinapsAttr;
} else {
foreach ($mapping as $xpath => list($fdTab, $fdAttr)) {
$nodes = $structure->xpath($xpath);
if (empty($nodes)) {
$values[$fdTab][$fdAttr] = '';
} else {
/* Note: We only support monovalued attributes through custom mapping for now */
$values[$fdTab][$fdAttr] = (string)$nodes[0];
}
}
......@@ -294,11 +296,13 @@ class sinapsRequest
return $values;
}
foreach ($mapping as $sinapsAttr => list($fdTab, $fdAttr)) {
if (isset($personne->$sinapsAttr)) {
$values[$fdTab][$fdAttr] = (string)$personne->$sinapsAttr;
} else {
foreach ($mapping as $xpath => list($fdTab, $fdAttr)) {
$nodes = $personne->xpath($xpath);
if (empty($nodes)) {
$values[$fdTab][$fdAttr] = '';
} else {
/* Note: We only support monovalued attributes through custom mapping for now */
$values[$fdTab][$fdAttr] = (string)$nodes[0];
}
}
......
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