Skip to content

Commit

Permalink
Fix lastlogin = null see #3108
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Jun 23, 2020
1 parent 68087a9 commit e1de72c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/Chamilo/UserBundle/Repository/UserRepository.php
Expand Up @@ -390,7 +390,7 @@ public function findUsersToSendMessage($currentUserId, $search, $limit = 10)
} else {
$dql = "SELECT DISTINCT U
FROM ChamiloCoreBundle:AccessUrlRelUser R, ChamiloCoreBundle:UserRelUser UF
INNER JOIN ChamiloUserBundle:User AS U
INNER JOIN ChamiloUserBundle:User AS U
WITH UF.friendUserId = U
WHERE
U.active = 1 AND
Expand All @@ -408,7 +408,7 @@ public function findUsersToSendMessage($currentUserId, $search, $limit = 10)
if ($allowSendMessageToAllUsers === 'true') {
$dql = "SELECT DISTINCT U
FROM ChamiloUserBundle:User U
LEFT JOIN ChamiloCoreBundle:AccessUrlRelUser R
LEFT JOIN ChamiloCoreBundle:AccessUrlRelUser R
WITH U = R.user
WHERE
U.active = 1 AND
Expand All @@ -427,7 +427,7 @@ public function findUsersToSendMessage($currentUserId, $search, $limit = 10)
WITH U.id = T.loginUserId
WHERE
R.portal = $accessUrlId AND
U.active = 1 AND
U.active = 1 AND
T.loginDate >= '".$limit_date."'";
}
}
Expand Down Expand Up @@ -1262,7 +1262,10 @@ public function getPersonalDataToJson($userId, array $substitutionTerms)
$lastLogin = $login->getLoginDate();
}
}
$user->setLastLogin($lastLogin);

if (!empty($lastLogin)) {
$user->setLastLogin($lastLogin);
}

$dateNormalizer = new GetSetMethodNormalizer();
$dateNormalizer->setCircularReferenceHandler(function ($object) {
Expand Down Expand Up @@ -1334,7 +1337,7 @@ public function getLastLogin(User $user)
$repo = $this->getEntityManager()->getRepository('ChamiloCoreBundle:TrackELogin');
$qb = $repo->createQueryBuilder('l');

$login = $qb
return $qb
->select('l')
->where(
$qb->expr()->eq('l.loginUserId', $user->getId())
Expand All @@ -1343,7 +1346,5 @@ public function getLastLogin(User $user)
->orderBy('l.loginDate', 'DESC')
->getQuery()
->getOneOrNullResult();

return $login;
}
}

0 comments on commit e1de72c

Please sign in to comment.