From a371309b7f4c2cd6333ffa4683d93af265710d52 Mon Sep 17 00:00:00 2001 From: Amit sharma Date: Mon, 20 Apr 2026 16:48:55 +0530 Subject: [PATCH] Use a centralized function for module enable/disable (single and bulk). --- .../template/controllers/modules/js.tpl | 44 ++++++- .../template/controllers/modules/list.tpl | 4 +- controllers/admin/AdminModulesController.php | 117 +++++++----------- 3 files changed, 86 insertions(+), 79 deletions(-) diff --git a/admin/themes/default/template/controllers/modules/js.tpl b/admin/themes/default/template/controllers/modules/js.tpl index 1daef2d32..79097c46a 100644 --- a/admin/themes/default/template/controllers/modules/js.tpl +++ b/admin/themes/default/template/controllers/modules/js.tpl @@ -62,11 +62,11 @@ module_list.push(modules[i].value); } } - + module_list = encodeURIComponent(module_list.join('|')); - if (action == 'bulk_enable' || action == 'bulk_disable') { - var type = action == 'bulk_disable' ? 'disabled' : 'enabled'; - document.location.href = currentIndex+'&token='+token+'&bulk_enable=1&type='+type+'&modules='+module_list; + if (action == 'enable' || action == 'disable') { + var type = action == 'disable' ? 0 : 1; + document.location.href = currentIndex+'&token='+token+'&enable='+type+'&module_name='+module_list; return false; } @@ -74,6 +74,40 @@ return false; } + function filter_modules_by_name(table, moduleName) + { + var moduleNames = moduleName.split('|'); + var filteredNames = []; + for (var i = 0; i < moduleNames.length; i++) { + moduleNames[i] = $.trim(moduleNames[i]); + if (moduleNames[i] !== '') { + filteredNames.push(moduleNames[i].toLowerCase()); + } + } + + if (!filteredNames.length) { + return; + } + + if (filteredNames.length === 1) { + $.uiTableFilter(table, filteredNames[0]); + return; + } + + table.find('tbody tr').each(function() { + var rowText = $(this).text().toLowerCase(); + var isMatch = false; + + for (var i = 0; i < filteredNames.length; i++) { + if (rowText.indexOf(filteredNames[i]) !== -1) { + isMatch = true; + break; + } + } + + $(this).toggle(isMatch); + }); + } $('document').ready( function() { // ScrollTo @@ -81,7 +115,7 @@ $.uiTableFilter($('#moduleContainer').find('table'), anchor); if (module_name != '') - $.uiTableFilter($('#moduleContainer').find('table'), module_name); + filter_modules_by_name($('#moduleContainer').find('table'), module_name); $('#moduleQuicksearch').on('keyup', function(){ val = this.value; diff --git a/admin/themes/default/template/controllers/modules/list.tpl b/admin/themes/default/template/controllers/modules/list.tpl index 8acf25921..9fab8630b 100644 --- a/admin/themes/default/template/controllers/modules/list.tpl +++ b/admin/themes/default/template/controllers/modules/list.tpl @@ -191,13 +191,13 @@