From cd54f169f15ee8c4212a10b7bf5ca5a039f926d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20OUDOT?= Date: Fri, 30 Jun 2023 12:14:43 +0200 Subject: [PATCH 1/2] Configuration of labels for dn_link viewers --- conf/config.inc.php | 3 +++ htdocs/index.php | 3 +++ templates/value_displayer.tpl | 6 +++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/conf/config.inc.php b/conf/config.inc.php index e6710f0..a72b390 100644 --- a/conf/config.inc.php +++ b/conf/config.inc.php @@ -74,6 +74,9 @@ ); $attributes_list = array(); +$dn_link_label_attributes = array("cn"); +$group_dn_link_label_attributes = array("description","cn"); +$usergroup_dn_link_label_attributes = array("description","cn"); # Quick search $use_quick_search = true; diff --git a/htdocs/index.php b/htdocs/index.php index f3ff577..c9200d1 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -76,6 +76,9 @@ $smarty->assign('display_footer',$display_footer); $smarty->assign('logout_link',isset($logout_link) ? $logout_link : false); $smarty->assign('attributes_list',$attributes_list); +$smarty->assign('dn_link_label_attributes',implode(",",$dn_link_label_attributes)); +$smarty->assign('group_dn_link_label_attributes',implode(",",$group_dn_link_label_attributes)); +$smarty->assign('usergroup_dn_link_label_attributes',implode(",",$usergroup_dn_link_label_attributes)); # Assign messages $smarty->assign('lang',$lang); diff --git a/templates/value_displayer.tpl b/templates/value_displayer.tpl index 3d473ff..733a27c 100644 --- a/templates/value_displayer.tpl +++ b/templates/value_displayer.tpl @@ -11,21 +11,21 @@ {/if} {if $type eq 'dn_link'} - {assign var="link" value="{{get_attribute dn="{$value}" attribute="cn" ldap_url="{$ldap_params.ldap_url}" ldap_starttls="{$ldap_params.ldap_starttls}" ldap_binddn="{$ldap_params.ldap_binddn}" ldap_bindpw="{$ldap_params.ldap_bindpw}" ldap_filter="{$ldap_params.ldap_user_filter}" ldap_network_timeout="{$ldap_params.ldap_network_timeout}"}|truncate:{$truncate_value_after}}"} + {assign var="link" value="{{get_attribute dn="{$value}" attribute="{$dn_link_label_attributes}" ldap_url="{$ldap_params.ldap_url}" ldap_starttls="{$ldap_params.ldap_starttls}" ldap_binddn="{$ldap_params.ldap_binddn}" ldap_bindpw="{$ldap_params.ldap_bindpw}" ldap_filter="{$ldap_params.ldap_user_filter}" ldap_network_timeout="{$ldap_params.ldap_network_timeout}"}|truncate:{$truncate_value_after}}"} {if $link} {$link}
{/if} {/if} {if $type eq 'group_dn_link'} - {assign var="link" value="{{get_attribute dn="{$value}" attribute="cn,description" ldap_url="{$ldap_params.ldap_url}" ldap_starttls="{$ldap_params.ldap_starttls}" ldap_binddn="{$ldap_params.ldap_binddn}" ldap_bindpw="{$ldap_params.ldap_bindpw}" ldap_filter="{$ldap_params.ldap_group_filter}" ldap_network_timeout="{$ldap_params.ldap_network_timeout}"}|truncate:{$truncate_value_after}}"} + {assign var="link" value="{{get_attribute dn="{$value}" attribute="{$group_dn_link_label_attributes}" ldap_url="{$ldap_params.ldap_url}" ldap_starttls="{$ldap_params.ldap_starttls}" ldap_binddn="{$ldap_params.ldap_binddn}" ldap_bindpw="{$ldap_params.ldap_bindpw}" ldap_filter="{$ldap_params.ldap_group_filter}" ldap_network_timeout="{$ldap_params.ldap_network_timeout}"}|truncate:{$truncate_value_after}}"} {if $link} {$link}
{/if} {/if} {if $type eq 'usergroup_dn_link'} - {assign var="link" value="{{get_attribute dn="{$value}" attribute="cn,description" ldap_url="{$ldap_params.ldap_url}" ldap_starttls="{$ldap_params.ldap_starttls}" ldap_binddn="{$ldap_params.ldap_binddn}" ldap_bindpw="{$ldap_params.ldap_bindpw}" ldap_filter="(|{$ldap_params.ldap_group_filter}{$ldap_params.ldap_user_filter})" ldap_network_timeout="{$ldap_params.ldap_network_timeout}"}|truncate:{$truncate_value_after}}"} + {assign var="link" value="{{get_attribute dn="{$value}" attribute="{$usergroup_dn_link_label_attributes}" ldap_url="{$ldap_params.ldap_url}" ldap_starttls="{$ldap_params.ldap_starttls}" ldap_binddn="{$ldap_params.ldap_binddn}" ldap_bindpw="{$ldap_params.ldap_bindpw}" ldap_filter="(|{$ldap_params.ldap_group_filter}{$ldap_params.ldap_user_filter})" ldap_network_timeout="{$ldap_params.ldap_network_timeout}"}|truncate:{$truncate_value_after}}"} {if $link} {$link}
{/if} From 11c72afc80de181c64c2f2acb492cc97d827a9ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20OUDOT?= Date: Fri, 30 Jun 2023 12:24:34 +0200 Subject: [PATCH 2/2] Documentation for dn_link customization --- docs/attributes.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/attributes.rst b/docs/attributes.rst index 4bf97c6..5ce546e 100644 --- a/docs/attributes.rst +++ b/docs/attributes.rst @@ -71,6 +71,14 @@ To manage a list, you need to define how keys and values are searched in LDAP di The attribute set in ``key`` will be used as select key, and the attribute set in ``value`` will be used as select value. +It is also possible to configure which attribute is displayed as value on ``dn_link``, ``group_dn_link``, ``usergroup_dn_link`` types. For each type, an array is defined, and the first attribute found is used: + +.. code-block:: php + + $dn_link_label_attributes = array("cn"); + $group_dn_link_label_attributes = array("description","cn"); + $usergroup_dn_link_label_attributes = array("description","cn"); + .. tip:: You can translate attribute label by defining the ``label_item`` messages in custom lang file, for example :