web - refactor core modules, harden authorization, simplify endpoints
This commit is contained in:
@@ -1,38 +1,62 @@
|
||||
<?php
|
||||
/*
|
||||
Name: content/profile.php
|
||||
Beschreibung: Popup innerhalb von Kalendertag bzw. Besuchsstellen: Profilanzeige
|
||||
Zur Verwendung ist die nachfolgende Unterscheidung zu treffen/erweitern
|
||||
*/
|
||||
/* Profil-Overlay für Kalender und Besuchsstellen. */
|
||||
require_once dirname(__DIR__) . '/util/seelsorge_helpers.php';
|
||||
|
||||
// Unterscheidung zwischen den aufrufenden Seitenbereichen
|
||||
// --> Name ist außerdem beim Aufruf der JS-Funktion openCloseProfile(id, name, overlay) zu bilden!
|
||||
// --> Bei einem neuen Seitenbereich ist zusätzlich der Listener (Escape-Taste) zu erweitern!
|
||||
// --> In overlay_profile.php wird bei Escape-Taste bzw. Klick auf Exit mit id=0 sowie den entsprechenden name und overlay weggeblendet!
|
||||
if (($isPageVisit ?? false) === true) {
|
||||
$profile_container_name = "profile_visit";
|
||||
$profile_overlay_id = "profile_visit_overlay";
|
||||
$isPageVisit = false;
|
||||
} elseif (($isPageCalendar ?? false) === true) {
|
||||
$profile_container_name = "profile_calendar";
|
||||
$profile_overlay_id = "profile_calendar_overlay";
|
||||
$isPageCalendar = false;
|
||||
}
|
||||
$profile_container_name = 'profile_seelsorge';
|
||||
$profile_overlay_id = 'profile_seelsorge_overlay';
|
||||
|
||||
|
||||
// Statement für alle Profile vorbereiten
|
||||
$stmt_all_profiles = $pdo->prepare("SELECT * FROM user_general_information");
|
||||
$stmt_all_profiles->execute();
|
||||
$profileRecords = seelsorge_profile_records($pdo);
|
||||
?>
|
||||
<div class="standard_overlay" id="<?= $profile_overlay_id ?>"> <!-- Overlay: Profile -->
|
||||
<div class="bg_blur"></div>
|
||||
|
||||
<?php
|
||||
while ($profile_all = $stmt_all_profiles->fetch()) {
|
||||
?>
|
||||
<div class="profile_container" name="<?= $profile_container_name ?>" id="<?= $profile_all['user_id'] ?>">
|
||||
<?php $_SESSION["profile_id"] = $profile_all['user_id'];
|
||||
include $g_phpSnippetsPath. "overlay_profile.php"; ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<div class="standard_overlay" id="<?= $profile_overlay_id ?>">
|
||||
<div class="bg_blur"></div>
|
||||
<?php foreach ($profileRecords as $record):
|
||||
$partner = $record['user'];
|
||||
$userId = (int) $partner['user_id'];
|
||||
$fullName = trim(($partner['first_name'] ?? '') . ' ' . ($partner['last_name'] ?? ''));
|
||||
$isRegistered = !empty($partner['first_name']);
|
||||
$groups = $record['permissions'];
|
||||
?>
|
||||
<div class="profile_container" name="<?= $profile_container_name ?>" id="<?= $userId ?>">
|
||||
<div class="profile-modal-card">
|
||||
<button type="button" class="exit" aria-label="Schließen" onclick="openCloseProfile(0, '<?= $profile_container_name ?>', '<?= $profile_overlay_id ?>');">×</button>
|
||||
|
||||
<div class="profile-modal-hero">
|
||||
<img class="profile-modal-img" src="<?= htmlspecialchars($record['image']) ?>" alt="Profilbild">
|
||||
<div>
|
||||
<?php if ($isRegistered): ?>
|
||||
<div class="profile-modal-title"><?= htmlspecialchars($fullName) ?></div>
|
||||
<?php else: ?>
|
||||
<div class="profile-modal-title" style="color:rgba(255,255,255,0.7);">Nicht registriert</div>
|
||||
<?php endif; ?>
|
||||
<div class="profile-modal-subtitle">
|
||||
<span><?= htmlspecialchars($partner['mail'] ?? '') ?></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="profile-modal-body">
|
||||
<?php if (!empty($partner['phone'])): ?>
|
||||
<div class="profile-modal-field">
|
||||
<div class="profile-modal-field-label">Telefon</div>
|
||||
<div class="profile-modal-field-value">
|
||||
<a href="tel:0<?= htmlspecialchars($partner['phone']) ?>">0<?= htmlspecialchars($partner['phone']) ?></a>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $activeGroups = array_filter($groups, static fn($value, $key) => $key !== 'user_id' && (int) $value === 1, ARRAY_FILTER_USE_BOTH); ?>
|
||||
<?php if ($activeGroups): ?>
|
||||
<div class="profile-modal-field">
|
||||
<div class="profile-modal-field-label">Gruppen</div>
|
||||
<div class="profile-modal-chips">
|
||||
<?php foreach (array_keys($activeGroups) as $groupName): ?>
|
||||
<span class="profile-modal-chip"><?= htmlspecialchars($groupName) ?></span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user