[TikiWiki-commits] [Git][tikiwiki/tiki][master] [NEW][ENH] Preferences: add Modules to make them optional (A preference for each)

Benoit Grégoire (@benoitg) via TikiWiki-cvs <[email protected]>
Newsgroups gmane.comp.cms.tiki.cvs
Message-ID <6967a40a69aa7_2c9cb08014392@gitlab-sidekiq-low-urgency-cpu-bound-v2-88785c6b5-tr9c9.mail>

Benoit Grégoire pushed to branch master at Tiki Wiki CMS Groupware / Tiki


Commits:
fa6fc479 by NasserNgandu at 2026-01-14T14:01:49+00:00
[NEW][ENH] Preferences: add Modules to make them optional (A preference for each)
---
* [FIX] Code correct.

* Code Correct.

* Code Correct.

* [FIX] Code Correct.

* [FIX] Code Correct.

* [FIX] Code Correct.

* [FIX] COde Correct.

* [FIX] COde Correct.

* [FIX] Code Correct.

* [NEW] Should Tiki modules be optional? (A preference for each)

See merge request tikiwiki/tiki!9283

- - - - -


5 changed files:

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


Changes:

=====================================
lib/modules/modlib.php
=====================================
@@ -523,6 +523,9 @@ class ModLib extends TikiLib
         global $section, $page, $prefs, $user;
         $tikilib = TikiLib::lib('tiki');
 
+        if ($prefs['module_' . $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
=====================================
@@ -6,7 +6,10 @@
 // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
 function prefs_module_list()
 {
-    return [
+    $modlib = TikiLib::lib('mod');
+    $all_modules = $modlib->get_all_modules();
+    sort($all_modules);
+    $pref_modules = [
         'module_zones_top' => [
             'name' => tra('Top module zone'),
             'description' => tra('Activate zone for modules such as site logo, log-in form, etc. (page header)'),
@@ -99,4 +102,14 @@ function prefs_module_list()
             'default' => 'n',
         ],
     ];
+    foreach ($all_modules as $name) {
+        $modinfo = $modlib->get_module_info($name);
+        $pref_modules['module_' . $name] = [
+            'name' => $modinfo['name'],
+            'type' => 'flag',
+            'description' => $modinfo['description'],
+            'default' => 'y',
+        ];
+    }
+    return $pref_modules;
 }


=====================================
templates/admin/include_module.tpl
=====================================
@@ -42,6 +42,14 @@
                 {preference name=module_sidebar_toggle_small_screen}
             </fieldset>
         </div>
+        <div class="adminoptionbox">
+            <fieldset>
+                <legend class="h3">{tr}Enable/Disable Modules{/tr}</legend>
+                {foreach from=$all_modules item=name}
+                    {preference name="module_{$name}"}
+                {/foreach}
+            </fieldset>
+        </div>
 
         {remarksbox type="tip" title="{tr}Hint{/tr}"}
             {tr}If you lose your login module, use tiki-login_scr.php to be able to login!{/tr}


=====================================
templates/tiki-admin_modules.tpl
=====================================
@@ -80,66 +80,68 @@
                                     </tr>
                                     {if isset($assigned_modules[$zone_initial])}
                                     {foreach $assigned_modules[$zone_initial] as $module}
-                                        <tr>
-                                            <td>{$module.name|escape}</td>
-                                            <td>{$module.ord}</td>
-                                            <td>{$module.cache_time}</td>
-                                            <td>{$module.rows}</td>
-                                            <td class="small">{$module.params_presentable}</td>
-                                            <td class="small">{$module.module_groups}</td>
-                                            <td>
-                                                {actions}
-                                                    {strip}
-                                                        <action>
-                                                            <form action="tiki-admin_modules.php" method="post">
-                                                                {ticket}
-                                                                <button
-                                                                    type="submit"
-                                                                    name="modup"
-                                                                    value="{$module.moduleId}"
-                                                                    class="btn btn-link link-list"
-                                                                    {if $module@first} disabled="disabled"{/if}
-                                                                >
-                                                                    {icon name="up"} {tr}Move up{/tr}
-                                                                </button>
-                                                            </form>
-                                                        </action>
-                                                        <action>
-                                                            <form action="tiki-admin_modules.php" method="post">
-                                                                {ticket}
-                                                                <button
-                                                                    type="submit"
-                                                                    name="moddown"
-                                                                    value="{$module.moduleId}"
-                                                                    class="btn btn-link link-list"
-                                                                    {if $module@last} disabled="disabled"{/if}
-                                                                >
-                                                                    {icon name="down"} {tr}Move down{/tr}
-                                                                </button>
-                                                            </form>
-                                                        </action>
-                                                        <action>
-                                                            <a href="tiki-admin_modules.php?edit_assign={$module.moduleId}&cookietab=2#content_admin_modules1-2">
-                                                                {icon name='edit' _menu_text='y' _menu_icon='y' alt="{tr}Edit{/tr}"}
-                                                            </a>
-                                                        </action>
-                                                        <action>
-                                                            <form action="tiki-admin_modules.php" method="post">
-                                                                {ticket}
-                                                                <button
-                                                                    type="submit"
-                                                                    name="unassign_module_id"
-                                                                    value="{$module.moduleId}"
-                                                                    class="btn btn-link link-list"
-                                                                >
-                                                                    {icon name="remove"} {tr}Unassign{/tr}
-                                                                </button>
-                                                            </form>
-                                                        </action>
-                                                    {/strip}
-                                                {/actions}
-                                            </td>
-                                        </tr>
+                                        {if isset($prefs['module_'|cat:$module.name]) && $prefs['module_'|cat:$module.name] eq 'y'}
+                                            <tr>
+                                                <td>{$module.name|escape}</td>
+                                                <td>{$module.ord}</td>
+                                                <td>{$module.cache_time}</td>
+                                                <td>{$module.rows}</td>
+                                                <td class="small">{$module.params_presentable}</td>
+                                                <td class="small">{$module.module_groups}</td>
+                                                <td>
+                                                    {actions}
+                                                        {strip}
+                                                            <action>
+                                                                <form action="tiki-admin_modules.php" method="post">
+                                                                    {ticket}
+                                                                    <button
+                                                                        type="submit"
+                                                                        name="modup"
+                                                                        value="{$module.moduleId}"
+                                                                        class="btn btn-link link-list"
+                                                                        {if $module@first} disabled="disabled"{/if}
+                                                                    >
+                                                                        {icon name="up"} {tr}Move up{/tr}
+                                                                    </button>
+                                                                </form>
+                                                            </action>
+                                                            <action>
+                                                                <form action="tiki-admin_modules.php" method="post">
+                                                                    {ticket}
+                                                                    <button
+                                                                        type="submit"
+                                                                        name="moddown"
+                                                                        value="{$module.moduleId}"
+                                                                        class="btn btn-link link-list"
+                                                                        {if $module@last} disabled="disabled"{/if}
+                                                                    >
+                                                                        {icon name="down"} {tr}Move down{/tr}
+                                                                    </button>
+                                                                </form>
+                                                            </action>
+                                                            <action>
+                                                                <a href="tiki-admin_modules.php?edit_assign={$module.moduleId}&cookietab=2#content_admin_modules1-2">
+                                                                    {icon name='edit' _menu_text='y' _menu_icon='y' alt="{tr}Edit{/tr}"}
+                                                                </a>
+                                                            </action>
+                                                            <action>
+                                                                <form action="tiki-admin_modules.php" method="post">
+                                                                    {ticket}
+                                                                    <button
+                                                                        type="submit"
+                                                                        name="unassign_module_id"
+                                                                        value="{$module.moduleId}"
+                                                                        class="btn btn-link link-list"
+                                                                    >
+                                                                        {icon name="remove"} {tr}Unassign{/tr}
+                                                                    </button>
+                                                                </form>
+                                                            </action>
+                                                        {/strip}
+                                                    {/actions}
+                                                </td>
+                                            </tr>
+                                        {/if}
                                     {foreachelse}
                                         {norecords _colspan=7}
                                     {/foreach}
@@ -391,17 +393,19 @@
                 </div>
                 <ul id="module_list" class="p-0">
                     {foreach key=name item=info from=$all_modules_info}
-                        <li class="{if !empty($info.enabled)}enabled{else}disabled{/if} clearfix">
-                            <input type="hidden" value="{$name}">
-                            <div class="q1 tips"
-                                    title="{$info.name} &lt;em&gt;({$name})&lt;/em&gt;|{$info.description}
-                                    {if not $info.enabled}&lt;br /&gt;&lt;small&gt;&lt;em&gt;({tr}Requires{/tr} {$info.prefs|join:' &amp; '})&lt;/em&gt;&lt;/small&gt;{/if}">
-                                {icon name="module"} <strong>{$info.name}</strong> <em>{$name}</em>
-                            </div>
-                            <div class="description q23">
-                                {$info.description}
-                            </div>
-                        </li>
+                        {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}">
+                                <div class="q1 tips"
+                                        title="{$info.name} &lt;em&gt;({$name})&lt;/em&gt;|{$info.description}
+                                        {if not $info.enabled}&lt;br /&gt;&lt;small&gt;&lt;em&gt;({tr}Requires{/tr} {$info.prefs|join:' &amp; '})&lt;/em&gt;&lt;/small&gt;{/if}">
+                                    {icon name="module"} <strong>{$info.name}</strong> <em>{$name}</em>
+                                </div>
+                                <div class="description q23">
+                                    {$info.description}
+                                </div>
+                            </li>
+                        {/if}
                     {/foreach}
                 </ul>
             </div>


=====================================
tiki-modules.php
=====================================
@@ -71,3 +71,4 @@ $module_nodecorations = ['decorations' => 'n'];
 $module_isflippable = ['flip' => 'y'];
 $smarty->assign('module_nodecorations', $module_nodecorations);
 $smarty->assign('module_isflippable', $module_isflippable);
+$smarty->assign('all_modules', $modlib->get_all_modules());



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

-- 
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/fa6fc47970723271c158c56ecb7831da39f9862e
You're receiving this email because of your account on gitlab.com.

_______________________________________________
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.