API / service accounts take no seat on the agent user limit, the managed instance's or config.php's: getActiveAgentUserCount() leaves them out, so the seats taken, the limit checks and the report to the manager do too; one can be added, enabled, restored or bulk enabled when every seat is taken, New User stays open with the window saying so, and turning an active one back into an agent who signs in needs a free seat (serviceAccountLeavingNeedsSeat()); 26.12.5 changelog

This commit is contained in:
johnnyq
2026-12-02 17:46:03 -05:00
parent c94aeaf4a7
commit bd38983abb
10 changed files with 63 additions and 17 deletions

View File

@@ -64,7 +64,7 @@ if (serviceAccountsReady()) {
$shows[$view_key]['where'] .= ' AND user_service_account = 0';
}
$shows = array_slice($shows, 0, array_search('archived', array_keys($shows), true), true)
+ ['service' => ['label' => 'API accounts', 'icon' => 'fa-plug', 'where' => 'user_archived_at IS NULL AND user_service_account = 1', 'title' => 'Logins only for API keys to act as - left out of every agent list, and unable to sign in']]
+ ['service' => ['label' => 'API accounts', 'icon' => 'fa-plug', 'where' => 'user_archived_at IS NULL AND user_service_account = 1', 'title' => 'Logins only for API keys to act as - left out of every agent list, unable to sign in, and taking no seat']]
+ $shows;
}
$show = isset($shows[$_GET['show'] ?? '']) ? ($_GET['show'] ?? '') : '';
@@ -201,7 +201,8 @@ if (isset($shows['invited'])) {
// Those who can sign in to the portal
$view_counts['portal'] = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM users $portal_joins WHERE $portal_filters AND " . PORTAL_USER_ON_SQL))[0]);
// Agent user limit (set in config.php, 0 / unset = unlimited) - an invite waiting holds a seat
// Agent user limit (set in config.php, 0 / unset = unlimited) - an invite waiting holds a seat, an API /
// service account doesn't (functions/service_account.php)
$agent_user_limit = getAgentUserLimit();
$agent_user_count = getActiveAgentUserCount();
$agent_invites_holding = userInvitesHoldingSeats();
@@ -231,14 +232,14 @@ $csrf = $_SESSION['csrf_token'];
<h3 class="card-title mt-2"><i class="fas fa-fw fa-users me-2"></i>Users
<?php if ($agent_user_limit > 0) { ?>
<span class="badge rounded-pill text-bg-<?= $agent_user_limit_reached ? 'danger' : 'secondary' ?> fw-normal ms-2"
title="<?= $agent_user_count ?> active agent<?= $agent_user_count === 1 ? '' : 's' ?><?= $agent_invites_holding ? " and $agent_invites_holding invite" . ($agent_invites_holding === 1 ? '' : 's') . ' waiting' : '' ?>, of the agent user limit <?= $managed_limit_by !== '' ? 'set by ' . escapeHtml($managed_limit_by) : 'set for this installation' ?>">
title="<?= $agent_user_count ?> active agent<?= $agent_user_count === 1 ? '' : 's' ?><?= $agent_invites_holding ? " and $agent_invites_holding invite" . ($agent_invites_holding === 1 ? '' : 's') . ' waiting' : '' ?>, of the agent user limit <?= $managed_limit_by !== '' ? 'set by ' . escapeHtml($managed_limit_by) : 'set for this installation' ?><?= serviceAccountsReady() ? ' - API / service accounts take none' : '' ?>">
<?= $agent_user_count + $agent_invites_holding ?> of <?= $agent_user_limit ?> seats
</span>
<?php } ?>
</h3>
<div class="card-tools">
<div class="btn-group">
<?php if ($agent_user_limit_reached) { ?>
<?php if ($agent_user_limit_reached && !serviceAccountsReady()) { ?>
<button type="button" class="btn btn-primary" disabled title="Every seat is taken - disable or archive a user<?= $agent_invites_holding ? ', or cancel an invite,' : '' ?> first">
<i class="fas fa-user-plus"></i><span class="d-none d-lg-inline ms-2">New User</span>
</button>