feat(groups): user_groups lookup, admin assignment UI, public directory with DataTables

This commit is contained in:
2025-12-10 10:01:07 +01:00
parent 9094b58b6d
commit 2b6d4c49f5
8 changed files with 201 additions and 2 deletions

View File

@@ -24,6 +24,9 @@
<li <?php if (View::checkForActiveController($filename, "profile")) { echo ' class="active" '; } ?> >
<a href="<?php echo Config::get('URL'); ?>profile/index">Profiles</a>
</li>
<li <?php if (View::checkForActiveController($filename, "directory")) { echo ' class="active" '; } ?> >
<a href="<?php echo Config::get('URL'); ?>directory/index">Benutzer</a>
</li>
<?php if (Session::userIsLoggedIn()) { ?>
<li <?php if (View::checkForActiveController($filename, "dashboard")) { echo ' class="active" '; } ?> >
<a href="<?php echo Config::get('URL'); ?>dashboard/index">Dashboard</a>

View File

@@ -22,6 +22,7 @@
<td>User's email</td>
<td>Activated ?</td>
<td>Link to user's profile</td>
<td>Group</td>
<td>suspension Time in days</td>
<td>Soft delete</td>
<td>Submit</td>
@@ -41,6 +42,19 @@
<td>
<a href="<?= Config::get('URL') . 'profile/showProfile/' . $user->user_id; ?>">Profile</a>
</td>
<td>
<form action="<?= Config::get('URL'); ?>admin/changeUserGroup" method="post">
<input type="hidden" name="user_id" value="<?= $user->user_id; ?>" />
<select name="group_id">
<?php foreach ($this->groups as $group) { ?>
<option value="<?= $group->group_id; ?>" <?= (isset($user->user_account_type) && (int)$user->user_account_type === (int)$group->group_id ? 'selected' : '') ?>>
<?= (int)$group->group_id; ?> - <?= htmlspecialchars($group->group_name, ENT_QUOTES, 'UTF-8'); ?>
</option>
<?php } ?>
</select>
<input type="submit" value="Save" />
</form>
</td>
<form action="<?= config::get("URL"); ?>admin/actionAccountSettings" method="post">
<td><input type="number" name="suspension" /></td>
<td><input type="checkbox" name="softDelete" <?php if ($user->user_deleted) { ?> checked <?php } ?> /></td>

View File

@@ -0,0 +1,54 @@
<div class="container">
<h1>Benutzerverzeichnis</h1>
<div class="box">
<?php $this->renderFeedbackMessages(); ?>
<table id="users-table" class="overview-table" style="width:100%">
<thead>
<tr>
<td>Id</td>
<td>Avatar</td>
<td>Benutzername</td>
<td>Email</td>
<td>Aktiv?</td>
<td>Gruppe</td>
<td>Profil</td>
</tr>
</thead>
<tbody>
<?php foreach ($this->users as $user) { ?>
<tr class="<?= ($user->user_active == 0 ? 'inactive' : 'active'); ?>">
<td><?= $user->user_id; ?></td>
<td class="avatar">
<?php if (isset($user->user_avatar_link)) { ?>
<img src="<?= $user->user_avatar_link; ?>"/>
<?php } ?>
</td>
<td><?= $user->user_name; ?></td>
<td><?= $user->user_email; ?></td>
<td><?= ($user->user_active == 0 ? 'Nein' : 'Ja'); ?></td>
<td><?= htmlspecialchars($user->group_name ?: $user->user_account_type, ENT_QUOTES, 'UTF-8'); ?></td>
<td><a href="<?= Config::get('URL') . 'profile/showProfile/' . $user->user_id; ?>">Profil</a></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</div>
<!-- jQuery & DataTables CDN -->
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.8/css/jquery.dataTables.min.css">
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script src="https://cdn.datatables.net/1.13.8/js/jquery.dataTables.min.js"></script>
<script>
$(document).ready(function(){
$('#users-table').DataTable({
pageLength: 10,
order: [[ 0, 'asc' ]],
language: {
url: 'https://cdn.datatables.net/plug-ins/1.13.8/i18n/de-DE.json'
}
});
});
</script>