ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilOnlineTracking Class Reference
+ Collaboration diagram for ilOnlineTracking:

Static Public Member Functions

static getOnlineTime (int $a_user_id)
 
static addUser (int $a_user_id)
 
static updateAccess (ilObjUser $user)
 

Static Protected Attributes

static int $last_access_time = null
 This static variable is used to prevent two database request (addUser and updateAccess) on login. More...
 

Detailed Description

Definition at line 27 of file class.ilOnlineTracking.php.

Member Function Documentation

◆ addUser()

static ilOnlineTracking::addUser ( int  $a_user_id)
static

Definition at line 51 of file class.ilOnlineTracking.php.

51 : bool
52 {
53 global $DIC;
54
55 $ilDB = $DIC->database();
56 $res = $ilDB->query(
57 'SELECT access_time FROM ut_online WHERE usr_id = ' . $ilDB->quote(
58 $a_user_id,
59 'integer'
60 )
61 );
62 if ($ilDB->numRows($res)) {
63 $row = $ilDB->fetchAssoc($res);
64 self::$last_access_time = (int) $row['access_time'];
65 return false;
66 }
67
68 $ilDB->manipulateF(
69 'INSERT INTO ut_online (usr_id, access_time) VALUES (%s, %s)',
70 array('integer', 'integer'),
71 array($a_user_id, time())
72 );
73 self::$last_access_time = time();
74 return true;
75 }
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:26

References $DIC, $ilDB, $res, and ILIAS\Repository\int().

Referenced by ilAuthFrontend\handleAuthenticationSuccess().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getOnlineTime()

static ilOnlineTracking::getOnlineTime ( int  $a_user_id)
static

Definition at line 34 of file class.ilOnlineTracking.php.

34 : int
35 {
36 global $DIC;
37
38 $ilDB = $DIC->database();
39 $res = $ilDB->query(
40 'SELECT online_time FROM ut_online WHERE usr_id = ' . $ilDB->quote(
41 $a_user_id,
42 'integer'
43 )
44 );
45 while ($row = $ilDB->fetchAssoc($res)) {
46 return (int) $row['online_time'];
47 }
48 return 0;
49 }

References $DIC, $ilDB, and $res.

◆ updateAccess()

static ilOnlineTracking::updateAccess ( ilObjUser  $user)
static

Definition at line 77 of file class.ilOnlineTracking.php.

77 : bool
78 {
79 global $DIC;
80
81 $ilDB = $DIC->database();
82 $ilSetting = $DIC->settings();
83
84 if (null === self::$last_access_time) {
85 $query = 'SELECT access_time FROM ut_online WHERE usr_id = ' . $ilDB->quote(
86 $user->getId(),
87 'integer'
88 );
89 $res = $ilDB->query($query);
90 if (!$ilDB->numRows($res)) {
91 return false;
92 }
93 $row = $ilDB->fetchAssoc($res);
94 self::$last_access_time = (int) $row['access_time'];
95 }
96
97 $time_span = (int) $ilSetting->get('tracking_time_span', '300');
98 if (($diff = time() - self::$last_access_time) <= $time_span) {
99 $ilDB->manipulateF(
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())
103 );
104 } else {
105 $ilDB->manipulateF(
106 'UPDATE ut_online SET access_time = %s WHERE usr_id = %s',
107 array('integer', 'integer'),
108 array(time(), $user->getId())
109 );
110 }
111 return true;
112 }
static int $last_access_time
This static variable is used to prevent two database request (addUser and updateAccess) on login.
global $ilSetting
Definition: privfeed.php:31

References $DIC, $ilDB, $ilSetting, $last_access_time, $res, ilObject\getId(), and ILIAS\Repository\int().

Referenced by ilInitialisation\initUserAccount().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $last_access_time

int ilOnlineTracking::$last_access_time = null
staticprotected

This static variable is used to prevent two database request (addUser and updateAccess) on login.

Definition at line 32 of file class.ilOnlineTracking.php.

Referenced by updateAccess().


The documentation for this class was generated from the following file: