Skip to content

Commit

Permalink
Merge pull request #132 from Worteks/issue-129-configure-label-dn-link
Browse files Browse the repository at this point in the history
Configure values for DN links
  • Loading branch information
coudot authored Jun 30, 2023
2 parents 8156f98 + 11c72af commit 17e13d4
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
3 changes: 3 additions & 0 deletions conf/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions docs/attributes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down
3 changes: 3 additions & 0 deletions htdocs/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions templates/value_displayer.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
<a href="index.php?page=display&dn={$value|escape:'url'}&search={$search}">{$link}</a><br />
{/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}
<a href="index.php?page=display&dn={$value|escape:'url'}&search={$search}">{$link}</a><br />
{/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}
<a href="index.php?page=display&dn={$value|escape:'url'}&search={$search}">{$link}</a><br />
{/if}
Expand Down

0 comments on commit 17e13d4

Please sign in to comment.