jilo-web/app/templates/profile.php

140 lines
6.6 KiB
PHP
Raw Normal View History

2024-09-07 20:05:22 +00:00
2025-11-27 10:44:15 +00:00
<?php
$user = $userDetails[0] ?? [];
$username = $user['username'] ?? '';
$name = $user['name'] ?? '';
$email = $user['email'] ?? '';
$timezoneName = $user['timezone'] ?? '';
$timezoneOffset = $timezoneName ? getUTCOffset($timezoneName) : '';
$bio = trim($user['bio'] ?? '');
$rightsNames = array_map(function ($right) {
return trim($right['right_name'] ?? '');
}, $userRights);
$rightsNames = array_filter($rightsNames, function ($label) {
return $label !== '';
});
$rightsCount = count($rightsNames);
$displayName = $name ?: $username ?: 'User profile';
$profileUserIdForHooks = (int)($user['user_id'] ?? ($userId ?? 0));
2025-11-27 10:44:15 +00:00
$timezoneDisplay = '';
if ($timezoneName) {
if ($timezoneOffset !== '') {
$offsetLabel = stripos($timezoneOffset, 'UTC') === 0 ? $timezoneOffset : 'UTC' . $timezoneOffset;
$timezoneDisplay = sprintf('%s (%s)', $timezoneName, $offsetLabel);
} else {
$timezoneDisplay = $timezoneName;
}
}
2024-09-07 20:05:22 +00:00
2025-11-27 10:44:15 +00:00
?>
2024-09-07 20:05:22 +00:00
2025-11-27 10:44:15 +00:00
<section class="tm-directory tm-profile-view">
<div class="tm-hero-card tm-hero-card--stacked tm-profile-hero">
<div class="tm-profile-hero-main">
<div class="tm-profile-avatar-frame">
<img src="<?= htmlspecialchars($app_root) . htmlspecialchars($avatar) ?>" alt="Avatar of <?= htmlspecialchars($displayName) ?>" />
2024-09-07 20:05:22 +00:00
</div>
2025-11-27 10:44:15 +00:00
<div class="tm-profile-hero-body">
<h1 class="tm-profile-title"><?= htmlspecialchars($displayName) ?></h1>
<p class="tm-profile-subtitle">Personal details and access summary for your <?= htmlspecialchars($config['site_name']); ?> account.</p>
2025-11-27 10:44:15 +00:00
<div class="tm-profile-hero-meta">
<?php if ($username): ?>
<span class="tm-hero-pill pill-neutral">
<i class="fas fa-user"></i>
@<?= htmlspecialchars($username) ?>
</span>
<?php endif; ?>
<?php if ($timezoneDisplay): ?>
<span class="tm-hero-pill pill-primary">
<i class="fas fa-clock"></i>
<?= htmlspecialchars($timezoneDisplay) ?>
</span>
<?php endif; ?>
<span class="tm-hero-pill pill-accent">
<i class="fas fa-shield-alt"></i>
<?= $rightsCount ?> <?= $rightsCount === 1 ? 'Right' : 'Rights' ?>
</span>
2024-09-07 20:05:22 +00:00
</div>
2025-11-27 10:44:15 +00:00
</div>
<div class="tm-profile-hero-actions">
<a class="btn btn-primary" href="<?= htmlspecialchars($app_root) ?>?page=profile&amp;action=edit">
<i class="fas fa-edit"></i> Edit profile
</a>
<?php
// Allow plugins to append additional hero buttons for the currently viewed account.
do_hook('profile.hero_actions', [
'app_root' => $app_root,
'user' => $user,
'profile_user_id' => $profileUserIdForHooks,
'session_user_id' => class_exists('Session') && Session::isValidSession() ? (int)Session::getUserId() : 0,
]);
?>
2025-11-27 10:44:15 +00:00
</div>
</div>
</div>
2024-09-07 20:05:22 +00:00
2025-11-27 10:44:15 +00:00
<div class="tm-profile-panels">
<article class="tm-profile-panel">
<header>
<h3>Account details</h3>
</header>
<dl class="tm-profile-detail-list">
<div class="tm-profile-detail-item">
<dt>Full name</dt>
<dd><?= $name ? htmlspecialchars($name) : '<span class="tm-profile-placeholder">Not provided</span>' ?></dd>
2024-09-07 20:05:22 +00:00
</div>
2025-11-27 10:44:15 +00:00
<div class="tm-profile-detail-item">
<dt>Email</dt>
<dd><?= $email ? htmlspecialchars($email) : '<span class="tm-profile-placeholder">Not provided</span>' ?></dd>
2024-09-13 10:04:15 +00:00
</div>
2025-11-27 10:44:15 +00:00
<div class="tm-profile-detail-item">
<dt>Username</dt>
<dd><?= $username ? htmlspecialchars($username) : '<span class="tm-profile-placeholder">Not provided</span>' ?></dd>
2024-09-07 20:05:22 +00:00
</div>
2025-11-27 10:44:15 +00:00
<div class="tm-profile-detail-item">
<dt>Timezone</dt>
<dd><?= $timezoneDisplay ? htmlspecialchars($timezoneDisplay) : '<span class="tm-profile-placeholder">Not set</span>' ?></dd>
2024-09-07 20:05:22 +00:00
</div>
2025-11-27 10:44:15 +00:00
</dl>
</article>
2024-09-07 20:05:22 +00:00
2025-11-27 10:44:15 +00:00
<article class="tm-profile-panel">
<header>
<h3>Bio</h3>
</header>
<?php if ($bio !== ''): ?>
<p class="tm-profile-bio"><?= nl2br(htmlspecialchars($bio)) ?></p>
<?php else: ?>
<p class="tm-profile-placeholder">This user hasnt added a bio yet.</p>
<?php endif; ?>
</article>
2024-09-07 22:36:57 +00:00
2025-11-27 10:44:15 +00:00
<article class="tm-profile-panel">
<header>
<h3>User rights</h3>
</header>
<?php if ($rightsCount): ?>
<ul class="tm-profile-rights">
<?php foreach ($rightsNames as $rightLabel): ?>
<li>
<i class="fas fa-check"></i>
<?= htmlspecialchars($rightLabel) ?>
</li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<p class="tm-profile-placeholder">No rights assigned yet.</p>
<?php endif; ?>
</article>
2024-09-07 20:05:22 +00:00
<?php
// Surface extra panels contributed by plugins.
do_hook('profile.additional_panels', [
2025-11-27 10:44:15 +00:00
'subscription' => $subscription ?? null,
'app_root' => $app_root,
'userId' => $profileUserIdForHooks,
'profile_user_id' => $profileUserIdForHooks,
2025-11-27 10:44:15 +00:00
]); ?>
2024-09-07 20:05:22 +00:00
</div>
2025-11-27 10:44:15 +00:00
</section>