Refactor global stats handling and user ID access

Moved global stats logic from LayoutHelper to Domain model and updated views/controllers to use the new stats structure. Replaced direct $_SESSION['user_id'] access with Core\Auth::id() for consistency. Cleaned up redundant code and improved isolation mode handling for statistics.
This commit is contained in:
Hosteroid
2025-10-20 18:38:58 +03:00
parent 719fb86c7a
commit 7ad01a7da0
8 changed files with 47 additions and 91 deletions

View File

@@ -27,13 +27,11 @@ class DashboardController extends Controller
$settingModel = new \App\Models\Setting();
$isolationMode = $settingModel->getValue('user_isolation_mode', 'shared');
// Get statistics based on isolation mode
// Get data based on isolation mode (stats are now handled in base.php)
if ($isolationMode === 'isolated') {
$stats = $this->domainModel->getStatistics($userId);
$recentDomains = $this->domainModel->getRecent(5, $userId);
$groups = $this->groupModel->getAllWithChannelCount($userId);
} else {
$stats = $this->domainModel->getStatistics();
$recentDomains = $this->domainModel->getRecent(5);
$groups = $this->groupModel->getAllWithChannelCount();
}
@@ -59,12 +57,7 @@ class DashboardController extends Controller
$formattedRecentDomains = \App\Helpers\DomainHelper::formatMultiple($recentDomains);
$formattedExpiringDomains = \App\Helpers\DomainHelper::formatMultiple($expiringThisMonth);
// Get global stats for dashboard cards
$globalStats = \App\Helpers\LayoutHelper::getGlobalStats($userId);
$this->view('dashboard/index', [
'stats' => $stats,
'globalStats' => $globalStats,
'recentDomains' => $formattedRecentDomains,
'expiringThisMonth' => $formattedExpiringDomains,
'expiringCount' => count($allExpiringDomains),