ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
StartUpSequenceDispatcher.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ilContext;
25use ilSession;
26use ilTermsOfServiceAcceptanceStartUpStep;
28use ilTermsOfServiceWithdrawalStartUpStep;
29use ILIAS\User\Profile\Prompt\StartUpStep as ProfilePromptStartUpStep;
30use SplQueue;
33
40{
41 private Container $dic;
43 private $sequence = [];
44
45 public function __construct(Container $dic)
46 {
47 $this->dic = $dic;
48 $this->initSequence();
49 }
50
51 protected function initSequence(): void
52 {
53 $this->sequence = new SplQueue();
54 $this->sequence->push(new StartUpStep(
55 $this->dic->ctrl(),
56 $this->dic['legalDocuments']
57 ));
58 $this->sequence->push(new ProfilePromptStartUpStep(
59 $this->dic->user(),
60 $this->dic->ctrl(),
61 $this->dic->database(),
62 $this->dic->language(),
63 $this->dic->http(),
64 $this->dic->refinery()
65 ));
66 $this->sequence->push(new ilForcedUserPasswordChangeStartUpStep(
67 $this->dic->user(),
68 $this->dic->ctrl(),
69 $this->dic->http()->request()
70 ));
71 }
72
73 protected function storeRequest(): void
74 {
75 if (!ilSession::get('orig_request_target')) {
76 //#16324 don't use the complete REQUEST_URI
77
78 $url = $_SERVER['REQUEST_URI'];
79 $short = strpos($url, StandardURIBuilder::SHORT);
80
81 if (preg_match('@/([^/]+\\.php[?/].*)$@', $url, $matches)) {
82 $url = $matches[1];
83 } elseif ($short !== false) {
84 $url = substr($url, $short + 1);
85 } else {
86 $url = substr($url, strrpos($url, '/') + 1);
87 }
88
89 ilSession::set('orig_request_target', $url);
90 }
91 }
92
96 public function dispatch(): bool
97 {
98 $this->dic->logger()->init()->debug('Started request interception checks ...');
99
100 if (defined('IL_CERT_SSO')) {
101 $this->dic->logger()->init()->debug('ApacheAuthentication request. No interception.');
102 return false;
103 } elseif (!ilContext::supportsRedirects()) {
104 $this->dic->logger()->init()->debug('Context does not support redirects. No interception.');
105 return false;
106 } elseif ($this->dic->ctrl()->isAsynch()) {
107 $this->dic->logger()->init()->debug('Async request. No interception.');
108 return false;
109 } elseif (in_array(basename($_SERVER['PHP_SELF']), array('logout.php'))) {
110 $this->dic->logger()->init()->debug('Logout request. No interception.');
111 return false;
112 } elseif (!$this->dic->user()->getId() || $this->dic->user()->isAnonymous()) {
113 $this->dic->logger()->init()->debug('Anonymous request. No interception.');
114 return false;
115 } elseif (ilSession::get(__CLASS__ . '_passed')) {
116 $this->dic->logger()->init()->debug(__CLASS__ . ' already passed in the current user session.');
117 return false;
118 }
119
120 $this->sequence->rewind();
121 while (!$this->sequence->isEmpty()) {
122 $step = $this->sequence->shift();
123
124 if ($step->isInFulfillment()) {
125 $this->dic->globalScreen()->tool()->context()->current()->addAdditionalData(
127 true
128 );
129
130 $this->dic->logger()->init()->debug('Step is in fulfillment:' . get_class($step));
131 return false;
132 }
133
134 if ($step->shouldInterceptRequest()) {
135 $this->dic->logger()->init()->debug('Step required adjustment:' . get_class($step));
136 if ($step->shouldStoreRequestTarget()) {
137 $this->storeRequest();
138 }
139 $step->execute();
140 return true;
141 }
142 }
143
144 ilSession::set(__CLASS__ . '_passed', 1);
145 return false;
146 }
147}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static supportsRedirects()
Are redirects supported?
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
$url
Definition: shib_logout.php:68