ILIAS
release_5-4 Revision v5.4.26-12-gabc799a52e6
◀ 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
$DIC
;
31
32
$ilDB
= $DIC[
'ilDB'
];
33
34
$res
=
$ilDB
->query(
'SELECT online_time FROM ut_online WHERE usr_id = '
.
$ilDB
->quote($a_user_id,
'integer'
));
35
while
(
$row
=
$ilDB
->fetchAssoc(
$res
)) {
36
return
(
int
)
$row
[
'online_time'
];
37
}
38
39
return
0;
40
}
41
48
public
static
function
addUser($a_user_id)
49
{
53
global
$DIC
;
54
55
$ilDB
= $DIC[
'ilDB'
];
56
57
$res
=
$ilDB
->query(
'SELECT access_time FROM ut_online WHERE usr_id = '
.
$ilDB
->quote($a_user_id,
'integer'
));
58
if
(
$ilDB
->numRows(
$res
)) {
59
$row
=
$ilDB
->fetchAssoc(
$res
);
60
self::$last_access_time = (int)
$row
[
'access_time'
];
61
return
false
;
62
}
63
64
$ilDB
->manipulateF(
65
'INSERT INTO ut_online (usr_id, access_time) VALUES (%s, %s)'
,
66
array(
'integer'
,
'integer'
),
67
array($a_user_id, time())
68
);
69
self::$last_access_time = time();
70
71
return
true
;
72
}
73
80
public
static
function
updateAccess(
ilObjUser
$user
)
81
{
86
global
$DIC
;
87
88
$ilDB
= $DIC[
'ilDB'
];
89
$ilSetting
= $DIC[
'ilSetting'
];
90
91
if
(null === self::$last_access_time) {
92
$query
=
'SELECT access_time FROM ut_online WHERE usr_id = '
.
$ilDB
->quote($user->
getId
(),
'integer'
);
93
$res
=
$ilDB
->query(
$query
);
94
if
(!
$ilDB
->numRows(
$res
)) {
95
return
false
;
96
}
97
$row
=
$ilDB
->fetchAssoc(
$res
);
98
self::$last_access_time =
$row
[
'access_time'
];
99
}
100
101
$time_span = (int)
$ilSetting
->get(
'tracking_time_span'
, 300);
102
if
(($diff = time() - self::$last_access_time) <= $time_span) {
103
$ilDB
->manipulateF(
104
'UPDATE ut_online SET online_time = online_time + %s, access_time = %s WHERE usr_id = %s'
,
105
array(
'integer'
,
'integer'
,
'integer'
),
106
array($diff, time(), $user->
getId
())
107
);
108
}
else
{
109
$ilDB
->manipulateF(
110
'UPDATE ut_online SET access_time = %s WHERE usr_id = %s'
,
111
array(
'integer'
,
'integer'
),
112
array(time(), $user->
getId
())
113
);
114
}
115
return
true
;
116
}
117
}
$DIC
global $DIC
Definition:
saml.php:7
ilOnlineTracking\$last_access_time
static $last_access_time
Definition:
class.ilOnlineTracking.php:18
ilOnlineTracking
Definition:
class.ilOnlineTracking.php:11
$res
foreach($_POST as $key=> $value) $res
Definition:
save_question_post_data.php:15
ilObject\getId
getId()
get object id public
Definition:
class.ilObject.php:320
$query
$query
Definition:
proxy_ylocal.php:13
$user
$user
Definition:
migrateto20.php:57
$row
$row
Definition:
migrateto20.php:360
$ilSetting
global $ilSetting
Definition:
privfeed.php:17
$ilDB
global $ilDB
Definition:
storeScorm2004.php:16
php
ilObjUser
Definition:
class.ilObjUser.php:25
Services
Tracking
classes
class.ilOnlineTracking.php
Generated on Thu Mar 13 2025 19:02:07 for ILIAS by
1.8.13 (using
Doxyfile
)