19 declare(strict_types=1);
53 $this->clock = $utcClock;
56 public function handle(): ResponseInterface
59 $this->
http->wrapper()->post()->retrieve(
61 $this->
refinery->kindlyTo()->string()
65 $this->
logger->debug(
'Session reminder call for session id hash: ' . $sessionIdHash);
72 $res = $this->db->queryF(
73 'SELECT expires, user_id, data FROM usr_session WHERE MD5(session_id) = %s',
78 $num = $this->db->numRows(
$res);
81 $response[
'message'] =
'ILIAS could not determine the session data.';
86 $response[
'message'] =
'The determined session data is not unique.';
92 $response[
'message'] =
'ILIAS could not fetch the session data or the corresponding user is no more authenticated.';
96 $expirationTime = (
int)
$data[
'expires'];
97 if (null === $expirationTime) {
98 $response[
'message'] =
'ILIAS could not determine the expiration time from the session data.';
103 $response[
'message'] =
'The session is already expired. The client should have received a remind command before.';
110 $response[
'message'] =
'ILIAS could not fetch the session data or the corresponding user is no more authenticated.';
114 $reminderTime = $expirationTime - ((
int) max(
116 (
float)
$ilUser->getPref(
'session_reminder_lead_time')
118 if ($reminderTime > $this->clock->now()->getTimestamp()) {
120 $response[
'message'] =
'Lead time not reached, yet. Current time: ' .
121 date(
'Y-m-d H:i:s') .
', Reminder time: ' . date(
'Y-m-d H:i:s', $reminderTime);
126 switch (
$ilUser->getTimeFormat()) {
138 'extend_url' =>
'./ilias.php?baseClass=ilDashboardGUI',
139 'txt' => str_replace(
143 $this->
lng->txt(
'session_reminder_alert'),
145 $formatted_expiration_time,
161 return $this->
http->response()
162 ->withHeader(ResponseHeader::CONTENT_TYPE,
'application/json')
163 ->withBody(Streams::ofString(json_encode(
$data, JSON_THROW_ON_ERROR)));
168 return $expirationTime < $this->clock->now()->getTimestamp();
175 isset($data[
'user_id']) &&
176 (
int) $data[
'user_id'] > 0 &&
Interface GlobalHttpState.
static enableWebAccessWithoutSession(bool $enable_web_access_without_session)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
isSessionAlreadyExpired(int $expirationTime)
static secondsToString(int $seconds, bool $force_with_seconds=false, ?ilLanguage $a_lng=null)
converts seconds to string: Long: 7 days 4 hour(s) ...
static http()
Fetches the global http state from ILIAS.
isAuthenticatedUsrSession(?array $data)
__construct(GlobalHttpState $http, Refinery $refinery, ilLanguage $lng, ilDBInterface $db, ilIniFile $clientIni, ilLogger $logger, ClockInterface $utcClock)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...