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
}
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:308
$query
$query
Definition:
proxy_ylocal.php:13
array
Create styles array
The data for the language used.
Definition:
40duplicateStyle.php:19
$ilSetting
global $ilSetting
Definition:
privfeed.php:17
$ilDB
global $ilDB
Definition:
storeScorm2004.php:16
time
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
Definition:
40duplicateStyle.php:39
ilObjUser
Definition:
class.ilObjUser.php:25
$row
$row
Definition:
10autofilter-selection-1.php:74
Services
Tracking
classes
class.ilOnlineTracking.php
Generated on Sat Jan 18 2025 19:01:39 for ILIAS by
1.8.13 (using
Doxyfile
)