Adds hook to profile page for plugins to display data in.

main
Yasen Pramatarov 2026-03-21 15:59:34 +02:00
parent 32edadc0f9
commit 2aaf051677
3 changed files with 18 additions and 5 deletions

View File

@ -78,7 +78,7 @@ function sendTemplateEmail($to, $subject, $templateName, $variables, $config, $a
try { try {
$message = renderEmailTemplate($templateName, $variables, $options); $message = renderEmailTemplate($templateName, $variables, $options);
$fromDomain = $config['domain'] ?? ($_SERVER['HTTP_HOST'] ?? 'totalmeet.local'); $fromDomain = $config['domain'] ?? ($_SERVER['HTTP_HOST'] ?? 'localhost');
$headers = array_merge([ $headers = array_merge([
'From: noreply@' . $fromDomain, 'From: noreply@' . $fromDomain,
'X-Mailer: PHP/' . phpversion(), 'X-Mailer: PHP/' . phpversion(),

View File

@ -15,6 +15,7 @@ $rightsNames = array_filter($rightsNames, function ($label) {
}); });
$rightsCount = count($rightsNames); $rightsCount = count($rightsNames);
$displayName = $name ?: $username ?: 'User profile'; $displayName = $name ?: $username ?: 'User profile';
$profileUserIdForHooks = (int)($user['user_id'] ?? ($userId ?? 0));
$timezoneDisplay = ''; $timezoneDisplay = '';
if ($timezoneName) { if ($timezoneName) {
if ($timezoneOffset !== '') { if ($timezoneOffset !== '') {
@ -35,7 +36,7 @@ if ($timezoneName) {
</div> </div>
<div class="tm-profile-hero-body"> <div class="tm-profile-hero-body">
<h1 class="tm-profile-title"><?= htmlspecialchars($displayName) ?></h1> <h1 class="tm-profile-title"><?= htmlspecialchars($displayName) ?></h1>
<p class="tm-profile-subtitle">Personal details and access summary for this TotalMeet account.</p> <p class="tm-profile-subtitle">Personal details and access summary for your <?= htmlspecialchars($config['site_name']); ?> account.</p>
<div class="tm-profile-hero-meta"> <div class="tm-profile-hero-meta">
<?php if ($username): ?> <?php if ($username): ?>
<span class="tm-hero-pill pill-neutral"> <span class="tm-hero-pill pill-neutral">
@ -59,6 +60,15 @@ if ($timezoneName) {
<a class="btn btn-primary" href="<?= htmlspecialchars($app_root) ?>?page=profile&amp;action=edit"> <a class="btn btn-primary" href="<?= htmlspecialchars($app_root) ?>?page=profile&amp;action=edit">
<i class="fas fa-edit"></i> Edit profile <i class="fas fa-edit"></i> Edit profile
</a> </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,
]);
?>
</div> </div>
</div> </div>
</div> </div>
@ -117,10 +127,13 @@ if ($timezoneName) {
<?php endif; ?> <?php endif; ?>
</article> </article>
<?php do_hook('profile.additional_panels', [ <?php
// Surface extra panels contributed by plugins.
do_hook('profile.additional_panels', [
'subscription' => $subscription ?? null, 'subscription' => $subscription ?? null,
'app_root' => $app_root, 'app_root' => $app_root,
'userId' => $user['id'] ?? null, 'userId' => $profileUserIdForHooks,
'profile_user_id' => $profileUserIdForHooks,
]); ?> ]); ?>
</div> </div>
</section> </section>

View File

@ -30,7 +30,7 @@ Check if registration is enabled.
## Configuration ## Configuration
Enable/disable registration in `totalmeet.conf.php`: Enable/disable registration in `<sitename>.conf.php`:
```php ```php
'registration_enabled' => true, 'registration_enabled' => true,
``` ```