From bf6ebf171d1f8f1757ca03d8cecfa84c934684e7 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Thu, 27 Aug 2015 18:28:13 +0200 Subject: [PATCH] LSattr_html :: select_list : add values_attribute parameter --- .../LSattr_html_select_list.docbook | 11 +++++++ .../class/class.LSattr_html_select_list.php | 33 ++++++++++++++----- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/doc/conf/LSattribute/LSattr_html/LSattr_html_select_list.docbook b/doc/conf/LSattribute/LSattr_html/LSattr_html_select_list.docbook index fe27e6a7..a0abe284 100644 --- a/doc/conf/LSattribute/LSattr_html/LSattr_html_select_list.docbook +++ b/doc/conf/LSattribute/LSattr_html/LSattr_html_select_list.docbook @@ -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 @@ + + values_attribute + + 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 + value_attribute. + + + filter diff --git a/public_html/includes/class/class.LSattr_html_select_list.php b/public_html/includes/class/class.LSattr_html_select_list.php index c7b3a4b3..fb2fa321 100644 --- a/public_html/includes/class/class.LSattr_html_select_list.php +++ b/public_html/includes/class/class.LSattr_html_select_list.php @@ -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,23 +172,38 @@ 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(($conf['value_attribute']=='dn')||($conf['value_attribute']=='%{dn}')) { - $retInfos = $LSsearch -> listObjectsName(); + if (isset($val['value_attribute'])) { + if(($conf['value_attribute']=='dn')||($conf['value_attribute']=='%{dn}')) { + $retInfos = $LSsearch -> listObjectsName(); + } + else { + $list = $LSsearch -> getSearchEntries(); + foreach($list as $entry) { + $key = $entry -> get($conf['value_attribute']); + if(is_array($key)) { + $key = $key[0]; + } + $retInfos[$key]=$entry -> displayName; + } + } } - else { + if (isset($conf['values_attribute'])) { $list = $LSsearch -> getSearchEntries(); foreach($list as $entry) { - $key = $entry -> get($conf['value_attribute']); - if(is_array($key)) { - $key = $key[0]; + $keys = $entry -> get($conf['values_attribute']); + if (!is_array($keys)) $keys=array($keys); + foreach ($keys as $key) { + $retInfos[$key]=$key; } - $retInfos[$key]=$entry -> displayName; } }