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