ILIAS  release_8 Revision v8.23
StartUpSequenceDispatcher.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
5 
7 
8 use ilContext;
10 use ilSession;
15 use SplQueue;
16 
23 {
24  private Container $dic;
26  private $sequence = [];
27 
28  public function __construct(Container $dic)
29  {
30  $this->dic = $dic;
31  $this->initSequence();
32  }
33 
34  protected function initSequence(): void
35  {
36  $this->sequence = new SplQueue();
37  $this->sequence->push(new ilTermsOfServiceWithdrawalStartUpStep(
38  $this->dic
39  ));
40  $this->sequence->push(new ilTermsOfServiceAcceptanceStartUpStep(
41  $this->dic
42  ));
43  $this->sequence->push(new ilUserProfileStartUpStep(
44  $this->dic->user(),
45  $this->dic->ctrl()
46  ));
47  $this->sequence->push(new ilForcedUserPasswordChangeStartUpStep(
48  $this->dic->user(),
49  $this->dic->ctrl(),
50  $this->dic->http()->request()
51  ));
52  }
53 
54  protected function storeRequest(): void
55  {
56  if (!ilSession::get('orig_request_target')) {
57  //#16324 don't use the complete REQUEST_URI
58  $url = substr($_SERVER['REQUEST_URI'], (strrpos($_SERVER['REQUEST_URI'], '/') + 1));
59 
60  ilSession::set('orig_request_target', $url);
61  }
62  }
63 
67  public function dispatch(): bool
68  {
69  $this->dic->logger()->init()->debug('Started request interception checks ...');
70 
71  if (defined('IL_CERT_SSO')) {
72  $this->dic->logger()->init()->debug('ApacheAuthentication request. No interception.');
73  return false;
74  } elseif (!ilContext::supportsRedirects()) {
75  $this->dic->logger()->init()->debug('Context does not support redirects. No interception.');
76  return false;
77  } elseif ($this->dic->ctrl()->isAsynch()) {
78  $this->dic->logger()->init()->debug('Async request. No interception.');
79  return false;
80  } elseif (in_array(basename($_SERVER['PHP_SELF']), array('logout.php'))) {
81  $this->dic->logger()->init()->debug('Logout request. No interception.');
82  return false;
83  } elseif (!$this->dic->user()->getId() || $this->dic->user()->isAnonymous()) {
84  $this->dic->logger()->init()->debug('Anonymous request. No interception.');
85  return false;
86  } elseif (ilSession::get(__CLASS__ . '_passed')) {
87  $this->dic->logger()->init()->debug(__CLASS__ . ' already passed in the current user session.');
88  return false;
89  }
90 
91  $this->sequence->rewind();
92  while (!$this->sequence->isEmpty()) {
93  $step = $this->sequence->shift();
94 
95  if ($step->isInFulfillment()) {
96  $this->dic->logger()->init()->debug('Step is in fulfillment:' . get_class($step));
97  return false;
98  }
99 
100  if ($step->shouldInterceptRequest()) {
101  $this->dic->logger()->init()->debug('Step required adjustment:' . get_class($step));
102  if ($step->shouldStoreRequestTarget()) {
103  $this->storeRequest();
104  }
105  $step->execute();
106  return true;
107  }
108  }
109 
110  ilSession::set(__CLASS__ . '_passed', 1);
111  return false;
112  }
113 }
static get(string $a_var)
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:31
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$url
static set(string $a_var, $a_val)
Set a value.
static supportsRedirects()
Are redirects supported?