[TikiWiki-commits] [Git][tikiwiki/tiki][30.x] [FIX] Preferences: Unable to enable preferences for custom modules containing...

"luci \(@luciash\) via TikiWiki-cvs" <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6a0331c4a22e2_381dec334756ab@gitlab-sidekiq-low-urgency-cpu-bound-v2-8b6f44c4b-jz59q.mail>

luci pushed to branch 30.x at Tiki Wiki CMS Groupware / Tiki


Commits:
cc4c5861 by NasserNgandu at 2026-05-12T13:50:04+00:00
[FIX] Preferences: Unable to enable preferences for custom modules containing special characters like spaces or dots
---
* [FIX] Preferences: Unable to enable preferences for custom modules containing special characters like spaces or dots

See merge request tikiwiki/tiki!10197

- - - - -


4 changed files:

- lib/modules/modlib.php
- lib/prefs/module.php
- templates/admin/include_module.tpl
- templates/tiki-admin_modules.tpl


Changes:

=====================================
lib/modules/modlib.php
=====================================
@@ -533,10 +533,12 @@ class ModLib extends TikiLib
         global $page, $prefs, $user;
         $section = Sections::getCurrentSection();
         $tikilib = TikiLib::lib('tiki');
+        $pref_module_name = 'module_' . preg_replace('/[^a-zA-Z0-9]/', '_', $module["name"]);
 
-        if ($prefs['module_' . $module["name"]] != 'y') {
+        if (! isset($prefs[$pref_module_name]) || $prefs[$pref_module_name] != 'y') {
             return false;
         }
+
         if (TikiLib::lib('login')->isSwitched() && isset($_SESSION["keep_login_box_visible"]) && $_SESSION["keep_login_box_visible"] == 'y') {
             if ($module["name"] === "login_box" && (! isset($module["mode"]) || isset($module["mode"]) === "module")) {
                 return true;


=====================================
lib/prefs/module.php
=====================================
@@ -104,7 +104,7 @@ function prefs_module_list()
     ];
     foreach ($all_modules as $name) {
         $modinfo = $modlib->get_module_info($name);
-        $pref_modules['module_' . $name] = [
+        $pref_modules['module_' . preg_replace('/[^a-zA-Z0-9]/', '_', $name)] = [
             'name' => $modinfo['name'],
             'type' => 'flag',
             'description' => $modinfo['description'],


=====================================
templates/admin/include_module.tpl
=====================================
@@ -46,7 +46,7 @@
             <fieldset>
                 <legend class="h3">{tr}Enable/Disable Modules{/tr}</legend>
                 {foreach from=$all_modules item=name}
-                    {preference name="module_{$name}"}
+                    {preference name="module_{$name|regex_replace:'/[^a-zA-Z0-9]/':'_'}"}
                 {/foreach}
             </fieldset>
         </div>


=====================================
templates/tiki-admin_modules.tpl
=====================================
@@ -80,7 +80,8 @@
                                     </tr>
                                     {if isset($assigned_modules[$zone_initial])}
                                     {foreach $assigned_modules[$zone_initial] as $module}
-                                        {if isset($prefs['module_'|cat:$module.name]) && $prefs['module_'|cat:$module.name] eq 'y'}
+                                        {assign var="pref_module_name" value="module_"|cat:($module.name|regex_replace:"/[^a-z0-9]/":"_")}
+                                        {if isset($prefs[$pref_module_name]) && $prefs[$pref_module_name] eq 'y'}
                                             <tr>
                                                 <td>{$module.name|escape}</td>
                                                 <td>{$module.ord}</td>
@@ -393,6 +394,7 @@
                 </div>
                 <ul id="module_list" class="p-0">
                     {foreach key=name item=info from=$all_modules_info}
+                        {assign var="pref_module_name" value="module_"|cat:($module.name|regex_replace:"/[^a-z0-9]/":"_")}
                         {if isset($prefs['module_'|cat:$name]) && $prefs['module_'|cat:$name] eq 'y'}
                             <li class="{if !empty($info.enabled)}enabled{else}disabled{/if} clearfix">
                                 <input type="hidden" value="{$name}">



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

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/cc4c5861cdbd106e36190c529ccc39a24b5a35f3
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.