diff --git a/src/conf/LSaddons/config.LSaddons.dyngroup.php b/src/conf/LSaddons/config.LSaddons.dyngroup.php index 72884d5f..12160b1e 100644 --- a/src/conf/LSaddons/config.LSaddons.dyngroup.php +++ b/src/conf/LSaddons/config.LSaddons.dyngroup.php @@ -29,6 +29,9 @@ // Dynamic group object type define('DYNGROUP_OBJECT_TYPE', 'LSdyngroup'); +// Dynamic group member object type +define('DYNGROUP_MEMBER_OBJECT_TYPE', 'LSpeople'); + /* * Members DN attributes */ diff --git a/src/conf/LSobjects/config.LSobjects.LSdyngroup.php b/src/conf/LSobjects/config.LSobjects.LSdyngroup.php index cc0bbf6e..286ff0c1 100644 --- a/src/conf/LSobjects/config.LSobjects.LSdyngroup.php +++ b/src/conf/LSobjects/config.LSobjects.LSdyngroup.php @@ -40,6 +40,16 @@ $GLOBALS['LSobjects']['LSdyngroup'] = array ( 'label' => 'Dynamic groups', 'customActions' => array ( + 'showDyngroupMembers' => array ( + 'label' => 'Show members', + 'icon' => 'group', + 'function' => 'showDyngroupMembers', + 'noConfirmation' => true, + 'disableOnSuccessMsg' => true, + 'rights' => array ( + 'admin', + ), + ), 'showTechInfo' => array ( 'function' => 'showTechInfo', 'label' => 'Show technical information', diff --git a/src/css/default/showDyngroupMembers.css b/src/css/default/showDyngroupMembers.css new file mode 100644 index 00000000..e0563405 --- /dev/null +++ b/src/css/default/showDyngroupMembers.css @@ -0,0 +1,11 @@ +#showDyngroupMembers { + margin-left: 1em; +} + +#showDyngroupMembers table.LStable tr.error { + background-color: var(--error-color); +} + +#showDyngroupMembers table.LStable .center { + text-align: center; +} diff --git a/src/images/default/group.png b/src/images/default/group.png new file mode 100644 index 00000000..7fb4e1f1 Binary files /dev/null and b/src/images/default/group.png differ diff --git a/src/includes/addons/LSaddons.dyngroup.php b/src/includes/addons/LSaddons.dyngroup.php index ef3c3614..dac722b3 100644 --- a/src/includes/addons/LSaddons.dyngroup.php +++ b/src/includes/addons/LSaddons.dyngroup.php @@ -361,6 +361,68 @@ function triggerUpdateDynGroupsMembersCacheOnUserChanges(&$user, &$changed_attrs return !$error; } +/** + * Show dyngroup members + * + * @author Benjamin Renard + * + * @param LSldapObject $ldapObject The LSldapObject + * + * @return array|false array of memberUid URI attribute values or false in case of error + */ +function showDyngroupMembers($ldapObject) { + $member_dns = ensureIsArray($ldapObject -> attrs[ DYNGROUP_MEMBER_DN_ATTRIBUTE ] -> getValue()); + $cache_member_dns = ensureIsArray($ldapObject -> attrs[ DYNGROUP_MEMBER_DN_STATIC_ATTRIBUTE ] -> getValue()); + $member_uids = ensureIsArray($ldapObject -> attrs[ DYNGROUP_MEMBER_UID_ATTRIBUTE ] -> getValue()); + $cache_member_uids = ensureIsArray($ldapObject -> attrs[ DYNGROUP_MEMBER_UID_STATIC_ATTRIBUTE ] -> getValue()); + sort($member_dns); + sort($cache_member_dns); + sort($member_uids); + sort($cache_member_uids); + LStemplate :: assign('member_dns', $member_dns); + LStemplate :: assign('cache_member_dns', $cache_member_dns); + LStemplate :: assign('member_uids', $member_uids); + LStemplate :: assign('cache_member_uids', $cache_member_uids); + + if ( + defined('DYNGROUP_MEMBER_OBJECT_TYPE') + && LSsession :: loadLSobject(constant('DYNGROUP_MEMBER_OBJECT_TYPE')) + ) { + $member_type = constant('DYNGROUP_MEMBER_OBJECT_TYPE'); + $uid2dn = ( + LSconfig :: get("LSobjects.$member_type.rdn")."=%{uid},". + LSconfig :: get("LSobjects.$member_type.container_dn").",". + LSsession :: getTopDn() + ); + LStemplate :: assign('member_object_type', $member_type); + LStemplate :: assign('uid2dn', $uid2dn); + } + else { + LStemplate :: assign('member_object_type', null); + } + + LStemplate :: assign('pagetitle', getFData(_('%{name}: members'), $ldapObject -> getDisplayName())); + + $LSview_actions=array(); + $LSview_actions['return'] = array ( + 'label' => _('Go back'), + 'url' => 'object/'.$ldapObject->getType().'/'.urlencode($ldapObject->getDn()), + 'action' => 'view' + ); + LStemplate :: assign('LSview_actions', $LSview_actions); + + if (LSsession :: loadLSclass('LSform')) { + LSform :: loadDependenciesDisplayView(); + } + + LStemplate :: addCssFile('showDyngroupMembers.css'); + LSsession :: setTemplate('showDyngroupMembers.tpl'); + + // Display template + LSsession :: displayTemplate(); + exit(); +} + if (php_sapi_name() != 'cli') return true; diff --git a/src/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.mo b/src/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.mo index 19df34ff..bf1025db 100644 Binary files a/src/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.mo and b/src/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.mo differ diff --git a/src/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.po b/src/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.po index 79b958b6..e6ba98b4 100644 --- a/src/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.po +++ b/src/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.po @@ -8,7 +8,7 @@ msgstr "" "Project-Id-Version: LdapSaisie\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2024-06-05 12:29+0200\n" +"PO-Revision-Date: 2024-06-19 17:52+0200\n" "Last-Translator: Benjamin Renard \n" "Language-Team: LdapSaisie \n" @@ -322,6 +322,7 @@ msgstr "Vos modifications ont été enregistrées." #: includes/addons/LSaddons.mail.php:565 #: includes/addons/LSaddons.showSupportInfo.php:78 +#: includes/addons/LSaddons.dyngroup.php:408 #: includes/addons/LSaddons.accesslog.php:248 #: includes/addons/LSaddons.showTechInfo.php:128 msgid "Go back" @@ -407,6 +408,10 @@ msgstr "" "délai de quelques minutes pourra être nécessaire pour que vos modifications " "soient prises en compte sur ces groupes." +#: includes/addons/LSaddons.dyngroup.php:404 +msgid "%{name}: members" +msgstr "%{name} : membres" + #: includes/addons/LSaddons.posix.php:27 msgid "POSIX Support: The constant %{const} is not defined." msgstr "Support POSIX : La constante %{const} n'est pas définie." @@ -3727,6 +3732,11 @@ msgstr "Identifiant" msgid "Imported objects" msgstr "Objets importés" +#: templates/default/showDyngroupMembers.tpl:12 +#: templates/default/showDyngroupMembers.tpl:68 +msgid "In cache" +msgstr "En cache" + #: templates/default/recoverpassword.tpl:13 templates/default/login.tpl:12 msgid "LDAP server" msgstr "Serveur LDAP" @@ -3747,6 +3757,16 @@ msgstr "Légende :" msgid "Logout" msgstr "Déconnexion" +#: templates/default/showDyngroupMembers.tpl:63 +#: templates/default/showDyngroupMembers.tpl:67 +msgid "Members's DN" +msgstr "DNs des membres" + +#: templates/default/showDyngroupMembers.tpl:7 +#: templates/default/showDyngroupMembers.tpl:11 +msgid "Members's UID" +msgstr "UID des membres" + #: templates/default/LSmail.tpl:28 msgid "Message" msgstr "Message" @@ -3776,6 +3796,14 @@ msgstr "Aucun champ." msgid "No imported object" msgstr "Aucun objet importé" +#: templates/default/showDyngroupMembers.tpl:113 +msgid "No member's DN." +msgstr "Aucun DN de membre." + +#: templates/default/showDyngroupMembers.tpl:57 +msgid "No member's UID." +msgstr "Aucun UID de membre." + #: templates/default/import.tpl:65 msgid "No value" msgstr "Aucune valeur" diff --git a/src/lang/ldapsaisie.pot b/src/lang/ldapsaisie.pot index baec5b74..a492f801 100644 --- a/src/lang/ldapsaisie.pot +++ b/src/lang/ldapsaisie.pot @@ -250,6 +250,7 @@ msgstr "" #: includes/addons/LSaddons.mail.php:565 #: includes/addons/LSaddons.showSupportInfo.php:78 +#: includes/addons/LSaddons.dyngroup.php:408 #: includes/addons/LSaddons.accesslog.php:248 #: includes/addons/LSaddons.showTechInfo.php:128 msgid "Go back" @@ -320,6 +321,10 @@ msgid "" "necessary to handle your changes on this groups." msgstr "" +#: includes/addons/LSaddons.dyngroup.php:404 +msgid "%{name}: members" +msgstr "" + #: includes/addons/LSaddons.posix.php:27 msgid "POSIX Support: The constant %{const} is not defined." msgstr "" @@ -3203,6 +3208,11 @@ msgstr "" msgid "Imported objects" msgstr "" +#: templates/default/showDyngroupMembers.tpl:12 +#: templates/default/showDyngroupMembers.tpl:68 +msgid "In cache" +msgstr "" + #: templates/default/recoverpassword.tpl:13 templates/default/login.tpl:12 msgid "LDAP server" msgstr "" @@ -3223,6 +3233,16 @@ msgstr "" msgid "Logout" msgstr "" +#: templates/default/showDyngroupMembers.tpl:63 +#: templates/default/showDyngroupMembers.tpl:67 +msgid "Members's DN" +msgstr "" + +#: templates/default/showDyngroupMembers.tpl:7 +#: templates/default/showDyngroupMembers.tpl:11 +msgid "Members's UID" +msgstr "" + #: templates/default/LSmail.tpl:28 msgid "Message" msgstr "" @@ -3252,6 +3272,14 @@ msgstr "" msgid "No imported object" msgstr "" +#: templates/default/showDyngroupMembers.tpl:113 +msgid "No member's DN." +msgstr "" + +#: templates/default/showDyngroupMembers.tpl:57 +msgid "No member's UID." +msgstr "" + #: templates/default/import.tpl:65 msgid "No value" msgstr "" diff --git a/src/templates/default/showDyngroupMembers.tpl b/src/templates/default/showDyngroupMembers.tpl new file mode 100644 index 00000000..24216b33 --- /dev/null +++ b/src/templates/default/showDyngroupMembers.tpl @@ -0,0 +1,119 @@ +{extends file='ls:base_connected.tpl'} +{block name="content"} +
+

{$pagetitle}

+ {include file='ls:LSview_actions.tpl'} + +

{tr msg="Members's UID"}

+ + + + + + + + + {if $member_uids || $cache_member_uids} + {foreach $member_uids as $uid} + {if in_array($uid, $cache_member_uids)} + + + + + {else} + + + + + {/if} + {/foreach} + {foreach $cache_member_uids as $uid} + {if in_array($uid, $member_uids)}{continue}{/if} + + + + + {/foreach} + {else} + + + + {/if} + +
{tr msg="Members's UID"}{tr msg="In cache"}
+ {if $member_object_type} + {$uid} + {else} + {$uid} + {/if} +
+ {if $member_object_type} + {$uid} + {else} + {$uid} + {/if} + X
X + {if $member_object_type} + {$uid} + {else} + {$uid} + {/if} +
{tr msg="No member's UID."}
+ +

{tr msg="Members's DN"}

+ + + + + + + + + {if $member_dns || $cache_member_dns} + {foreach $member_dns as $dn} + {if in_array($dn, $cache_member_dns)} + + + + + {else} + + + + + {/if} + {/foreach} + {foreach $cache_member_dns as $dn} + {if in_array($dn, $member_dns)}{continue}{/if} + + + + + {/foreach} + {else} + + + + {/if} + +
{tr msg="Members's DN"}{tr msg="In cache"}
+ {if $member_object_type} + {$dn} + {else} + {$dn} + {/if} +
+ {if $member_object_type} + {$dn} + {else} + {$dn} + {/if} + X
X + {if $member_object_type} + {$dn} + {else} + {$dn} + {/if} +
{tr msg="No member's DN."}
+
+{/block}