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:
@@ -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),
|
||||
|
||||
@@ -100,7 +100,7 @@ class ErrorLogController extends Controller
|
||||
$notes = $_POST['notes'] ?? null;
|
||||
|
||||
// Mark error as resolved using model
|
||||
$this->errorLogModel->markErrorResolved($errorId, $_SESSION['user_id'], $notes);
|
||||
$this->errorLogModel->markErrorResolved($errorId, \Core\Auth::id(), $notes);
|
||||
|
||||
$_SESSION['success'] = 'Error marked as resolved';
|
||||
header('Location: /errors/' . urlencode($errorId));
|
||||
|
||||
Reference in New Issue
Block a user