ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 13 of file class.ilOnlineTracking.php.

Member Function Documentation

◆ addUser()

static ilOnlineTracking::addUser ( int  $a_user_id)
static

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

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

Referenced by ilAuthFrontend\handleAuthenticationSuccess().

37  : bool
38  {
39  global $DIC;
40 
41  $ilDB = $DIC->database();
42  $res = $ilDB->query(
43  'SELECT access_time FROM ut_online WHERE usr_id = ' . $ilDB->quote(
44  $a_user_id,
45  'integer'
46  )
47  );
48  if ($ilDB->numRows($res)) {
49  $row = $ilDB->fetchAssoc($res);
50  self::$last_access_time = (int) $row['access_time'];
51  return false;
52  }
53 
54  $ilDB->manipulateF(
55  'INSERT INTO ut_online (usr_id, access_time) VALUES (%s, %s)',
56  array('integer', 'integer'),
57  array($a_user_id, time())
58  );
59  self::$last_access_time = time();
60  return true;
61  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ 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 20 of file class.ilOnlineTracking.php.

References $DIC, $ilDB, and $res.

20  : int
21  {
22  global $DIC;
23 
24  $ilDB = $DIC->database();
25  $res = $ilDB->query(
26  'SELECT online_time FROM ut_online WHERE usr_id = ' . $ilDB->quote(
27  $a_user_id,
28  'integer'
29  )
30  );
31  while ($row = $ilDB->fetchAssoc($res)) {
32  return (int) $row['online_time'];
33  }
34  return 0;
35  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28

◆ updateAccess()

static ilOnlineTracking::updateAccess ( ilObjUser  $user)
static

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

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

Referenced by ilInitialisation\initUserAccount(), and ilInitialisation\resumeUserSession().

63  : bool
64  {
65  global $DIC;
66 
67  $ilDB = $DIC->database();
68  $ilSetting = $DIC->settings();
69 
70  if (null === self::$last_access_time) {
71  $query = 'SELECT access_time FROM ut_online WHERE usr_id = ' . $ilDB->quote(
72  $user->getId(),
73  'integer'
74  );
75  $res = $ilDB->query($query);
76  if (!$ilDB->numRows($res)) {
77  return false;
78  }
79  $row = $ilDB->fetchAssoc($res);
80  self::$last_access_time = (int) $row['access_time'];
81  }
82 
83  $time_span = (int) $ilSetting->get('tracking_time_span', '300');
84  if (($diff = time() - self::$last_access_time) <= $time_span) {
85  $ilDB->manipulateF(
86  'UPDATE ut_online SET online_time = online_time + %s, access_time = %s WHERE usr_id = %s',
87  array('integer', 'integer', 'integer'),
88  array($diff, time(), $user->getId())
89  );
90  } else {
91  $ilDB->manipulateF(
92  'UPDATE ut_online SET access_time = %s WHERE usr_id = %s',
93  array('integer', 'integer'),
94  array(time(), $user->getId())
95  );
96  }
97  return true;
98  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
$query
global $ilSetting
Definition: privfeed.php:17
+ 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 18 of file class.ilOnlineTracking.php.


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