Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions htdocs/modules/system/themes/modern/language/english/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@

// -- Dashboard: KPI Cards --
define('_MODERN_TOTAL_USERS', 'Total Users');
define('_MODERN_NEW_THIS_MONTH', 'new this month');
define('_MODERN_NEW_THIS_MONTH', 'New this month');
define('_MODERN_ACTIVE_MODULES', 'Active Modules');
define('_MODERN_INACTIVE', 'inactive');
define('_MODERN_ACTIVE_MODULES_USERS', 'User-Facing Modules');
define('_MODERN_ACTIVE_MODULES_ADMINS', 'Admin-Only Modules');
define('_MODERN_ACTIVE_USERS', 'Active Users');
define('_MODERN_LAST_30_DAYS', 'Last 30 days');
define('_MODERN_SERVER_LOAD', 'Server Load');
Expand Down
17 changes: 10 additions & 7 deletions htdocs/modules/system/themes/modern/modern.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,18 +243,21 @@ private function getModuleStats(&$tpl)
{
/** @var XoopsModuleHandler $module_handler */
$module_handler = xoops_getHandler('module');

$criteria = new CriteriaCompo();
$criteria->add(new Criteria('hasmain', 1));
// active modules
$criteria->add(new Criteria('isactive', 1));

$active_modules = $module_handler->getCount($criteria);

$criteria_all = new Criteria('dirname', '', '!=');
$total_modules = $module_handler->getCount($criteria_all);
// active modules for user side
$criteria->add(new Criteria('hasmain', 1));
$active_modules_user = $module_handler->getCount($criteria);

$tpl->assign('active_modules', $active_modules);
$tpl->assign('total_modules', $total_modules);
$tpl->assign('inactive_modules', $total_modules - $active_modules);
$tpl->assign('active_modules_user', $active_modules_user);
// Modules without a frontend entry (hasmain=0) are admin-only by XOOPS design.
// Every active module has at least hasmain=1 or hasadmin=1, so this subtraction
// equals querying isactive=1 AND hasmain=0 without an extra DB round-trip.
$tpl->assign('active_modules_admin', $active_modules - $active_modules_user);
Comment thread
ggoffy marked this conversation as resolved.
Comment on lines 247 to +260
Copy link

Copilot AI Apr 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

active_modules_admin is currently derived as active_modules - active_modules_user (i.e., active modules without hasmain). That doesn't actually represent “modules for admins”: modules that have both user side (hasmain=1) and an admin side (hasadmin=1) are excluded from the admin count, and modules with neither hasmain nor hasadmin would be included. Consider either (a) counting admin modules with an explicit hasadmin=1 criteria (separate CriteriaCompo) or (b) renaming the label/variable to reflect that it's counting “admin-only / no-user-side” modules and also filtering hasadmin=1 to avoid counting modules with no admin UI.

Copilot uses AI. Check for mistakes.
Comment on lines +257 to +260
Copy link

Copilot AI Apr 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The KPI label says "Admin-Only Modules", but the value is computed as active_modules - active_modules_user, which is effectively “active modules without hasmain=1” (i.e., not user-facing) and does not check hasadmin=1. To avoid misleading counts, either (a) change the label to reflect “modules without frontend entry”, or (b) compute admin-only as isactive=1 AND hasadmin=1 AND hasmain=0 (using a separate criteria/count).

Copilot uses AI. Check for mistakes.
}

/**
Expand Down
5 changes: 3 additions & 2 deletions htdocs/modules/system/themes/modern/xotpl/xo_dashboard.tpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<{* Dashboard shown only on admin.php homepage *}>
<{if $xoops_dirname == 'system' && !isset($smarty.get.fct)}>
<{if $xoops_page == 'admin'}>
<section class="dashboard-section">
<!-- KPI Cards -->
<div class="kpis">
Expand All @@ -16,7 +16,8 @@
<div class="kpi-label"><{$smarty.const._MODERN_ACTIVE_MODULES}></div>
<div class="kpi-value"><{$active_modules}></div>
<div class="kpi-change">
<span><{$inactive_modules}> <{$smarty.const._MODERN_INACTIVE}></span>
<span><{$smarty.const._MODERN_ACTIVE_MODULES_USERS}>: <{$active_modules_user}><br>
<{$smarty.const._MODERN_ACTIVE_MODULES_ADMINS}>: <{$active_modules_admin}></span>
</div>
</div>

Expand Down
Loading