Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add ability to list all accounts and players in admin editor #115

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 26 additions & 6 deletions admin/pages/accounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function verify_number($number, $name, $max_length)
}
?>

<link rel="stylesheet" type="text/css" href="<?= BASE_URL; ?>tools/css/jquery.datetimepicker.css"/ >
<link rel="stylesheet" type="text/css" href="<?= BASE_URL; ?>tools/css/jquery.datetimepicker.css"/>
<script src="<?= BASE_URL; ?>tools/js/jquery.datetimepicker.js"></script>

<?php
Expand All @@ -68,18 +68,18 @@ function verify_number($number, $name, $max_length)
} else {
if (Validator::number($searchName)) {
$id = $searchName;
$query = $db->query("SELECT `id` FROM `accounts` WHERE `name` = {$id}");
$query = $db->query("SELECT id FROM accounts WHERE name = {$id}");
if ($query->rowCount() == 1) {
$query = $query->fetch();
$id = $query['id'];
}
} else {
$query = $db->query("SELECT `id` FROM `accounts` WHERE `name` = {$db->quote($searchName)}");
$query = $db->query("SELECT id FROM accounts WHERE name = {$db->quote($searchName)}");
if ($query->rowCount() == 1) {
$query = $query->fetch();
$id = $query['id'];
} else {
$query = $db->query("SELECT `id`, `name` FROM `accounts` WHERE `name` LIKE {$db->quote("%{$searchName}%")}");
$query = $db->query("SELECT id, name FROM accounts WHERE name LIKE {$db->quote("%{$searchName}%")}");
if ($query->rowCount() > 0 && $query->rowCount() <= 10) {
echo 'Do you mean?<ul>';
foreach ($query as $row)
Expand All @@ -91,6 +91,8 @@ function verify_number($number, $name, $max_length)
}
}
}


$groups = new OTS_Groups_List();
if ($id > 0) {
$account = new OTS_Account();
Expand Down Expand Up @@ -457,7 +459,7 @@ class="fa fa-remove"></i> Cancel</span></a>
<?php
if (isset($account) && $account->isLoaded()) {
$account_players = array();
$query = $db->query('SELECT `name`,`level`,`vocation` FROM `players` WHERE `account_id` = ' . $account->getId() . ' ORDER BY `name`')->fetchAll();
$query = $db->query('SELECT name,level,vocation FROM players WHERE account_id = ' . $account->getId() . ' ORDER BY name')->fetchAll();
dhmello marked this conversation as resolved.
Show resolved Hide resolved
if (isset($query)) {
?>
<div class="box">
Expand Down Expand Up @@ -495,7 +497,25 @@ class="fa fa-remove"></i> Cancel</span></a>
};
?>
</div>

<?php
// List all accounts
dhmello marked this conversation as resolved.
Show resolved Hide resolved
$allAccounts = $db->query("SELECT id, name, email FROM accounts ORDER BY id ASC")->fetchAll();
if ($allAccounts) {
echo '<h3>All Accounts:</h3>';
echo '<table class="table table-striped">';
echo '<thead><tr><th>ID</th><th>Account Name</th><th>Email</th></tr></thead>';
echo '<tbody>';
foreach ($allAccounts as $accountRow) {
echo '<tr>';
echo '<td>' . $accountRow['id'] . '</td>';
echo '<td><a href="' . $base . '&id=' . $accountRow['id'] . '">' . $accountRow['name'] . '</a></td>';
echo '<td>' . $accountRow['email'] . '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
}
?>
<script type="text/javascript">
$('#lastlogout').datetimepicker({format: 'unixtime'});
$('#created').datetimepicker({format: 'unixtime'});
Expand Down
19 changes: 19 additions & 0 deletions admin/pages/players.php
Original file line number Diff line number Diff line change
Expand Up @@ -895,3 +895,22 @@ function updateOutfit()
console.log(new_outfit);
}
</script>
<?php
// List all players
$allAccounts = $db->query("SELECT id, name, account_id FROM players ORDER BY id ASC")->fetchAll();
dhmello marked this conversation as resolved.
Show resolved Hide resolved
if ($allAccounts) {
echo '<h3>All Accounts:</h3>';
echo '<table class="table table-striped">';
echo '<thead><tr><th>ID</th><th>Player Name</th><th>Account Name</th></tr></thead>';
echo '<tbody>';
foreach ($allAccounts as $accountRow) {
echo '<tr>';
echo '<td>' . $accountRow['id'] . '</td>';
echo '<td><a href="' . $base . '&id=' . $accountRow['id'] . '">' . $accountRow['name'] .'</a></td>';
echo '<td>' . $accountRow['account_id'] . '</td>';
echo '</tr>';
}
echo '</tbody>';
echo '</table>';
}
?>
Loading