Adjustments regarding accounts.id in admin panel -> Accounts editor

getAccountIdentityColumn() function
This commit is contained in:
slawkens 2024-12-19 22:32:05 +01:00
parent 023f1dc598
commit 8e0978c1ed
2 changed files with 16 additions and 7 deletions

View File

@ -23,10 +23,7 @@ $use_datatable = true;
if (setting('core.account_country')) if (setting('core.account_country'))
require SYSTEM . 'countries.conf.php'; require SYSTEM . 'countries.conf.php';
$nameOrNumberColumn = 'name'; $nameOrNumberColumn = getAccountIdentityColumn();
if (USE_ACCOUNT_NUMBER) {
$nameOrNumberColumn = 'number';
}
$hasSecretColumn = $db->hasColumn('accounts', 'secret'); $hasSecretColumn = $db->hasColumn('accounts', 'secret');
$hasCoinsColumn = $db->hasColumn('accounts', 'coins'); $hasCoinsColumn = $db->hasColumn('accounts', 'coins');
@ -69,7 +66,7 @@ else if (isset($_REQUEST['search_email'])) {
else if (isset($_REQUEST['search'])) { else if (isset($_REQUEST['search'])) {
$search_account = $_REQUEST['search']; $search_account = $_REQUEST['search'];
$min_size = 3; $min_size = 3;
if ($nameOrNumberColumn == 'number') { if (in_array($nameOrNumberColumn, ['id', 'number'])) {
$min_size = 1; $min_size = 1;
} }
@ -212,7 +209,7 @@ else if (isset($_REQUEST['search'])) {
if(setting('core.account_country')) { if(setting('core.account_country')) {
$account->setCountry($rl_country); $account->setCountry($rl_country);
} }
$account->setCustomField('created', $created); $account->setCustomField('created', $created);
$account->setWebFlags($web_flags); $account->setWebFlags($web_flags);
$account->setCustomField('web_lastlogin', $web_lastlogin); $account->setCustomField('web_lastlogin', $web_lastlogin);
@ -248,7 +245,7 @@ else if (isset($_REQUEST['search'])) {
<thead> <thead>
<tr> <tr>
<th>ID</th> <th>ID</th>
<th><?= ($nameOrNumberColumn == 'number' ? 'Number' : 'Name'); ?></th> <th><?= ($nameOrNumberColumn == 'name' ? 'Name' : 'Number'); ?></th>
<?php if($hasTypeColumn || $hasGroupColumn): ?> <?php if($hasTypeColumn || $hasGroupColumn): ?>
<th>E-Mail</th> <th>E-Mail</th>
<th>Position</th> <th>Position</th>

View File

@ -1684,6 +1684,18 @@ function isRequestMethod(string $method): bool {
return strtolower($_SERVER['REQUEST_METHOD']) == strtolower($method); return strtolower($_SERVER['REQUEST_METHOD']) == strtolower($method);
} }
function getAccountIdentityColumn(): string
{
if (USE_ACCOUNT_NAME) {
return 'name';
}
elseif (USE_ACCOUNT_NUMBER) {
return 'number';
}
return 'id';
}
// validator functions // validator functions
require_once SYSTEM . 'compat/base.php'; require_once SYSTEM . 'compat/base.php';