19 declare(strict_types=1);
55 $this->clock = $utcClock;
58 public function handle(): ResponseInterface
61 $this->
http->wrapper()->post()->retrieve(
63 $this->
refinery->kindlyTo()->string()
67 $this->
logger->debug(
'Session reminder call for session id hash: ' . $sessionIdHash);
74 $res = $this->db->queryF(
75 'SELECT expires, user_id, data FROM usr_session WHERE MD5(session_id) = %s',
80 $num = $this->db->numRows(
$res);
83 $response[
'message'] =
'ILIAS could not determine the session data.';
88 $response[
'message'] =
'The determined session data is not unique.';
94 $response[
'message'] =
'ILIAS could not fetch the session data or the corresponding user is no more authenticated.';
98 $expiration_time =
$data[
'expires'];
99 if (null === $expiration_time) {
100 $response[
'message'] =
'ILIAS could not determine the expiration time from the session data.';
103 $expiration_time = (
int) $expiration_time;
106 $response[
'message'] =
'The session is already expired. The client should have received a remind command before.';
113 $response[
'message'] =
'ILIAS could not fetch the session data or the corresponding user is no more authenticated.';
122 $reminder_time = $expiration_time - ($session_reminder->getEffectiveLeadTime() * 60);
123 if ($reminder_time > $this->clock->now()->getTimestamp()) {
125 $response[
'message'] =
'Lead time not reached, yet. Current time: ' .
126 date(
'Y-m-d H:i:s') .
', Reminder time: ' . date(
'Y-m-d H:i:s', $reminder_time);
131 switch ($ilUser->getTimeFormat()) {
133 $formatted_expiration_time = $dateTime->get(
IL_CAL_FKT_DATE,
'g:ia', $ilUser->getTimeZone());
138 $formatted_expiration_time = $dateTime->get(
IL_CAL_FKT_DATE,
'H:i', $ilUser->getTimeZone());
143 'extend_url' =>
'./ilias.php?baseClass=ilDashboardGUI',
144 'txt' => str_replace(
148 $this->
lng->txt(
'session_reminder_alert'),
150 $formatted_expiration_time,
166 return $this->
http->response()
167 ->withHeader(ResponseHeader::CONTENT_TYPE,
'application/json')
168 ->withBody(Streams::ofString(json_encode(
$data, JSON_THROW_ON_ERROR)));
173 return $expirationTime < $this->clock->now()->getTimestamp();
180 isset($data[
'user_id']) &&
181 (
int) $data[
'user_id'] > 0 &&
static enableWebAccessWithoutSession(bool $enable_web_access_without_session)
__construct(GlobalHttpState $http, Refinery $refinery, ilLanguage $lng, ilDBInterface $db, ilIniFile $clientIni, ilLogger $logger, ClockInterface $utcClock, private readonly ilSetting $settings)
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isAuthenticatedUsrSession(?array $data)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id