Add user profile & dashboard insights
Introduce a user profile page and expand dashboard insights/UI. Added UserController::show and a new users/show view with user stats, domains, tags and groups; updated users index to include a "view profile" link and changed edit form action to /users/{id}/update. Enhanced DashboardController to compute registrar distribution, notification coverage, channel totals and dashboard tag usage; updated dashboard/index.php to show system status, expiring list, registrar/tag widgets and notification coverage panels. Minor controller hardening: DomainController now returns a permission message when a domain is inaccessible, and TagController enforces isolation-mode access checks. UI/JS improvements: add a Quick Actions dropdown in top-nav, refactor dropdown toggle/close logic in layout/base.php, and small notification markup tweak. Routes were adjusted to expose the new user profile endpoints.
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user