From abfe3b08af4e73de3db7ae001864e48786287c47 Mon Sep 17 00:00:00 2001 From: slawkens1 Date: Tue, 17 Oct 2017 03:36:37 +0200 Subject: [PATCH] * Account::getAccess = Account::getGroupId() --- system/libs/pot/OTS_Account.php | 37 ++++++--------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/system/libs/pot/OTS_Account.php b/system/libs/pot/OTS_Account.php index 37d26356..e578344c 100644 --- a/system/libs/pot/OTS_Account.php +++ b/system/libs/pot/OTS_Account.php @@ -818,34 +818,7 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable */ public function getAccess() { - global $groups; - if(!isset($groups)) - $groups = new OTS_Groups_List(); - - // by default - $access = 0; - if(fieldExist('group_id', 'accounts')) { - $query = $this->db->query('SELECT `group_id` FROM `accounts` WHERE `id` = ' . (int) $this->getId())->fetch(); - // if anything was found - - $group = $groups->getGroup($query['group_id']); - if(!$group) return 0; - return $group->getAccess(); - } - - // finds groups of all characters - foreach( $this->getPlayersList() as $player) - { - $group = $player->getGroup(); - - // checks if group's access level is higher then previouls found highest - if( $group->getAccess() > $access) - { - $access = $group->getAccess(); - } - } - - return $access; + return $this->getGroupId(); } public function getGroupId() @@ -858,10 +831,12 @@ class OTS_Account extends OTS_Row_DAO implements IteratorAggregate, Countable return $query['group_id']; } - $db->query('SELECT `group_id` FROM `players` WHERE `account_id` = ' . $this->getId() . ' ORDER BY `group_id` DESC LIMIT 1')->fetch(); - if(isset($query['group_id'])) + $query = $this->db->query('SELECT `group_id` FROM `players` WHERE `account_id` = ' . (int) $this->getId() . ' ORDER BY `group_id` DESC LIMIT 1'); + if($query->rowCount() == 1) + { + $query = $query->fetch(); return $query['group_id']; - + } return 0; }