Delete isLogged from User
Use logged > 0
This commit is contained in:
parent
68156fe9b7
commit
2cc436d87d
4 changed files with 8 additions and 56 deletions
|
@ -146,7 +146,7 @@ class Model extends ParentModel
|
|||
':name' => (string) $this->c->user->isBot,
|
||||
':ip' => $this->c->user->ip
|
||||
];
|
||||
if ($this->c->user->isLogged) {
|
||||
if ($this->c->user->logged > 0) {
|
||||
$this->c->DB->exec('UPDATE ::online SET logged=?i:logged, o_position=?s:pos, o_name=?s:name WHERE user_id=1 AND ident=?s:ip', $vars);
|
||||
} else {
|
||||
$this->c->DB->exec('INSERT INTO ::online (user_id, ident, logged, o_position, o_name) SELECT 1, ?s:ip, ?i:logged, ?s:pos, ?s:name FROM ::groups WHERE NOT EXISTS (SELECT 1 FROM ::online WHERE user_id=1 AND ident=?s:ip) LIMIT 1', $vars);
|
||||
|
@ -159,7 +159,7 @@ class Model extends ParentModel
|
|||
':id' => $this->c->user->id,
|
||||
':name' => $this->c->user->username,
|
||||
];
|
||||
if ($this->c->user->isLogged) {
|
||||
if ($this->c->user->logged > 0) {
|
||||
$this->c->DB->exec('UPDATE ::online SET logged=?i:logged, o_position=?s:pos WHERE user_id=?i:id', $vars);
|
||||
} else {
|
||||
$this->c->DB->exec('INSERT INTO ::online (user_id, ident, logged, o_position) SELECT ?i:id, ?s:name, ?i:logged, ?s:pos FROM ::groups WHERE NOT EXISTS (SELECT 1 FROM ::online WHERE user_id=?i:id) LIMIT 1', $vars);
|
||||
|
|
|
@ -34,38 +34,18 @@ class Current extends Action
|
|||
$cookie->setUser($user);
|
||||
|
||||
if ($user->isGuest) {
|
||||
$user->__isBot = $this->isBot();
|
||||
# $user->__disp_topics = $this->c->config->o_disp_topics_default;
|
||||
# $user->__disp_posts = $this->c->config->o_disp_posts_default;
|
||||
$user->__isBot = $this->isBot();
|
||||
$user->__timezone = $this->c->config->o_default_timezone;
|
||||
$user->__dst = $this->c->config->o_default_dst;
|
||||
# $user->language = $this->c->config->o_default_lang;
|
||||
# $user->style = $this->c->config->o_default_style;
|
||||
$user->__dst = $this->c->config->o_default_dst;
|
||||
$user->__language = $this->getLangFromHTTP();
|
||||
|
||||
// быстрое переключение языка - Visman
|
||||
/* $language = $this->cookie->get('glang');
|
||||
if (null !== $language) {
|
||||
$language = preg_replace('%[^a-zA-Z0-9_]%', '', $language);
|
||||
$languages = forum_list_langs();
|
||||
if (in_array($language, $languages)) {
|
||||
$user->language = $language;
|
||||
}
|
||||
} */
|
||||
} else {
|
||||
$user->__isBot = false;
|
||||
# if (! $user->disp_topics) {
|
||||
# $user->__disp_topics = $this->c->config->o_disp_topics_default;
|
||||
# }
|
||||
# if (! $user->disp_posts) {
|
||||
# $user->__disp_posts = $this->c->config->o_disp_posts_default;
|
||||
# }
|
||||
// Special case: We've timed out, but no other user has browsed the forums since we timed out
|
||||
if (
|
||||
$user->isLogged
|
||||
$user->logged > 0
|
||||
&& $user->logged < \time() - $this->c->config->o_timeout_visit
|
||||
) {
|
||||
$this->manager->updateLastVisit($user); //????
|
||||
$this->manager->updateLastVisit($user);
|
||||
}
|
||||
|
||||
$this->manager->set($user->id, $user);
|
||||
|
|
|
@ -30,7 +30,6 @@ class Model extends DataModel
|
|||
'group_id' => ['isUnverified', 'isGuest', 'isAdmin', 'isAdmMod', 'link', 'viewUsers', 'showPostCount', 'searchUsers'],
|
||||
'id' => ['isGuest', 'link', 'avatar', 'online'],
|
||||
'last_visit' => ['currentVisit'],
|
||||
'logged' => ['isLogged'],
|
||||
'show_sig' => ['showSignature'],
|
||||
'show_avatars' => ['showAvatar'],
|
||||
];
|
||||
|
@ -103,33 +102,6 @@ class Model extends DataModel
|
|||
return isset($model->moderators[$this->id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Время последнего действия пользователя
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function getlogged(): int
|
||||
{
|
||||
$attr = $this->getAttr('logged');
|
||||
|
||||
if (empty($attr)) { // ???? $attr < 1
|
||||
$attr = \time();
|
||||
}
|
||||
|
||||
return $attr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Статус наличия данных пользователя в таблице online //????
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function getisLogged(): bool
|
||||
{
|
||||
$attr = $this->getAttr('logged');
|
||||
return ! empty($attr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Время последнего визита
|
||||
*
|
||||
|
|
|
@ -17,10 +17,10 @@ class UpdateLastVisit extends Action
|
|||
*/
|
||||
public function updateLastVisit(User $user): void
|
||||
{
|
||||
if ($user->id < 2) {
|
||||
if ($user->isGuest) {
|
||||
throw new RuntimeException('Expected user');
|
||||
}
|
||||
if ($user->isLogged) {
|
||||
if ($user->logged > 0) {
|
||||
$this->c->DB->exec('UPDATE ::users SET last_visit=?i:loggid WHERE id=?i:id', [':loggid' => $user->logged, ':id' => $user->id]);
|
||||
$user->__last_visit = $user->logged;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue