313 lines
12 KiB
PHTML
313 lines
12 KiB
PHTML
<?php
|
|
|
|
/**
|
|
* @var array<int, string> $errors
|
|
* @var array $form
|
|
* @var array $user
|
|
*/
|
|
|
|
use MintyPHP\Router;
|
|
use MintyPHP\Session;
|
|
use MintyPHP\Service\UserAvatarService;
|
|
|
|
$values = $form ?? $user ?? [];
|
|
$avatarUuid = (string) ($values['uuid'] ?? '');
|
|
$hasAvatar = $avatarUuid !== '' && UserAvatarService::hasAvatar($avatarUuid);
|
|
$currentUserId = (int) ($_SESSION['user']['id'] ?? 0);
|
|
$isOwnAccount = $currentUserId > 0 && $currentUserId === (int) ($values['id'] ?? 0);
|
|
$titleText = $isOwnAccount ? t('My account') : t('Edit user');
|
|
$canViewUsers = can('users.view');
|
|
$hideNavigation = $isOwnAccount && !$canViewUsers;
|
|
|
|
?>
|
|
|
|
<div class="app-details-container">
|
|
<section>
|
|
<?php if (!$hideNavigation): ?>
|
|
<div class="app-breadcrumb">
|
|
<a href="/admin">Startseite</a><i class="bi bi-chevron-right"></i><a
|
|
href="/admin/users"><?php e(t('Users')); ?></a><i class="bi bi-chevron-right"></i><?php e($titleText); ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
<div class="app-details-titlebar">
|
|
<h1>
|
|
<?php if (!$hideNavigation): ?>
|
|
<a href="admin/users" title="<?php e(t('Cancel')); ?>"><i class="bi bi-arrow-left"></i></a>
|
|
<?php endif; ?>
|
|
<?php e($titleText); ?>
|
|
</h1>
|
|
<div class="app-details-titlebar-actions">
|
|
<?php if (can('users.delete')): ?>
|
|
<details class="dropdown">
|
|
<summary role="button" class="outline secondary"><i class="bi bi-three-dots"></i></summary>
|
|
<ul dir="rtl">
|
|
<li>
|
|
<?php if (!empty($canEditUser)): ?>
|
|
<form method="post" action="admin/users/send-access/<?php e($values['uuid'] ?? ''); ?>"
|
|
onsubmit="return confirm('<?php e(t('Send access email to this user?')); ?>');">
|
|
<?php Session::getCsrfInput(); ?>
|
|
<button type="submit" class="transparent">
|
|
<?php e(t('Send access')); ?>
|
|
</button>
|
|
</form>
|
|
<?php endif; ?>
|
|
</li>
|
|
<li>
|
|
<?php if (!empty($canEditUser)): ?>
|
|
<form method="post" action="admin/users/forget-tokens/<?php e($values['uuid'] ?? ''); ?>"
|
|
onsubmit="return confirm('<?php e(t('Clear all login tokens for this user?')); ?>');">
|
|
<?php Session::getCsrfInput(); ?>
|
|
<button type="submit" class="transparent">
|
|
<?php e(t('Clear login tokens')); ?>
|
|
</button>
|
|
</form>
|
|
<?php endif; ?>
|
|
</li>
|
|
<li>
|
|
<form method="post" action="admin/users/delete/<?php e($values['uuid'] ?? ''); ?>"
|
|
onsubmit="return confirm('<?php e(t('Delete this user?')); ?>');">
|
|
<?php Session::getCsrfInput(); ?>
|
|
<button type="submit" class="transparent">
|
|
<?php e(t('Delete')); ?>
|
|
</button>
|
|
</form>
|
|
</li>
|
|
</ul>
|
|
</details>
|
|
<?php endif; ?>
|
|
|
|
<?php if (!empty($canEditUser)): ?>
|
|
<button type="submit" form="user-form" name="action" value="save" class="secondary outline">
|
|
<?php e(t('Save')); ?>
|
|
</button>
|
|
<?php if (!$hideNavigation): ?>
|
|
<button type="submit" form="user-form" name="action" value="save_close" class="primary">
|
|
<?php e(t('Save & close')); ?>
|
|
</button>
|
|
<?php endif; ?>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<?php if (!empty($errors)): ?>
|
|
<div class="app-details-errors">
|
|
<div class="notice" data-variant="error">
|
|
<ul>
|
|
<?php foreach ($errors as $error): ?>
|
|
<li><?php e($error); ?></li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php
|
|
$passwordRequired = false;
|
|
$passwordLabel = t('New password (optional)');
|
|
$passwordLegend = t('Password');
|
|
$passwordConfirmLabel = t('Password (again)');
|
|
$showTenants = !empty($canEditAssignments);
|
|
$tenants = $tenants ?? [];
|
|
$selectedTenantIds = $selectedTenantIds ?? [];
|
|
$showRoles = !empty($canEditAssignments);
|
|
$roles = $roles ?? [];
|
|
$selectedRoleIds = $selectedRoleIds ?? [];
|
|
$showDepartments = !empty($canEditAssignments);
|
|
$departments = $departments ?? [];
|
|
$selectedDepartmentIds = $selectedDepartmentIds ?? [];
|
|
$isReadOnly = !(!empty($canEditUser));
|
|
$canEditAssignments = $canEditAssignments ?? false;
|
|
$permissionRows = $permissionRows ?? [];
|
|
$showPermissions = !empty($permissionRows) && can('permissions.view');
|
|
require __DIR__ . '/_form.phtml';
|
|
?>
|
|
</section>
|
|
<aside id="app-details-aside-section">
|
|
<div class="app-details-aside-section">
|
|
<div class="user-avatar-block avatar-round">
|
|
<?php if ($hasAvatar): ?>
|
|
<a data-fslightbox="user-avatar" href="admin/users/avatar-file?uuid=<?php e($avatarUuid); ?>&size=256">
|
|
<img class="user-avatar-image" src="admin/users/avatar-file?uuid=<?php e($avatarUuid); ?>&size=128"
|
|
alt="<?php e(t('Profile image')); ?>">
|
|
</a>
|
|
<?php else: ?>
|
|
<?php
|
|
$initials = strtoupper(substr((string) ($values['first_name'] ?? ''), 0, 1) . substr((string) ($values['last_name'] ?? ''), 0, 1));
|
|
?>
|
|
<div class="user-avatar-placeholder"><?php e($initials ?: '?'); ?></div>
|
|
<?php endif; ?>
|
|
</div>
|
|
<hgroup>
|
|
<h2><?php e($values['first_name'] ?? ''); ?> <?php e($values['last_name'] ?? ''); ?></h2>
|
|
<p><?php e($values['email'] ?? ''); ?></p>
|
|
</hgroup>
|
|
<hr>
|
|
<?php if (!empty($canEditUser)): ?>
|
|
<details name="user-avatar">
|
|
<summary>
|
|
<?php e(t('Upload image')); ?>
|
|
</summary>
|
|
<hr>
|
|
<form class="user-avatar-form" method="post" action="admin/users/avatar/<?php e($avatarUuid); ?>"
|
|
enctype="multipart/form-data">
|
|
<label class="user-avatar-upload">
|
|
<input type="file" name="avatar" accept="image/*">
|
|
</label>
|
|
<div class="grid">
|
|
<button type="submit" class="primary">
|
|
<?php e(t('Save')); ?>
|
|
</button>
|
|
<?php if ($hasAvatar): ?>
|
|
<button data-tooltip-pos="top" data-tooltip="<?php e(t('Remove image')); ?>" type="submit" class="danger" formaction="admin/users/avatar-delete/<?php e($avatarUuid); ?>"
|
|
formmethod="post">
|
|
<i class="bi bi-trash3-fill"></i>
|
|
</button>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php Session::getCsrfInput(); ?>
|
|
</form>
|
|
</details>
|
|
<?php endif; ?>
|
|
<hr>
|
|
<details name="user-meta" open>
|
|
<summary><?php e(t('Status & meta')); ?></summary>
|
|
<hr>
|
|
<div class="grid">
|
|
<div>
|
|
<small><?php e(t('ID')); ?></small>
|
|
<p>
|
|
<span class="badge" data-variant="neutral" data-copy="true"
|
|
data-copy-value="<?php e($values['id'] ?? ''); ?>">
|
|
<?php e($values['id'] ?? '-'); ?>
|
|
</span>
|
|
</p>
|
|
</div>
|
|
<div>
|
|
<small><?php e(t('Status')); ?></small>
|
|
<p>
|
|
<?php if (!empty($values['active'])): ?>
|
|
<span class="badge" data-variant="success"><?php e(t('Active')); ?></span>
|
|
<?php else: ?>
|
|
<span class="badge" data-variant="danger"><?php e(t('Inactive')); ?></span>
|
|
<?php endif; ?>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<small><?php e(t('Email')); ?></small>
|
|
<p>
|
|
<?php if (!empty($values['email_verified_at'])): ?>
|
|
<span class="badge" data-variant="success"><?php e(t('Verified')); ?> <?php e(dt($values['email_verified_at'])); ?></span>
|
|
<?php else: ?>
|
|
<span class="badge" data-variant="warning"><?php e(t('Not verified')); ?></span>
|
|
<?php endif; ?>
|
|
</p>
|
|
</div>
|
|
<div>
|
|
<small>
|
|
<?php e(t('UUID')); ?>
|
|
</small>
|
|
<p>
|
|
<span class="badge" data-variant="neutral" data-copy="true"
|
|
data-copy-value="<?php e($values['uuid'] ?? ''); ?>">
|
|
<?php
|
|
$uuidValue = (string) ($values['uuid'] ?? '');
|
|
$uuidDisplay = $uuidValue !== '' ? substr($uuidValue, 0, 10) : '-';
|
|
e($uuidDisplay);
|
|
?>
|
|
</span>
|
|
</p>
|
|
</div>
|
|
</details>
|
|
<hr>
|
|
<?php
|
|
$createdByLabel = $values['created_by_label'] ?? '';
|
|
$createdById = $values['created_by'] ?? null;
|
|
$createdByUuid = $values['created_by_uuid'] ?? null;
|
|
$modifiedByLabel = $values['modified_by_label'] ?? '';
|
|
$modifiedById = $values['modified_by'] ?? null;
|
|
$modifiedByUuid = $values['modified_by_uuid'] ?? null;
|
|
$activeChangedByLabel = $values['active_changed_by_label'] ?? '';
|
|
$activeChangedById = $values['active_changed_by'] ?? null;
|
|
$activeChangedByUuid = $values['active_changed_by_uuid'] ?? null;
|
|
?>
|
|
<details name="user-audit">
|
|
<summary><?php e(t('Audit')); ?></summary>
|
|
<hr>
|
|
<div class="grid">
|
|
<div>
|
|
<small><?php e(t('Created')); ?></small>
|
|
<p><?php e(dt($values['created'] ?? '') ?: '-'); ?></p>
|
|
</div>
|
|
<div>
|
|
<small>
|
|
<?php e(t('Created by')); ?>
|
|
</small>
|
|
<p>
|
|
<?php if ($createdByLabel !== ''): ?>
|
|
<?php if ($createdByUuid): ?>
|
|
<a href="admin/users/edit/<?php e($createdByUuid); ?>"><?php e($createdByLabel); ?></a>
|
|
<?php else: ?>
|
|
<?php e($createdByLabel); ?>
|
|
<?php endif; ?>
|
|
<?php elseif ($createdById): ?>
|
|
<?php e('#' . $createdById); ?>
|
|
<?php else: ?>
|
|
-
|
|
<?php endif; ?>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div class="grid">
|
|
<div>
|
|
<small><?php e(t('Modified')); ?></small>
|
|
<p><?php e(dt($values['modified'] ?? '') ?: '-'); ?></p>
|
|
</div>
|
|
<div>
|
|
<small>
|
|
<?php e(t('Modified by')); ?>
|
|
</small>
|
|
<p>
|
|
<?php if ($modifiedByLabel !== ''): ?>
|
|
<?php if ($modifiedByUuid): ?>
|
|
<a href="admin/users/edit/<?php e($modifiedByUuid); ?>"><?php e($modifiedByLabel); ?></a>
|
|
<?php else: ?>
|
|
<?php e($modifiedByLabel); ?>
|
|
<?php endif; ?>
|
|
<?php elseif ($modifiedById): ?>
|
|
<?php e('#' . $modifiedById); ?>
|
|
<?php else: ?>
|
|
-
|
|
<?php endif; ?>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div class="grid">
|
|
<div>
|
|
<small><?php e(t('Status changed')); ?></small>
|
|
<p><?php e(dt($values['active_changed_at'] ?? '') ?: '-'); ?></p>
|
|
</div>
|
|
<div>
|
|
<small>
|
|
<?php e(t('Status changed by')); ?>
|
|
</small>
|
|
<p>
|
|
<?php if ($activeChangedByLabel !== ''): ?>
|
|
<?php if ($activeChangedByUuid): ?>
|
|
<a href="admin/users/edit/<?php e($activeChangedByUuid); ?>"><?php e($activeChangedByLabel); ?></a>
|
|
<?php else: ?>
|
|
<?php e($activeChangedByLabel); ?>
|
|
<?php endif; ?>
|
|
<?php elseif ($activeChangedById): ?>
|
|
<?php e('#' . $activeChangedById); ?>
|
|
<?php else: ?>
|
|
-
|
|
<?php endif; ?>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</details>
|
|
</div>
|
|
</aside>
|
|
</div>
|