19 declare(strict_types=1);
42 public function handle(): ResponseInterface
45 $this->
http->wrapper()->post()->retrieve(
47 $this->
refinery->kindlyTo()->string()
51 $this->
logger->debug(
'Session reminder call for session id hash: ' . $hash);
58 $concat = $this->db->concat(
65 $res = $this->db->queryF(
66 'SELECT usess.expires, usess.user_id, usess.data ' .
67 'FROM usr_session usess ' .
68 'INNER JOIN object_data od ON od.obj_id = usess.user_id ' .
69 "WHERE SHA2($concat, 256) = %s",
74 $num = $this->db->numRows(
$res);
77 $response[
'message'] =
'ILIAS could not determine the session data.';
82 $response[
'message'] =
'The determined session data is not unique.';
88 $response[
'message'] =
'ILIAS could not fetch the session data or the corresponding user is no more authenticated.';
92 $expiration_time =
$data[
'expires'];
93 if ($expiration_time ===
null) {
94 $response[
'message'] =
'ILIAS could not determine the expiration time from the session data.';
97 $expiration_time = (
int)
$data[
'expires'];
100 $response[
'message'] =
'The session is already expired. The client should have received a remind command before.';
107 $response[
'message'] =
'ILIAS could not fetch the session data or the corresponding user is no more authenticated.';
116 $reminder_time = $expiration_time - ($session_reminder->getEffectiveLeadTime() * 60);
117 if ($reminder_time > $this->clock->now()->getTimestamp()) {
119 $response[
'message'] =
'Lead time not reached, yet. Current time: ' .
120 date(
'Y-m-d H:i:s') .
', Reminder time: ' . date(
'Y-m-d H:i:s', $reminder_time);
125 switch ($ilUser->getTimeFormat()) {
127 $formatted_expiration_time = $dateTime->get(
IL_CAL_FKT_DATE,
'g:ia', $ilUser->getTimeZone());
132 $formatted_expiration_time = $dateTime->get(
IL_CAL_FKT_DATE,
'H:i', $ilUser->getTimeZone());
137 'extend_url' =>
'./ilias.php?baseClass=' . ilDashboardGUI::class,
138 'txt' => str_replace(
142 $this->
lng->txt(
'session_reminder_alert'),
144 $formatted_expiration_time,
160 return $this->
http->response()
161 ->withHeader(ResponseHeader::CONTENT_TYPE,
'application/json')
162 ->withBody(Streams::ofString(json_encode(
$data, JSON_THROW_ON_ERROR)));
167 return $expirationTime < $this->clock->now()->getTimestamp();
174 isset($data[
'user_id']) &&
175 (
int) $data[
'user_id'] > 0 &&
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) ...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
__construct(private GlobalHttpState $http, private Refinery $refinery, private ilLanguage $lng, private ilDBInterface $db, private ilIniFile $client_ini, private ilLogger $logger, private ClockInterface $clock, private ilSetting $settings)
isAuthenticatedUsrSession(?array $data)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id