Переделал вызов User()->info[] на статический, чтобы можно было вызывать в том числе и извне для частных случаев, когда нужна инфомация не только по активному игроку.
This commit is contained in:
parent
83ec9d12f9
commit
2d3f23f81b
@ -588,47 +588,8 @@ class User
|
|||||||
|
|
||||||
private function __construct()
|
private function __construct()
|
||||||
{
|
{
|
||||||
if (!empty($_SESSION['uid'])) {
|
$user = !empty($_SESSION['uid']) ? $_SESSION['uid'] : $_COOKIE['login'];
|
||||||
$user = Db::getRow(
|
$this->info = self::getInfo($user);
|
||||||
'select
|
|
||||||
*,
|
|
||||||
users.id as id,
|
|
||||||
users.level as level,
|
|
||||||
users.align as align,
|
|
||||||
users.sex as sex,
|
|
||||||
users.clan as clan,
|
|
||||||
stats.timeGo as timeGo,
|
|
||||||
users.name as name,
|
|
||||||
stats.lider as lider
|
|
||||||
from users
|
|
||||||
left join stats on users.id = stats.id
|
|
||||||
left join room on users.room = room.id
|
|
||||||
where users.id = ?',
|
|
||||||
[$_SESSION['uid']]
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$user = Db::getRow(
|
|
||||||
'select
|
|
||||||
*,
|
|
||||||
users.id as id,
|
|
||||||
users.level as level,
|
|
||||||
users.align as align,
|
|
||||||
users.sex as sex,
|
|
||||||
users.clan as clan,
|
|
||||||
stats.timeGo as timeGo,
|
|
||||||
users.name as name,
|
|
||||||
stats.lider as lider
|
|
||||||
from users
|
|
||||||
left join stats on users.id = stats.id
|
|
||||||
left join room on users.room = room.id
|
|
||||||
where login = ?',
|
|
||||||
[$_COOKIE['login']]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($user) && is_array($user)) {
|
|
||||||
$this->info = $user;
|
|
||||||
}
|
|
||||||
unset($user);
|
unset($user);
|
||||||
|
|
||||||
Database::init(); // для всяких mysql_*
|
Database::init(); // для всяких mysql_*
|
||||||
@ -1144,6 +1105,31 @@ class User
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int|string $user
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function getInfo($user): array
|
||||||
|
{
|
||||||
|
$cell = is_numeric($user) ? 'id' : 'login';
|
||||||
|
$query = 'select
|
||||||
|
*,
|
||||||
|
users.id as id,
|
||||||
|
users.level as level,
|
||||||
|
users.align as align,
|
||||||
|
users.sex as sex,
|
||||||
|
users.clan as clan,
|
||||||
|
stats.timeGo as timeGo,
|
||||||
|
users.name as name,
|
||||||
|
stats.lider as lider
|
||||||
|
from users
|
||||||
|
left join stats on users.id = stats.id
|
||||||
|
left join room on users.room = room.id
|
||||||
|
where users.' . $cell . ' = ?';
|
||||||
|
$result = Db::getRow($query, [$user]);
|
||||||
|
return $result ?: [];
|
||||||
|
}
|
||||||
|
|
||||||
private function infoTasks()
|
private function infoTasks()
|
||||||
{
|
{
|
||||||
if (empty($this->info)) {
|
if (empty($this->info)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user