[TikiWiki-commits] [Git][tikiwiki/tiki][master] [FIX] Address QA issues for Groups Emulation module (Visibility, Session Leak, and Param logic)

"ushindi bienvenu \(@usbbush\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6a2bc01a80549_37141ffe061335@gitlab-sidekiq-low-urgency-cpu-bound-v2-677db6d654-nzz4w.mail>

ushindi bienvenu pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
9a5b6cdc by Aksanti Bahiga at 2026-06-12T07:56:53+00:00
[FIX] Address QA issues for Groups Emulation module (Visibility, Session Leak, and Param logic)
---
* refactor: include Anonymous and Registered groups by default in mod-func-groups_emulation

* fix: remove redundant group emulation session cleanup and simplify group assignment logic

* [FIX] Address QA issues for Groups Emulation module (Visibility, Session Leak, and Param logic)

See merge request tikiwiki/tiki!10471

- - - - -


2 changed files:

- modules/mod-func-groups_emulation.php
- templates/modules/mod-groups_emulation.tpl


Changes:

=====================================
modules/mod-func-groups_emulation.php
=====================================
@@ -16,7 +16,7 @@ function module_groups_emulation_info()
         'params' => [
             'showallgroups' => [
                 'name' => tra('Show All Groups'),
-                'description' => tra('Show All Groups') . '. ' . tra('If set to "n", the list is not shown.'),
+                'description' => tra('Show the list of all system groups and include them in the emulation dropdown.') . ' ' . tra('If set to "n", the list is not shown and groups are excluded from the dropdown. Admin only.'),
                 'filter' => 'alpha',
                 'default' => 'y',
                 'since' => '13.1',
@@ -27,7 +27,7 @@ function module_groups_emulation_info()
             ],
             'showyourgroups' => [
                 'name' => tra('Show Your Groups'),
-                'description' => tra('Show Your Groups') . '. ' . tra('If set to "n", the list is not shown.'),
+                'description' => tra('Show the list of your assigned groups and include them in the emulation dropdown.') . ' ' . tra('If set to "n", the list is not shown and groups are excluded from the dropdown.'),
                 'filter' => 'alpha',
                 'default' => 'y',
                 'since' => '13.1',
@@ -50,6 +50,12 @@ function module_groups_emulation($mod_reference, $module_params)
 {
     global $user, $tiki_p_admin;
 
+    // Anonymous users can only emulate anonymous permissions, which is pointless.
+    // Hide the module entirely for non-logged-in users.
+    if (empty($user) || strtolower($user) === 'anonymous') {
+        return false;
+    }
+
     $userlib = TikiLib::lib('user');
     $smarty = TikiLib::lib('smarty');
 
@@ -77,19 +83,21 @@ function module_groups_emulation($mod_reference, $module_params)
 
     // Extract list of groups of user, including included groups
     $userGroups = $userlib->get_user_groups_inclusion($user);
-    if ($tiki_p_admin == 'y') {
+
+    // Build the choosable groups for the dropdown, respecting params
+    $chooseGroups = [];
+    if ($showallgroups == 'y' && $tiki_p_admin == 'y') {
         $chooseGroups = $allGroups;
-    } else {
+    } elseif ($showyourgroups == 'y') {
         $chooseGroups = $userGroups;
     }
     $chooseGroups["Anonymous"] = "included";
-    if (isset($user)) {
-        $chooseGroups["Registered"] = "included";
-    }
+    $chooseGroups["Registered"] = "included";
 
     $moduleId = $mod_reference['moduleId'];
     $smarty->assign('moduleId', $moduleId);
 
+
     $smarty->assign_by_ref('userGroups', $userGroups);
     $smarty->assign_by_ref('chooseGroups', $chooseGroups);
     $smarty->assign('showallgroups', $showallgroups);


=====================================
templates/modules/mod-groups_emulation.tpl
=====================================
@@ -1,4 +1,5 @@
 {strip}
+{if $user and $user|lower neq 'anonymous'}
 {tikimodule error=$module_params.error title=$tpl_module_title name="groups_emulation" flip=$module_params.flip decorations=$module_params.decorations nobox=$module_params.nobox notitle=$module_params.notitle}
 
     <style>
@@ -91,6 +92,7 @@
         </div>
     {/if}
 
+    {if $chooseGroups|@count > 0}
     <form method="get" action="tiki-emulate_groups_switch.php" target="_self" onsubmit="return !!document.getElementById('mge-select-groups-{$moduleId}').value;">
         <fieldset>
             <legend><strong>{tr}Switch to Groups{/tr}</strong></legend>
@@ -102,6 +104,10 @@
             <div class="text-center mt-2"><button type="submit" class="btn btn-primary" name="emulategroups" value="setgroups" id="mge-simulate-btn-{$moduleId}">{tr}Simulate{/tr}</button></div>
         </fieldset>
     </form>
+    {/if}
 
 {/tikimodule}
+{else}
+<span class="d-none"></span>
+{/if}
 {/strip}



View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/9a5b6cdc627fc161c053dab44eca6d8f9959d936

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/9a5b6cdc627fc161c053dab44eca6d8f9959d936
You're receiving this email because of your account on gitlab.com. Manage all notifications: https://gitlab.com/-/profile/notifications | Help: https://gitlab.com/help

_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.