LSattr_html :: select_list : add values_attribute parameter

This commit is contained in:
Benjamin Renard 2015-08-27 18:28:13 +02:00
parent dda02c0ff4
commit bf6ebf171d
2 changed files with 35 additions and 9 deletions

View file

@ -16,6 +16,7 @@
'object_type' => '[Type d'LSobject]',
'display_name_format' => '[LSformat du nom d'affichage des LSobjects]',
'value_attribute' => '[Nom de l'attribut clé]',
'values_attribute' => '[Nom de l'attribut clé multi-valeur]',
'filter' => '[Filtre de recherche des LSobject]',
'scope' => '[Scope de la recherche]',
'basedn' => '[Basedn de la recherche]'
@ -85,6 +86,16 @@
</listitem>
</varlistentry>
<varlistentry>
<term>values_attribute</term>
<listitem>
<simpara>Nom de l'attribut des &LSobjects; en référence servant de catalogue de
valeurs. Dans ce mode, la valeur n'a pas de label et est affichée directement
dans l'interface. Ce paramètre peut-être utilisé en complément ou non du paramètre
<emphasis>value_attribute</emphasis>.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term>filter</term>
<listitem>

View file

@ -157,7 +157,7 @@ class LSattr_html_select_list extends LSattr_html{
protected function getLSobjectPossibleValues($conf) {
$retInfos = array();
if ((!isset($conf['object_type'])) || (!isset($conf['value_attribute']))) {
if ((!isset($conf['object_type'])) || ((!isset($conf['value_attribute'])) && (!isset($conf['values_attribute'])))) {
LSerror :: addErrorCode('LSattr_html_select_list_01',$this -> name);
break;
}
@ -172,12 +172,16 @@ class LSattr_html_select_list extends LSattr_html{
'displayFormat' => (isset($conf['display_name_format'])?$conf['display_name_format']:null),
);
if ($conf['value_attribute']!='dn') {
if (isset($conf['value_attribute']) && $conf['value_attribute']!='dn') {
$param['attributes'][] = $conf['value_attribute'];
}
if (isset($conf['values_attribute'])) {
$param['attributes'][] = $conf['values_attribute'];
}
$LSsearch = new LSsearch($conf['object_type'],'LSattr_html_select_list',$param,true);
$LSsearch -> run();
if (isset($val['value_attribute'])) {
if(($conf['value_attribute']=='dn')||($conf['value_attribute']=='%{dn}')) {
$retInfos = $LSsearch -> listObjectsName();
}
@ -191,6 +195,17 @@ class LSattr_html_select_list extends LSattr_html{
$retInfos[$key]=$entry -> displayName;
}
}
}
if (isset($conf['values_attribute'])) {
$list = $LSsearch -> getSearchEntries();
foreach($list as $entry) {
$keys = $entry -> get($conf['values_attribute']);
if (!is_array($keys)) $keys=array($keys);
foreach ($keys as $key) {
$retInfos[$key]=$key;
}
}
}
$this -> _sort($retInfos);