ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilSessionControl Class Reference
+ Collaboration diagram for ilSessionControl:

Static Public Member Functions

static handleLoginEvent (string $a_login, ilAuthSession $auth_session)
 when current session is allowed to be created it marks it with type regarding to the sessions user context. More...
 
static handleLogoutEvent ()
 reset sessions type to unknown More...
 
static getExistingSessionCount (array $a_types)
 returns number of valid sessions relating to given session types More...
 
static getSettingFields ()
 returns the array of setting fields More...
 

Data Fields

const DEFAULT_MIN_IDLE = 15
 default value for settings that have not been defined in setup or administration yet More...
 
const DEFAULT_ALLOW_CLIENT_MAINTENANCE = 1
 

Static Public Attributes

static array $session_types_controlled
 

Static Private Member Functions

static isValidSession (string $a_sid)
 checks if session exists for given id and if it is still valid More...
 
static removeSessionCookie ()
 removes a session cookie, so it is not sent by browser anymore More...
 
static checkAdministrationPermission (int $a_user_id)
 checks wether a given user login relates to an user with administrative permissions More...
 
static debug (string $a_debug_log_message)
 logs the given debug message in More...
 

Private Attributes

const SESSION_TYPE_UNKNOWN = 0
 session types from which one is assigned to each session More...
 
const SESSION_TYPE_SYSTEM = 1
 
const SESSION_TYPE_ADMIN = 2
 
const SESSION_TYPE_USER = 3
 
const SESSION_TYPE_ANONYM = 4
 
const SESSION_TYPE_KEY = "SessionType"
 

Static Private Attributes

static array $setting_fields
 all fieldnames that are saved in settings table More...
 
static array $session_types_not_controlled
 all session types that will be involved when count of sessions will be determined or when idleing sessions will be destroyed More...
 

Detailed Description

Author
Bjoern Heyser bheys.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de

Definition at line 24 of file class.ilSessionControl.php.

Member Function Documentation

◆ checkAdministrationPermission()

static ilSessionControl::checkAdministrationPermission ( int  $a_user_id)
staticprivate

checks wether a given user login relates to an user with administrative permissions

ilRbacSystem $rbacsystem

Returns
boolean access

Definition at line 202 of file class.ilSessionControl.php.

References $DIC, and SYSTEM_FOLDER_ID.

202  : bool
203  {
204  if (!$a_user_id) {
205  return false;
206  }
207 
208  global $DIC;
209 
210  $rbacsystem = $DIC['rbacsystem'];
211 
212  $access = $rbacsystem->checkAccessOfUser(
213  $a_user_id,
214  'read,visible',
216  );
217 
218  return $access;
219  }
const SYSTEM_FOLDER_ID
Definition: constants.php:35
global $DIC
Definition: shib_login.php:22

◆ debug()

static ilSessionControl::debug ( string  $a_debug_log_message)
staticprivate

logs the given debug message in

Parameters
string$a_debug_log_message

Definition at line 226 of file class.ilSessionControl.php.

References $DIC.

226  : void
227  {
228  global $DIC;
229 
230  $logger = $DIC->logger()->auth();
231 
232  $logger->debug($a_debug_log_message);
233  }
global $DIC
Definition: shib_login.php:22

◆ getExistingSessionCount()

static ilSessionControl::getExistingSessionCount ( array  $a_types)
static

returns number of valid sessions relating to given session types

Definition at line 125 of file class.ilSessionControl.php.

References $DIC, $ilDB, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilSessionStatisticsGUI\renderCurrentBasics().

125  : int
126  {
127  global $DIC;
128 
129  $ilDB = $DIC['ilDB'];
130 
131  $ts = time();
132 
133  $query = "SELECT count(session_id) AS num_sessions FROM usr_session " .
134  "WHERE expires > %s " .
135  "AND " . $ilDB->in('type', $a_types, false, 'integer');
136 
137  $res = $ilDB->queryF($query, array('integer'), array($ts));
138  return (int) $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)->num_sessions;
139  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22
+ Here is the caller graph for this function:

◆ getSettingFields()

static ilSessionControl::getSettingFields ( )
static

returns the array of setting fields

Returns
array setting_fields

Definition at line 240 of file class.ilSessionControl.php.

240  : array
241  {
242  return self::$setting_fields;
243  }

◆ handleLoginEvent()

static ilSessionControl::handleLoginEvent ( string  $a_login,
ilAuthSession  $auth_session 
)
static

when current session is allowed to be created it marks it with type regarding to the sessions user context.

when session is not allowed to be created it will be destroyed.

Definition at line 81 of file class.ilSessionControl.php.

References $DIC, $ilSetting, $user_id, ilObjUser\_lookupId(), ANONYMOUS_USER_ID, and ilSession\set().

Referenced by ilAuthFrontend\handleAuthenticationSuccess().

81  : bool
82  {
83  global $DIC;
84 
85  $ilSetting = $DIC['ilSetting'];
86 
87  $user_id = ilObjUser::_lookupId($a_login);
88 
89  // we need the session type for the session statistics
90  // regardless of the current session handling type
91  switch (true) {
92  case isset($_ENV['SHELL']):
93  $type = self::SESSION_TYPE_SYSTEM;
94  break;
95 
96  case $user_id === ANONYMOUS_USER_ID:
97  $type = self::SESSION_TYPE_ANONYM;
98  break;
99 
100  case self::checkAdministrationPermission($user_id):
101  $type = self::SESSION_TYPE_ADMIN;
102  break;
103 
104  default:
105  $type = self::SESSION_TYPE_USER;
106  break;
107  }
108 
109  ilSession::set(self::SESSION_TYPE_KEY, $type);
110  self::debug(__METHOD__ . " --> update sessions type to (" . $type . ")");
111 
112  return true;
113  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
static _lookupId($a_user_str)
global $DIC
Definition: shib_login.php:22
global $ilSetting
Definition: privfeed.php:31
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleLogoutEvent()

static ilSessionControl::handleLogoutEvent ( )
static

reset sessions type to unknown

Definition at line 118 of file class.ilSessionControl.php.

118  : void
119  {
120  }

◆ isValidSession()

static ilSessionControl::isValidSession ( string  $a_sid)
staticprivate

checks if session exists for given id and if it is still valid

Returns
boolean session_valid

Definition at line 147 of file class.ilSessionControl.php.

References $DIC, $ilDB, and $res.

147  : bool
148  {
149  global $DIC;
150 
151  $ilDB = $DIC['ilDB'];
152 
153  $query = "SELECT session_id, expires FROM usr_session " .
154  "WHERE session_id = %s";
155 
156  $res = $ilDB->queryF($query, array('text'), array($a_sid));
157 
158  $ts = time();
159 
160  $sessions = array();
161 
162  while ($row = $ilDB->fetchAssoc($res)) {
163  if ($row['expires'] > $ts) {
164  self::debug(__METHOD__ . ' --> Found a valid session with id (' . $a_sid . ')');
165  $sessions[] = $row;
166  } else {
167  self::debug(__METHOD__ . ' --> Found an expired session with id (' . $a_sid . ')');
168  }
169  }
170 
171  if (count($sessions) === 1) {
172  self::debug(__METHOD__ . ' --> Exact one valid session found for session id (' . $a_sid . ')');
173 
174  return true;
175  }
176 
177  if (count($sessions) > 1) {
178  self::debug(__METHOD__ . ' --> Strange!!! More than one sessions found for given session id! (' . $a_sid . ')');
179  } else {
180  self::debug(__METHOD__ . ' --> No valid session found for session id (' . $a_sid . ')');
181  }
182 
183  return false;
184  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:22

◆ removeSessionCookie()

static ilSessionControl::removeSessionCookie ( )
staticprivate

removes a session cookie, so it is not sent by browser anymore

Definition at line 189 of file class.ilSessionControl.php.

References ilUtil\setCookie().

189  : void
190  {
191  ilUtil::setCookie(session_name(), 'deleted', true, true);
192  self::debug('Session cookie has been removed');
193  }
static setCookie(string $a_cookie_name, string $a_cookie_value='', bool $a_also_set_super_global=true, bool $a_set_cookie_invalid=false)
+ Here is the call graph for this function:

Field Documentation

◆ $session_types_controlled

array ilSessionControl::$session_types_controlled
static
Initial value:
= array(
self::SESSION_TYPE_USER,
self::SESSION_TYPE_ANONYM
)

Definition at line 59 of file class.ilSessionControl.php.

Referenced by ilSessionStatistics\getNumberOfActiveRawSessions(), ilSessionStatistics\getRawData(), ilSession\lookupExpireTime(), and ilSessionStatisticsGUI\renderCurrentBasics().

◆ $session_types_not_controlled

array ilSessionControl::$session_types_not_controlled
staticprivate
Initial value:
= array(
self::SESSION_TYPE_UNKNOWN,
self::SESSION_TYPE_SYSTEM,
self::SESSION_TYPE_ADMIN
)

all session types that will be involved when count of sessions will be determined or when idleing sessions will be destroyed

all session types that will be ignored when count of sessions will be determined or when idleing sessions will be destroyed

Definition at line 70 of file class.ilSessionControl.php.

◆ $setting_fields

array ilSessionControl::$setting_fields
staticprivate
Initial value:
= array(
'session_allow_client_maintenance',
)

all fieldnames that are saved in settings table

Definition at line 38 of file class.ilSessionControl.php.

◆ DEFAULT_ALLOW_CLIENT_MAINTENANCE

const ilSessionControl::DEFAULT_ALLOW_CLIENT_MAINTENANCE = 1

◆ DEFAULT_MIN_IDLE

const ilSessionControl::DEFAULT_MIN_IDLE = 15

default value for settings that have not been defined in setup or administration yet

Definition at line 30 of file class.ilSessionControl.php.

Referenced by ilObjSCORMInitData\getIliasScormVars(), and ilSCORM13PlayerGUI\getPlayer().

◆ SESSION_TYPE_ADMIN

const ilSessionControl::SESSION_TYPE_ADMIN = 2
private

Definition at line 48 of file class.ilSessionControl.php.

◆ SESSION_TYPE_ANONYM

const ilSessionControl::SESSION_TYPE_ANONYM = 4
private

Definition at line 50 of file class.ilSessionControl.php.

◆ SESSION_TYPE_KEY

const ilSessionControl::SESSION_TYPE_KEY = "SessionType"
private

Definition at line 52 of file class.ilSessionControl.php.

◆ SESSION_TYPE_SYSTEM

const ilSessionControl::SESSION_TYPE_SYSTEM = 1
private

Definition at line 47 of file class.ilSessionControl.php.

◆ SESSION_TYPE_UNKNOWN

const ilSessionControl::SESSION_TYPE_UNKNOWN = 0
private

session types from which one is assigned to each session

Definition at line 46 of file class.ilSessionControl.php.

◆ SESSION_TYPE_USER

const ilSessionControl::SESSION_TYPE_USER = 3
private

Definition at line 49 of file class.ilSessionControl.php.


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