Bug Fixes

-fix for getSkillTries as reported by whiteblXK
-fix for login and account type as reported by vG-
This commit is contained in:
Lee 2018-12-30 01:00:26 +00:00
parent 8c83eb805b
commit 1859867039
5 changed files with 72 additions and 29 deletions

View File

@ -432,6 +432,11 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
$this->data['lastday'] = (int) $lastlogin; $this->data['lastday'] = (int) $lastlogin;
} }
public function setWebFlags($webflags)
{
$this->data['web_flags'] = (int) $webflags;
}
/** /**
* Name. * Name.
* *
@ -882,6 +887,32 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable
return 0; return 0;
} }
public function getAccGroupId()
{
if(isset($this->data['group_id'])) {
return $this->data['group_id'];
}
global $db;
if($db->hasColumn('accounts', 'group_id')) {
$query = $this->db->query('SELECT `group_id` FROM `accounts` WHERE `id` = ' . (int) $this->getId())->fetch();
// if anything was found
if(isset($query['group_id'])) {
$this->data['group_id'] = $query['group_id'];
return $query['group_id'];
}
}
if($db->hasColumn('accounts', 'type')) {
$query = $this->db->query('SELECT `type` FROM `accounts` WHERE `id` = ' . (int) $this->getId())->fetch();
// if anything was found
if(isset($query['type'])) {
$this->data['type'] = $query['type'];
return $query['type'];
}
}
return 0;
}
/**
/** /**
* Checks highest access level of account in given guild. * Checks highest access level of account in given guild.
* *

View File

@ -39,6 +39,8 @@ function verify_number($number, $name, $max_length)
$hasCoinsColumn = $db->hasColumn('accounts', 'coins'); $hasCoinsColumn = $db->hasColumn('accounts', 'coins');
$hasPointsColumn = $db->hasColumn('accounts', 'premium_points'); $hasPointsColumn = $db->hasColumn('accounts', 'premium_points');
$hasTypeColumn = $db->hasColumn('accounts', 'type');
$hasGroupColumn = $db->hasColumn('accounts', 'group_id');
if ($config['account_country']) { if ($config['account_country']) {
$countries = array(); $countries = array();
@ -82,7 +84,7 @@ else if (isset($_REQUEST['search_name'])) {
} }
} }
} }
$groups = new OTS_Groups_List();
if ($id > 0) { if ($id > 0) {
$account = new OTS_Account(); $account = new OTS_Account();
$account->load($id); $account->load($id);
@ -101,7 +103,7 @@ if ($id > 0) {
if (!$account_db->isLoaded()) if (!$account_db->isLoaded())
echo_error('Account with this id doesn\'t exist.'); echo_error('Account with this id doesn\'t exist.');
//type //type/group
$group = $_POST['group']; $group = $_POST['group'];
$password = ((!empty($_POST["pass"]) ? $_POST['pass'] : null)); $password = ((!empty($_POST["pass"]) ? $_POST['pass'] : null));
if (!Validator::password($password)) { if (!Validator::password($password)) {
@ -155,7 +157,13 @@ if ($id > 0) {
if (!$error) { if (!$error) {
$account->setName($name); $account->setName($name);
$account->setCustomField('type', $group);
if ($hasTypeColumn) {
$account->setCustomField('type', $group);
} elseif ($hasGroupColumn) {
$account->setCustomField('group_id', $group);
}
$account->setCustomField('secret', $secret); $account->setCustomField('secret', $secret);
$account->setCustomField('key', $key); $account->setCustomField('key', $key);
$account->setEMail($email); $account->setEMail($email);
@ -174,7 +182,6 @@ if ($id > 0) {
$account->setWebFlags($web_flags); $account->setWebFlags($web_flags);
$account->setCustomField('web_lastlogin', $web_lastlogin); $account->setCustomField('web_lastlogin', $web_lastlogin);
if (isset($password)) { if (isset($password)) {
$config_salt_enabled = $db->hasColumn('accounts', 'salt'); $config_salt_enabled = $db->hasColumn('accounts', 'salt');
if ($config_salt_enabled) { if ($config_salt_enabled) {
@ -189,7 +196,6 @@ if ($id > 0) {
if ($config_salt_enabled) if ($config_salt_enabled)
$account->setCustomField('salt', $salt); $account->setCustomField('salt', $salt);
} }
//$account->setCustomField('created', time());
$account->save(); $account->save();
echo_success('Account saved at: ' . date('G:i')); echo_success('Account saved at: ' . date('G:i'));
@ -208,12 +214,8 @@ else if ($id > 0 && isset($account) && $account->isLoaded())
?> ?>
<div class="row"> <div class="row">
<?php <?php if (isset($account) && $account->isLoaded()) { ?>
if (isset($account) && $account->isLoaded()) {
?>
<?php $acc_type = array("Normal", "Tutor", "Senior Tutor", "Gamemaster", "God"); ?>
<?php $web_acc = array("None", "Admin", "Super Admin", "(Admin + Super Admin)"); ?>
<form action="<?php echo $base . ((isset($id) && $id > 0) ? '&id=' . $id : ''); ?>" method="post" <form action="<?php echo $base . ((isset($id) && $id > 0) ? '&id=' . $id : ''); ?>" method="post"
class="form-horizontal"> class="form-horizontal">
<div class="col-md-8"> <div class="col-md-8">
@ -249,19 +251,36 @@ else if ($id > 0 && isset($account) && $account->isLoaded())
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<?php
<div class="col-xs-6"> $acc_group = $account->getAccGroupId();
<label for="group" class="control-label">Account Type:</label> if ($hasTypeColumn) {
<select name="group" id="group" class="form-control"> $acc_type = array("Normal", "Tutor", "Senior Tutor", "Gamemaster", "God"); ?>
<?php foreach ($acc_type as $id => $a_type): ?> <div class="col-xs-6">
<option value="<?php echo($id + 1); ?>" <?php echo($account->getCustomField('type') == ($id + 1) ? 'selected' : ''); ?>><?php echo $a_type; ?></option> <label for="group" class="control-label">Account Type:</label>
<?php endforeach; ?> <select name="group" id="group" class="form-control">
</select> <?php foreach ($acc_type as $id => $a_type): ?>
</div> <option value="<?php echo($id + 1); ?>" <?php echo($acc_group == ($id + 1) ? 'selected' : ''); ?>><?php echo $a_type; ?></option>
<?php endforeach; ?>
</select>
</div>
<?php
} elseif ($hasGroupColumn) {
?>
<div class="col-xs-6">
<label for="group" class="control-label">Account Type:</label>
<select name="group" id="group" class="form-control">
<?php
foreach ($groups->getGroups() as $id => $group): ?>
<option value="<?php echo $id; ?>" <?php echo($acc_group == $id ? 'selected' : ''); ?>><?php echo $group->getName(); ?></option>
<?php endforeach; ?>
</select>
</div>
<?php } ?>
<div class="col-xs-6"> <div class="col-xs-6">
<label for="web_flags" class="control-label">Website Access:</label> <label for="web_flags" class="control-label">Website Access:</label>
<select name="web_flags" id="web_flags" class="form-control"> <select name="web_flags" id="web_flags" class="form-control">
<?php foreach ($web_acc as $id => $a_type): ?> <?php $web_acc = array("None", "Admin", "Super Admin", "(Admin + Super Admin)");
foreach ($web_acc as $id => $a_type): ?>
<option value="<?php echo($id); ?>" <?php echo($account->getWebFlags() == ($id) ? 'selected' : ''); ?>><?php echo $a_type; ?></option> <option value="<?php echo($id); ?>" <?php echo($account->getWebFlags() == ($id) ? 'selected' : ''); ?>><?php echo $a_type; ?></option>
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>

View File

@ -14,19 +14,13 @@ if ($action == 'logout') {
$logout = "You have been logged out!"; $logout = "You have been logged out!";
} }
$search_errors[] = 'Character <b></b> does not exist or has been deleted.';
if (isset($errors)) { if (isset($errors)) {
foreach ($errors as $error) { foreach ($errors as $error) {
error($error); error($error);
$twig->display('admin.error.html.twig', array('errors' => $error));
} }
} }
$twig->display('admin.login.html.twig', array( $twig->display('admin.login.html.twig', array(
'errors' => $search_errors,
'logout' => $logout, 'logout' => $logout,
'account' => USE_ACCOUNT_NAME ? 'Name' : 'Number', 'account' => USE_ACCOUNT_NAME ? 'Name' : 'Number',
)); ));

View File

@ -584,13 +584,12 @@ else if ($id > 0 && isset($player) && $player->isLoaded())
</div> </div>
<div class="col-xs-6"> <div class="col-xs-6">
<label for="skills_tries[' . $id . ']" class="control-label">' . $info[0] . ' tries</label> <label for="skills_tries[' . $id . ']" class="control-label">' . $info[0] . ' tries</label>
<input type="text" class="form-control" id="skills_tries[' . $id . ']" name="skills_tries[' . $id . ']" maxlength="10" autocomplete="off" style="cursor: auto;" value="' . $player->getSkill($id) . '"/> <input type="text" class="form-control" id="skills_tries[' . $id . ']" name="skills_tries[' . $id . ']" maxlength="10" autocomplete="off" style="cursor: auto;" value="' . $player->getSkillTries($id) . '"/>
</div> </div>
</div>'; </div>';
if ($i == 0) if ($i == 0)
echo ''; echo '';
} }
?> ?>
</div> </div>
<div class="tab-pane" id="tab_4"> <div class="tab-pane" id="tab_4">

View File

@ -35,4 +35,4 @@
</div> </div>
</div> </div>
</form> </form>
</div> </div>