Files
maria_uslugi/visio/nom_afficher.php
T
2026-03-05 10:25:39 +01:00

40 lines
1.4 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* /nom_afficher.php
* Affiche le nom et prenom de la personne connecté lors de visio en Jitsi
*/
$displayName = 'Invité';
try {
if ($refId > 0 && in_array($role, ['praticien','client'], true)) {
// Adapte les noms de tables/colonnes si besoin
if ($role === 'praticien') {
$sql = "SELECT nom, prenom FROM praticien WHERE id = :id LIMIT 1";
} else { // client
$sql = "SELECT nom, prenom FROM client WHERE id = :id LIMIT 1";
}
$stmt = $pdo->prepare($sql);
$stmt->execute(['id' => $refId]);
if ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$pn = trim(($row['prenom'] ?? '') . ' ' . ($row['nom'] ?? ''));
if ($pn !== '') {
$displayName = $pn;
} else {
$displayName = ($role === 'praticien') ? 'Praticien' : 'Client';
}
} else {
$displayName = ($role === 'praticien') ? 'Praticien' : 'Client';
}
}
} catch (Throwable $e) {
// En cas d’erreur, on garde un fallback propre
$displayName = ($role === 'praticien') ? 'Praticien' : 'Client';
}
// Optionnel: mémoriser pour d'autres pages
$_SESSION['display_name'] = $displayName;
// Sécuriser pour l'injecter côté JS
$displayName = htmlspecialchars($displayName, ENT_QUOTES, 'UTF-8');
$jitsiDomain = $config['jitsi_domain'];