Files
wavelog/application/views/user/index.php
Fabian Berg c70c2ec5cd Clubstations for Wavelog (#1334)
* feat[clubstations]: New DB structure

* feat[clubstations]: Add clubstationstable in user managment

* feat[clubstations]: Show last operator

* feat[clubstations]: Better solution for last operator. tnx for the hint @int2001

* feat[clubstations]: New Club Model and Controller

* feat[clubstations]: Add "Add User" and "Edit User" functionality

* docs[clubstations]: move comment

* feat[clubstations]: Add "Delete Member" functionality

* feat[clubstations]: some enhancements and javascript

* fix[clubstations]: Wrong message class for flashmessages

* feat[clubstations]: Added Switch in the Header menu (not functional yet)

* feat[clubstations]: clubswitch modal

* fix[clubstations]: Load encryption library if not already loaded

* fix[clubstations]: Prevent direct login attempts to clubstations and enhance impersonation authorization

* fix[clubstations]: Typo

* feat[clubstations]: Only show the operator dialog if there is something fishy

* fix[user]: little UI bug

* feat[impersonate]: Add source uid to session data

* fix[impersonate]: logic adjustment

* feat[clubstations]: Add manage button in header menu for club officers

* fix[clubstations]: typo in permission level check

* fix[clubstations]: Full rights for the admin

* feat[impersonate]: Custom sessiondata

* feat[impersonate]: Implement stop impersonation feature with modal confirmation; "the way back"

* fix(modal): Fix bug where modal was hidden when mouse leaved the browser content

* docs(config): Adjust config description for special callsigns and clubstations

* feat(club): Add club access check helper

* typo

* fix[impersonation]: Better text

* feat(club): Selectize for a efficient user search

* feat(clubstations): Restrict clubstations based on users permission level part 1/x

* adjustments for dev merge

* Adjusted club right for the advanced logbook

* feat[user]: Refactoring of the Action Buttons in the user table

* fix[club_permissions]: normal button instead small one for club permissions

* remove unnecessary line break in modal body

* feat[clubstations]: Add Club Mode badge to the header

* fix[clubstations]: fix maintenance mode

* allow switch back on http

* feat(simplefle): display operator input based on club_access

* small UI adjustments

* small UI adjustments

* moved api page to a index.php file and added support for clubstations

* removed unused stuff

* typo

* radios and api keys

* missed one binding

* fix qso view, even officers do just see their own radios in QSO logging

* omit the need for a relogin to see the changes as an admin

* Omit the need for relogin after club changes in general. It's a question of UX. It's better to accept a little higher DB load (if clubstations are enabled) then the need of an user to relogin. There is some room for improvement by changing user_model->get_by_id() and adding a join there. This can be done later if we see that the load is too high

* If the user is not the creator of the API key, it's likely a clubstation. In this case the callsign of the clubstation can not be the same as the callsign of the user (operator call provided by the user). If this is the case, we need to use the callsign of the creator of the API key

* remove debug messages

* better UI in header

* found a typo

* full access in clubstations for admins (if accessed via admin usertable)

* adjusted text

* adjusted text

* adjust text

* reduce required chars

* bugfix: missing the correct authentication in case the admin was not member of the club. he wasn't able to switch back

* reduce debug messages

* fixed UI bug related to tooltips

* load js in controller

* upps..

* some UI adjustments

* corrected permissions

* if user gets delete we need to remove data in club_permissions and also api keys which were created by this user

* Notify members about new memberships or changes in permission level

* add spinner to save button

* make login/logout process more bulletproof

* remove the relogin cookie after the attempt

* better strategy

* bug where switch back failed if user is no admin

* make api keys more secure

* mask not owned api keys

* removed annoying link

* if a user gets removed from a club we also should delete the corresponding api keys and cat radios

* adjusted wiki link

* Auto creation of logbook and location when new user is created

* store and display locator in uppercase

* same for callsign

* fixed a bug in user/club creation

* Revert "Auto creation of logbook and location when new user is created"
We found another solution to which will be addressed in a second PR
This reverts commit f05f4b7bf0.

* Optimized SQL for stats at userlist

* Source query for lastop "out", because mysql<9.0 can't handle Windowed functions

* adjust migration

* add new columns to users table to get created_at and modified_at

* added a partial down function

* add operator dropdown for clubstations

* fix mig version

* Add some backend restrictions in case a user wants to try something funny with the club

---------

Co-authored-by: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com>
Co-authored-by: int2001 <joerg@dj7nt.de>
2025-01-02 10:22:23 +01:00

241 lines
12 KiB
PHP

<div class="container">
<br>
<h2><?php echo $page_title; ?></h2>
<?php $this->load->view('layout/messages'); ?>
<div class="card">
<div class="card-header">
<?= __("User List"); ?>
</div>
<div class="card-body">
<p class="card-text"><?= __("Wavelog needs at least one user configured in order to operate."); ?></p>
<p class="card-text"><?= __("Users can be assigned roles which give them different permissions, such as adding QSOs to the logbook and accessing Wavelog APIs."); ?></p>
<p class="card-text"><?= __("The currently logged-in user is displayed at the upper-right of each page."); ?></p>
<p class="card-text"><?= __("With the password reset button, you can send a user an email containing a link to reset their password. To achieve this, ensure that the email settings in the global options are configured correctly."); ?></p>
<p>
<a class="btn btn-primary" href="<?php echo site_url('user/add'); ?>"><i class="fas fa-user-plus"></i> <?= __("Create user"); ?></a>
<a class="btn btn-secondary" style="float: right;" href="<?php echo site_url('user'); ?>"><i class="fas fa-sync"></i> <?= __("Refresh List"); ?></a>
</p>
<div class="table-responsive">
<table class="table table-striped" id="adminusertable">
<thead>
<tr>
<th style="text-align: center; vertical-align: middle;" scope="col"><?= __("User"); ?></th>
<th style="text-align: center; vertical-align: middle;" scope="col"><?= __("Callsign"); ?></th>
<th style="text-align: center; vertical-align: middle;" scope="col"><?= __("E-mail"); ?></th>
<th style="text-align: center; vertical-align: middle;" scope="col"><?= __("Type"); ?></th>
<th style="text-align: center; vertical-align: middle;" scope="col"><?= __("Last seen"); ?></th>
<th></th>
<th style="text-align: center; vertical-align: middle;" scope="col"><?= __("Actions"); ?></th>
</tr>
</thead>
<tbody>
<?php $i = 0;
foreach ($results->result() as $row) { ?>
<tr class="tr<?php echo ($i & 1); ?>">
<td style="text-align: left; vertical-align: middle;">
<a href="<?php echo site_url('user/edit') . '/' . $row->user_id; ?>">
<?php echo $row->user_name; ?>
</a>
</td>
<td style="text-align: left; vertical-align: middle;">
<?php echo $row->user_callsign; ?>
</td>
<td style="text-align: left; vertical-align: middle;">
<a href="mailto:<?php echo $row->user_email; ?>">
<?php echo $row->user_email; ?>
</a>
</td>
<td style="text-align: left; vertical-align: middle;">
<?php
$l = $this->config->item('auth_level');
echo $l[$row->user_type];
?>
</td>
<td style="text-align: left; vertical-align: middle;">
<?php if ($row->last_seen != null) {
$lastSeenTimestamp = strtotime($row->last_seen);
$currentTimestamp = time();
if (($currentTimestamp - $lastSeenTimestamp) < 120) { ?>
<a><i style="color: green;" class="fas fa-circle"></i> <?php echo date($custom_date_format . ' H:i:s', $lastSeenTimestamp); ?></a>
<?php } else { ?>
<a><i style="color: red;" class="fas fa-circle"></i> <?php echo date($custom_date_format . ' H:i:s', $lastSeenTimestamp); ?></a>
<?php }
} else {
echo __("Never");
} ?>
</td>
<td style="text-align: left; vertical-align: middle;">
<span class="badge text-bg-success"><?= __("Locations"); ?>: <?php echo $row->stationcount; ?></span>
<br>
<span class="badge text-bg-info"><?= __("Logbooks"); ?>: <?php echo $row->logbookcount; ?></span>
<?php if ($row->qsocount > 0) { ?>
<span class="badge text-bg-light" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-custom-class="custom-tooltip" data-bs-html="true" data-bs-title="<?= __("Last QSO:"); ?><br><?php echo $row->lastqso; ?>">
<?php echo $row->qsocount; ?> <?= __("QSO"); ?>
</span>
<?php } else { ?>
<span class="badge text-bg-light" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-custom-class="custom-tooltip" data-bs-html="true" data-bs-title="<?= __("No QSOs in Log"); ?>">
<?php echo $row->qsocount; ?> <?= __("QSO"); ?>
</span>
<?php } ?>
</td>
<!-- ### Actions ### -->
<td style="text-align: center; vertical-align: middle;">
<!-- Edit Button -->
<a href="<?php echo site_url('user/edit') . '/' . $row->user_id; ?>" class="btn btn-outline-primary btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="<?= __("Edit"); ?>">
<i class="fas fa-user-edit"></i>
</a>
<!-- Impersonate Button -->
<?php if (!$disable_impersonate && $session_uid != $row->user_id) { ?>
<button class="btn btn-info btn-sm btn-tooltip" onclick="actions_modal('<?php echo $row->user_id; ?>', 'admin_impersonate')" title="<?= __("Impersonate"); ?>">
<i class="fas fa-people-arrows"></i>
</button>
<?php } ?>
<!-- Other Actions Button -->
<?php if ($session_uid != $row->user_id) { ?>
<button class="btn btn-secondary btn-sm btn-tooltip" onclick="actions_modal('<?php echo $row->user_id; ?>', 'more_actions')" title="<?= __("Other Actions"); ?>">
<i class="fas fa-bars"></i>
</button>
<?php } ?>
<!-- Delete Button -->
<?php if ($session_uid != $row->user_id) { ?>
<div class="vr mx-2"></div>
<a href="<?php echo site_url('user/delete') . '/' . $row->user_id; ?>" class="btn btn-danger btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="<?= __("Delete"); ?>">
<i class="fas fa-user-minus"></i>
</a>
<?php } ?>
<!-- End Actions -->
</td>
</tr>
<?php $i++; } ?>
</tbody>
</table>
</div>
</div>
</div>
<?php if ($clubmode) { ?>
<div class="card mt-3">
<div class="card-header">
<?= __("Clubstation List"); ?>
</div>
<div class="card-body">
<p class="card-text"><?= __("Clubstations in Wavelog are a unique way for clubs and special callsign events to handle multiple operators. A clubstation is basically a normal user account with some special features and some restrictions."); ?></p>
<p>
<a class="btn btn-primary" href="<?php echo site_url('user/add?club=1'); ?>"><i class="fas fa-user-plus"></i> <?= __("Create Clubstation"); ?></a>
<a class="btn btn-secondary" style="float: right;" href="<?php echo site_url('user'); ?>"><i class="fas fa-sync"></i> <?= __("Refresh List"); ?></a>
</p>
<?php if (!empty($clubs->result())) { ?>
<div class="table-responsive">
<table class="table table-striped" id="adminclubusertable">
<thead>
<tr>
<th style="text-align: center; vertical-align: middle;" scope="col"><?= __("Username"); ?></th>
<th style="text-align: center; vertical-align: middle;" scope="col"><?= __("Callsign"); ?></th>
<th style="text-align: center; vertical-align: middle;" scope="col"><?= __("E-mail"); ?></th>
<th style="text-align: center; vertical-align: middle;" scope="col"><?= __("Last Operator"); ?></th>
<th style="text-align: center; vertical-align: middle;" scope="col"><?= __("Last seen"); ?></th>
<th></th>
<th style="text-align: center; vertical-align: middle;" scope="col"><?= __("Actions"); ?></th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($clubs->result() as $row) { ?>
<?php echo '<tr class="tr' . ($i & 1) . '">'; ?>
<td style="text-align: left; vertical-align: middle;"><a href="<?php echo site_url('user/edit') . "/" . $row->user_id; ?>"><?php echo $row->user_name; ?></a></td>
<td style="text-align: left; vertical-align: middle;"><?php echo $row->user_callsign; ?></td>
<td style="text-align: left; vertical-align: middle;"><a href="mailto:<?php echo $row->user_email; ?>"><?php echo $row->user_email; ?></a></td>
<td style="text-align: left; vertical-align: middle;"><?php echo $row->lastoperator; ?></td>
<td style="text-align: left; vertical-align: middle;"><?php
if ($row->last_seen != null) { // if the user never logged in before the value is null. We can show "never" then.
$lastSeenTimestamp = strtotime($row->last_seen);
$currentTimestamp = time();
if (($currentTimestamp - $lastSeenTimestamp) < 120) {
echo "<a><i style=\"color: green;\" class=\"fas fa-circle\"></i> " . date($custom_date_format . ' H:i:s', $lastSeenTimestamp) . "</a>";
} else {
echo "<a><i style=\"color: red;\" class=\"fas fa-circle\"></i> " . date($custom_date_format . ' H:i:s', $lastSeenTimestamp) . "</a>";
}
} else {
echo __("Never");
}?>
</td>
<td style="text-align: left; vertical-align: middle;">
<span class="badge text-bg-success"><?= __("Locations"); ?>: <?php echo $row->stationcount; ?></span>
<br>
<span class="badge text-bg-info"><?= __("Logbooks"); ?>: <?php echo $row->logbookcount; ?></span>
<?php if ($row->qsocount > 0) { ?>
<span class="badge text-bg-light" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-custom-class="custom-tooltip" data-bs-html="true" data-bs-title="<?= __("Last QSO:"); ?><br><?php echo $row->lastqso; ?>"><?php echo $row->qsocount; ?> <?= __("QSO"); ?></span>
<?php } else { ?>
<span class="badge text-bg-light" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-custom-class="custom-tooltip" data-bs-html="true" data-bs-title="<?= __("No QSOs in Log"); ?>"><?php echo $row->qsocount; ?> <?= __("QSO"); ?></span>
<?php } ?>
</td>
<!-- ### Actions ### -->
<td style="text-align: center; vertical-align: middle;">
<!-- Edit Button -->
<a href="<?php echo site_url('user/edit') . '/' . $row->user_id; ?>" class="btn btn-outline-primary btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="<?= __("Edit"); ?>">
<i class="fas fa-user-edit"></i>
</a>
<!-- Impersonate Button -->
<?php if (!$disable_impersonate && $session_uid != $row->user_id) { ?>
<button class="btn btn-info btn-sm btn-tooltip" onclick="actions_modal('<?php echo $row->user_id; ?>', 'admin_impersonate')" title="<?= __("Impersonate"); ?>">
<i class="fas fa-people-arrows"></i>
</button>
<?php } ?>
<!-- Club Permissions Button -->
<a href="<?php echo site_url('club/permissions') . "/" . $row->user_id; ?>" class="btn btn-warning btn-sm btn-tooltip" title="<?= __("Club Permissions"); ?>"><i style="color: black;" class="fas fa-user-lock"></i></a>
<!-- Other Actions Button -->
<?php if ($session_uid != $row->user_id) { ?>
<button class="btn btn-secondary btn-sm btn-tooltip" onclick="actions_modal('<?php echo $row->user_id; ?>', 'more_actions')" title="<?= __("Other Actions"); ?>">
<i class="fas fa-bars"></i>
</button>
<?php } ?>
<!-- Delete Button -->
<?php if ($session_uid != $row->user_id) { ?>
<div class="vr mx-2"></div>
<a href="<?php echo site_url('user/delete') . '/' . $row->user_id; ?>" class="btn btn-danger btn-sm" data-bs-toggle="tooltip" data-bs-placement="top" title="<?= __("Delete"); ?>">
<i class="fas fa-user-minus"></i>
</a>
<?php } ?>
<!-- End Actions -->
</td>
</tr>
<?php $i++;
} ?>
</tbody>
</table>
</div>
<?php } else { ?>
<div class="text-center">
<h5><?= __("No Clubstations configures yet."); ?></h5>
</div>
<?php } ?>
</div>
</div>
<?php } ?>
</div>
</div>
<div id="actionsModal-container"></div>
</div>