Commit 2b620cf1 authored by Antoine Gallavardin's avatar Antoine Gallavardin
Browse files

managing special field referentiel>taxonomy field

parent 9eb783ae
......@@ -31,9 +31,10 @@ class term extends simplePlugin
'name' => _('Terms Lists'),
'icon' => 'geticon.php?context=applications&icon=term&size=16',
'ou' => get_ou('fdTaxonomyTermsRDN'),
]],
//'plSearchAttrs' => ['description'],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo(), TRUE)
'mainAttr' => 'fdTaxonomyTermCode',
]],
'plSearchAttrs' => ['description'],
'plProvidedAcls' => parent::generatePlProvidedAcls(static::getAttributesInfo(), TRUE)
];
}
......@@ -48,21 +49,25 @@ class term extends simplePlugin
_('Code'), _('Code name of Term'),
'fdTaxonomyTermCode', TRUE
),
new StringAttribute(
_('Description'), _('Short description of this terms'),
'description', FALSE
),
new StringAttribute(
_('Referentiel'), _('Referentiel used'),
'fdTaxonomyReferentiel', FALSE
new SelectAttribute(
_('Referentiel'), _('Referentiel used'),
'ReferentielAndTaxonomy', FALSE,
[],
),
new TextAreaAttribute(
_('Term Long Label'), _('Long Label of Term code'),
'fdTaxonomyTermLongLabel', FALSE
),
new StringAttribute(
new HiddenArrayAttribute('fdTaxonomyReferentiel',FALSE,[] ),
new HiddenArrayAttribute('fdTaxonomyName',FALSE,[]),
/*new StringAttribute(
_('Taxonomy Name'), _('Name of taxonomy belonging to the Referentiel'),
'fdTaxonomyName', FALSE
),
),*/
new TextAreaAttribute(
_('Term Long Label'), _('Long Label of Term code'),
'fdTaxonomyTermLongLabel', FALSE
_('Description'), _('Short description of this terms'),
'description', FALSE
),
new DateAttribute(
_('StartDate'), _('Start Date of validity '),
......@@ -75,7 +80,7 @@ class term extends simplePlugin
'fdTaxonomyTermEndDate', FALSE,
'Ymd', '',
'today', NULL
)
),
]
]
];
......@@ -85,47 +90,23 @@ class term extends simplePlugin
{
global $config;
parent::__construct($dn, $object, $parent, $mainTab);
foreach ($config->get_cfg_value('TaxonomyList', []) as $taxonomy) {
list($referentiel, $taxonomy,$policy,$startDate,$endDate) = explode(';', $taxonomy);
// TODO : test the policy and the start/end Date
$ref_tax[] = $referentiel.">".$taxonomy;
}
$initval=$this->fdTaxonomyReferentiel[0].">".$this->fdTaxonomyName[0];
//list($code_entites, $label_entites) = static::listPossibleParentEntities();
//$this->attributesAccess['supannCodeEntiteParent']->attribute->setChoices($code_entites, $label_entites);
//$this->attributesAccess['ou']->setUnique('one');
//$this->attributesAccess['supannCodeEntite']->setUnique('whole', '(objectClass=supannEntite)');
//$this->attributesAccess['supannRefId']->setUnique('whole', '(objectClass=supannEntite)');
$this->attributesAccess['ReferentielAndTaxonomy']->setChoices($ref_tax);
}
//static public function listPossibleParentEntities (): array
//{
//global $config;
//$ldap = $config->get_ldap_link();
//$ldap->cd($config->current['BASE']);
//$ldap->search('(objectClass=supannEntite)', ['supannCodeEntite','ou','o','description']);
//$code_entites = [''];
//$label_entites = [''];
//while ($attrs = $ldap->fetch()) {
//if (isset($attrs['supannCodeEntite'][0])) {
//$code_entites[] = $attrs['supannCodeEntite'][0];
//if (isset($attrs['description'][0])) {
//$description = $attrs['description'][0];
//if (mb_strlen($description, 'UTF-8') > 30) {
//$description = mb_substr($description, 0, 27, 'UTF-8').'...';
//}
//$description = ' ('.$description.')';
//} else {
//$description = '';
//}
//if (isset($attrs['ou'][0])) {
//$label_entites[] = $attrs['ou'][0].$description;
//} else {
//$label_entites[] = $attrs['o'][0].$description;
//}
//}
//}
//return [$code_entites, $label_entites];
//}
protected function prepare_save (): array
{
$refAndTex = $this->attributesAccess['ReferentielAndTaxonomy']->getValue();
$hRefAndTex = explode('>', $refAndTex);
$this->fdTaxonomyReferentiel = $hRefAndTex[0];
$this->fdTaxonomyName = $hRefAndTex[1];
$this->ReferentielAndTaxonomy='';
return parent::prepare_save();
}
}
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