19 declare(strict_types=0);
38 $ilDB = $DIC->database();
40 'SELECT online_time FROM ut_online WHERE usr_id = ' .
$ilDB->quote(
46 return (
int) $row[
'online_time'];
51 public static function addUser(
int $a_user_id): bool
55 $ilDB = $DIC->database();
57 'SELECT access_time FROM ut_online WHERE usr_id = ' .
$ilDB->quote(
64 self::$last_access_time = (
int) $row[
'access_time'];
69 'INSERT INTO ut_online (usr_id, access_time) VALUES (%s, %s)',
70 array(
'integer',
'integer'),
71 array($a_user_id, time())
73 self::$last_access_time = time();
81 $ilDB = $DIC->database();
84 if (
null === self::$last_access_time) {
85 $query =
'SELECT access_time FROM ut_online WHERE usr_id = ' .
$ilDB->quote(
94 self::$last_access_time = (
int) $row[
'access_time'];
97 $time_span = (
int)
$ilSetting->get(
'tracking_time_span',
'300');
98 if (($diff = time() - self::$last_access_time) <= $time_span) {
100 'UPDATE ut_online SET online_time = online_time + %s, access_time = %s WHERE usr_id = %s',
101 array(
'integer',
'integer',
'integer'),
102 array($diff, time(), $user->
getId())
106 'UPDATE ut_online SET access_time = %s WHERE usr_id = %s',
107 array(
'integer',
'integer'),
108 array(time(), $user->
getId())
static updateAccess(ilObjUser $user)
static int $last_access_time
This static variable is used to prevent two database request (addUser and updateAccess) on login...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static addUser(int $a_user_id)
static getOnlineTime(int $a_user_id)