diff --git a/app/Controllers/DashboardController.php b/app/Controllers/DashboardController.php index 4f3a69b..8d49cc3 100644 --- a/app/Controllers/DashboardController.php +++ b/app/Controllers/DashboardController.php @@ -57,6 +57,37 @@ class DashboardController extends Controller $formattedRecentDomains = \App\Helpers\DomainHelper::formatMultiple($recentDomains); $formattedExpiringDomains = \App\Helpers\DomainHelper::formatMultiple($expiringThisMonth); + // Get all domains for registrar distribution & notification coverage + if ($isolationMode === 'isolated') { + $allDomains = $this->domainModel->getAllWithGroups($userId); + } else { + $allDomains = $this->domainModel->getAllWithGroups(); + } + + // Registrar distribution + $registrarCounts = []; + foreach ($allDomains as $d) { + $reg = !empty($d['registrar']) ? $d['registrar'] : 'Unknown'; + $registrarCounts[$reg] = ($registrarCounts[$reg] ?? 0) + 1; + } + arsort($registrarCounts); + + // Notification coverage + $domainsWithGroup = count(array_filter($allDomains, fn($d) => !empty($d['group_name']))); + $totalDomainCount = count($allDomains); + + // Total channels + $totalChannels = 0; + foreach ($groups as $g) { $totalChannels += ($g['channel_count'] ?? 0); } + + // Get user's tags with usage + $tagModel = new \App\Models\Tag(); + if ($isolationMode === 'isolated') { + $dashTags = $tagModel->getAllWithUsage($userId); + } else { + $dashTags = $tagModel->getAllWithUsage(); + } + $this->view('dashboard/index', [ 'recentDomains' => $formattedRecentDomains, 'expiringThisMonth' => $formattedExpiringDomains, @@ -64,6 +95,11 @@ class DashboardController extends Controller 'recentLogs' => $recentLogs, 'groups' => $groups, 'systemStatus' => $systemStatus, + 'registrarCounts' => $registrarCounts, + 'domainsWithGroup' => $domainsWithGroup, + 'totalDomainCount' => $totalDomainCount, + 'totalChannels' => $totalChannels, + 'dashTags' => $dashTags, 'title' => 'Dashboard' ]); } diff --git a/app/Controllers/DomainController.php b/app/Controllers/DomainController.php index 23a8d5d..bde5cfc 100644 --- a/app/Controllers/DomainController.php +++ b/app/Controllers/DomainController.php @@ -531,7 +531,7 @@ class DomainController extends Controller } if (!$domain) { - $_SESSION['error'] = 'Domain not found'; + $_SESSION['error'] = 'You do not have permission to view this domain.'; $this->redirect('/domains'); return; } diff --git a/app/Controllers/TagController.php b/app/Controllers/TagController.php index f0a9ff0..51a60c2 100644 --- a/app/Controllers/TagController.php +++ b/app/Controllers/TagController.php @@ -250,6 +250,13 @@ class TagController extends Controller $userId = \Core\Auth::id(); $settingModel = new \App\Models\Setting(); $isolationMode = $settingModel->getValue('user_isolation_mode', 'shared'); + + // Check if user can access this tag in isolation mode + if ($isolationMode === 'isolated' && !$this->tagModel->canUserAccessTag($id, $userId, true)) { + $_SESSION['error'] = 'You do not have permission to view this tag.'; + $this->redirect('/tags'); + return; + } // Get domains for this tag with proper formatting $domainModel = new \App\Models\Domain(); diff --git a/app/Controllers/UserController.php b/app/Controllers/UserController.php index 1f5815e..a3a3f31 100644 --- a/app/Controllers/UserController.php +++ b/app/Controllers/UserController.php @@ -195,6 +195,62 @@ class UserController extends Controller } } + /** + * Show user profile view (admin) + */ + public function show($params = []) + { + $userId = $params['id'] ?? 0; + $user = $this->userModel->find($userId); + + if (!$user) { + $_SESSION['error'] = 'User not found'; + $this->redirect('/users'); + return; + } + + // Get user's domains (formatted for display) + $domainModel = new \App\Models\Domain(); + $domains = $domainModel->getAllWithGroups($userId); + $domains = \App\Helpers\DomainHelper::formatMultiple($domains); + $userDomainStats = $domainModel->getStatistics($userId); + + // Get user's tags with domains per tag + $tagModel = new \App\Models\Tag(); + $tags = $tagModel->getAllWithUsage($userId); + + // Fetch domains for each tag (formatted for display) + foreach ($tags as &$tag) { + $tagDomains = $tagModel->getDomainsForTag($tag['id'], $userId); + $tag['domains'] = \App\Helpers\DomainHelper::formatMultiple($tagDomains); + } + unset($tag); + + // Get user's notification groups with channels + $groupModel = new \App\Models\NotificationGroup(); + $groups = $groupModel->getAllWithChannelCount($userId); + + // Fetch channels for each group + $channelModel = new \App\Models\NotificationChannel(); + foreach ($groups as &$group) { + $group['channels'] = $channelModel->getByGroupId($group['id']); + } + unset($group); + + // Get 2FA status + $twoFactorStatus = $this->userModel->getTwoFactorStatus($userId); + + $this->view('users/show', [ + 'title' => htmlspecialchars($user['full_name']) . ' - User Profile', + 'user' => $user, + 'domains' => $domains, + 'userDomainStats' => $userDomainStats, + 'tags' => $tags, + 'groups' => $groups, + 'twoFactorStatus' => $twoFactorStatus, + ]); + } + /** * Show edit user form */ diff --git a/app/Views/dashboard/index.php b/app/Views/dashboard/index.php index 4f575ab..4af6826 100644 --- a/app/Views/dashboard/index.php +++ b/app/Views/dashboard/index.php @@ -9,12 +9,62 @@ if (!isset($domainStats)) { $domainStats = \App\Helpers\LayoutHelper::getDomainStats(); } +// Prepare widget data +$topRegistrars = array_slice($registrarCounts ?? [], 0, 8, true); +$topTags = array_slice(array_filter($dashTags ?? [], fn($t) => ($t['usage_count'] ?? 0) > 0), 0, 8); +$domainsWithoutGroup = ($totalDomainCount ?? 0) - ($domainsWithGroup ?? 0); +$totalGroupCount = count($groups ?? []); + ob_start(); ?> + + +
= htmlspecialchars($domain['domain_name']) ?>
-- = $domain['expiration_date'] ? date('M d, Y', strtotime($domain['expiration_date'])) : 'Unknown' ?> - - = $daysLeft ?> days - -
+ +No domains expiring soon
+within = $domainStats['expiring_threshold'] ?? 30 ?> days
+No domains expiring soon
-within = $domainStats['expiring_threshold'] ?? 30 ?> days
+No registrar data
+No tags in use
+= $domainsWithGroup ?? 0 ?>
+With Notifications
+= $domainsWithoutGroup ?>
+Without Notifications
+No domains to monitor