Added last login date to users

This commit is contained in:
Marcin Kurczewski 2014-02-13 09:10:24 +01:00
parent b22e74c0e9
commit c99596d12b
6 changed files with 11 additions and 0 deletions

View file

@ -104,6 +104,8 @@ class AuthController
if (!empty($context->user) and $context->user->id) if (!empty($context->user) and $context->user->id)
{ {
$dbUser = UserModel::findById($context->user->id); $dbUser = UserModel::findById($context->user->id);
$context->user->lastLoginDate = time();
UserModel::save($context->user);
$_SESSION['user'] = serialize($dbUser); $_SESSION['user'] = serialize($dbUser);
} }
else else

View file

@ -8,6 +8,7 @@ class UserEntity extends AbstractEntity
public $emailUnconfirmed; public $emailUnconfirmed;
public $emailConfirmed; public $emailConfirmed;
public $joinDate; public $joinDate;
public $lastLoginDate;
public $accessRank; public $accessRank;
public $settings; public $settings;
public $banned; public $banned;

View file

@ -34,6 +34,7 @@ class UserModel extends AbstractCrudModel
'email_unconfirmed' => $user->emailUnconfirmed, 'email_unconfirmed' => $user->emailUnconfirmed,
'email_confirmed' => $user->emailConfirmed, 'email_confirmed' => $user->emailConfirmed,
'join_date' => $user->joinDate, 'join_date' => $user->joinDate,
'last_login_date' => $user->lastLoginDate,
'access_rank' => $user->accessRank, 'access_rank' => $user->accessRank,
'settings' => $user->settings, 'settings' => $user->settings,
'banned' => $user->banned 'banned' => $user->banned

View file

@ -0,0 +1 @@
ALTER TABLE user ADD COLUMN last_login_date INTEGER DEFAULT NULL;

View file

@ -0,0 +1 @@
ALTER TABLE user ADD COLUMN last_login_date INTEGER DEFAULT NULL;

View file

@ -19,6 +19,11 @@ LayoutHelper::addStylesheet('user-view.css');
<span class="value" title="<?php echo $val = date('Y-m-d', $this->context->transport->user->joinDate) ?>"><?php echo $val ?></span> <span class="value" title="<?php echo $val = date('Y-m-d', $this->context->transport->user->joinDate) ?>"><?php echo $val ?></span>
</div> </div>
<div class="key-value last-login">
<span class="key">Last login:</span>
<span class="value" title="<?php echo $val = $this->context->transport->user->lastLoginDate ? date('Y-m-d', $this->context->transport->user->lastLoginDate) : 'Unknown' ?>"><?php echo $val ?></span>
</div>
<div class="key-value access-rank"> <div class="key-value access-rank">
<span class="key">Access rank:</span> <span class="key">Access rank:</span>
<span class="value" title="<?php echo $val = TextHelper::camelCaseToHumanCase(AccessRank::toString($this->context->transport->user->accessRank)) ?>"><?php echo $val ?></span> <span class="value" title="<?php echo $val = TextHelper::camelCaseToHumanCase(AccessRank::toString($this->context->transport->user->accessRank)) ?>"><?php echo $val ?></span>