ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
class.ilSessionReminderGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 readonly class ilSessionReminderGUI
22 {
23  public function __construct(
24  private ilSessionReminder $session_reminder,
25  private ilGlobalTemplateInterface $page,
26  private ilLanguage $lng,
27  private ilLoggerFactory $logger_factory
28  ) {
29  }
30 
31  public function populatePage(): void
32  {
33  if (!$this->session_reminder->isActive()) {
34  return;
35  }
36 
37  $this->page->addJavaScript('assets/js/SessionReminder.min.js');
38 
39  $url = './sessioncheck.php?client_id=' . CLIENT_ID . '&lang=' . $this->lng->getLangKey();
40  $client_id = defined('CLIENT_ID') ? CLIENT_ID : '';
41  $hash = hash(
42  'sha256',
43  implode('', [
44  session_id(),
45  $this->session_reminder->getUser()->getId(),
46  $this->session_reminder->getUser()->getCreateDate()
47  ])
48  );
49  $log_level = $this->logger_factory->getSettings()->getLevelByComponent('auth');
50 
51  $javascript = <<<JS
52  il.SessionReminder.init({
53  url: "$url",
54  clientId: "$client_id",
55  hash: "$hash",
56  frequency: 60,
57  logLevel: $log_level
58  }, window, console);
59  il.SessionReminder.run();
60  JS;
61 
62  $this->page->addOnLoadCode($javascript);
63  }
64 }
$url
Definition: shib_logout.php:68
const CLIENT_ID
Definition: constants.php:41
__construct(Container $dic, ilPlugin $plugin)
global $lng
Definition: privfeed.php:31
$client_id
Definition: ltiauth.php:66