ILIAS
release_5-3 Revision v5.3.23-19-g915713cf615
◀ ilDoc Overview
class.ilOnlineTracking.php
Go to the documentation of this file.
1
<?
php
2
/* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3
11
class
ilOnlineTracking
12
{
18
protected
static
$last_access_time
=
null
;
19
25
public
static
function
getOnlineTime($a_user_id)
26
{
30
global
$ilDB
;
31
32
$res
=
$ilDB
->query(
'SELECT online_time FROM ut_online WHERE usr_id = '
.
$ilDB
->quote($a_user_id,
'integer'
));
33
while
(
$row
=
$ilDB
->fetchAssoc(
$res
)) {
34
return
(
int
)
$row
[
'online_time'
];
35
}
36
37
return
0;
38
}
39
46
public
static
function
addUser($a_user_id)
47
{
51
global
$ilDB
;
52
53
$res
=
$ilDB
->query(
'SELECT access_time FROM ut_online WHERE usr_id = '
.
$ilDB
->quote($a_user_id,
'integer'
));
54
if
(
$ilDB
->numRows(
$res
)) {
55
$row
=
$ilDB
->fetchAssoc(
$res
);
56
self::$last_access_time = (int)
$row
[
'access_time'
];
57
return
false
;
58
}
59
60
$ilDB
->manipulateF(
61
'INSERT INTO ut_online (usr_id, access_time) VALUES (%s, %s)'
,
62
array(
'integer'
,
'integer'
),
63
array($a_user_id, time())
64
);
65
self::$last_access_time = time();
66
67
return
true
;
68
}
69
76
public
static
function
updateAccess(
ilObjUser
$user)
77
{
82
global
$ilDB
,
$ilSetting
;
83
84
if
(
null
=== self::$last_access_time) {
85
$query
=
'SELECT access_time FROM ut_online WHERE usr_id = '
.
$ilDB
->quote($user->
getId
(),
'integer'
);
86
$res
=
$ilDB
->query(
$query
);
87
if
(!
$ilDB
->numRows(
$res
)) {
88
return
false
;
89
}
90
$row
=
$ilDB
->fetchAssoc(
$res
);
91
self::$last_access_time =
$row
[
'access_time'
];
92
}
93
94
$time_span = (int)
$ilSetting
->get(
'tracking_time_span'
, 300);
95
if
(($diff = time() - self::$last_access_time) <= $time_span) {
96
$ilDB
->manipulateF(
97
'UPDATE ut_online SET online_time = online_time + %s, access_time = %s WHERE usr_id = %s'
,
98
array(
'integer'
,
'integer'
,
'integer'
),
99
array($diff, time(), $user->
getId
())
100
);
101
}
else
{
102
$ilDB
->manipulateF(
103
'UPDATE ut_online SET access_time = %s WHERE usr_id = %s'
,
104
array(
'integer'
,
'integer'
),
105
array(time(), $user->
getId
())
106
);
107
}
108
return
true
;
109
}
110
}
$row
$row
Definition:
10autofilter-selection-1.php:74
php
An exception for terminatinating execution or to throw for unit testing.
ilObjUser
Definition:
class.ilObjUser.php:26
ilObject\getId
getId()
get object id @access public
Definition:
class.ilObject.php:308
ilOnlineTracking
Definition:
class.ilOnlineTracking.php:12
ilOnlineTracking\$last_access_time
static $last_access_time
Definition:
class.ilOnlineTracking.php:18
$ilSetting
global $ilSetting
Definition:
privfeed.php:17
$query
$query
Definition:
proxy_ylocal.php:13
$res
foreach($_POST as $key=> $value) $res
Definition:
save_question_post_data.php:15
$ilDB
global $ilDB
Definition:
storeScorm2004.php:19
Services
Tracking
classes
class.ilOnlineTracking.php
Generated on Sat Oct 4 2025 19:01:23 for ILIAS by
1.9.4 (using
Doxyfile
)