ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilUserRequestTargetAdjustment.php
Go to the documentation of this file.
1<?php declare(strict_types=1);
2
3/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5use Psr\Http\Message\ServerRequestInterface;
6
11{
13 protected $user;
14
16 protected $ctrl;
17
19 protected $request;
20
22 protected $cases = array();
23
29 public function __construct(ilObjUser $user, ilCtrl $ctrl, ServerRequestInterface $request)
30 {
31 $this->user = $user;
32 $this->ctrl = $ctrl;
33 $this->request = $request;
34
35 $this->initCases();
36 }
37
41 protected function initCases() : void
42 {
43 $this->cases = array(
44 new ilTermsOfServiceRequestTargetAdjustmentCase($this->user, $this->ctrl, $this->request),
45 new ilUserProfileIncompleteRequestTargetAdjustmentCase($this->user, $this->ctrl, $this->request),
46 new ilUserPasswordResetRequestTargetAdjustmentCase($this->user, $this->ctrl, $this->request)
47 );
48 }
49
53 protected function storeRequest() : void
54 {
55 if (!ilSession::get('orig_request_target')) {
56 //#16324 don't use the complete REQUEST_URI
57 $url = substr($_SERVER['REQUEST_URI'], (strrpos($_SERVER['REQUEST_URI'], '/') + 1));
58
59 ilSession::set('orig_request_target', $url);
60 }
61 }
62
66 public function adjust() : bool
67 {
68 if (defined('IL_CERT_SSO')) {
69 $GLOBALS['DIC']->logger()->init()->debug('CERT SSO request. No adjustment.');
70 return false;
71 } elseif (!ilContext::supportsRedirects()) {
72 $GLOBALS['DIC']->logger()->init()->debug('Context does not support redirects. No adjustment.');
73 return false;
74 } elseif ($this->ctrl->isAsynch()) {
75 $GLOBALS['DIC']->logger()->init()->debug('Async request. No adjustment.');
76 return false;
77 } elseif (in_array(basename($_SERVER['PHP_SELF']), array('logout.php'))) {
78 $GLOBALS['DIC']->logger()->init()->debug('Logout request. No adjustment.');
79 return false;
80 } elseif (!$this->user->getId() || $this->user->isAnonymous()) {
81 $GLOBALS['DIC']->logger()->init()->debug('Anonymous request. No adjustment.');
82 return false;
83 } elseif (ilSession::get(__CLASS__ . '_passed')) {
84 $GLOBALS['DIC']->logger()->init()->debug(__CLASS__ . ' already passed in the current user session.');
85 return false;
86 }
87
88 foreach ($this->cases as $case) {
89 if ($case->isInFulfillment()) {
90 $GLOBALS['DIC']->logger()->init()->debug('Case is in fulfillment:' . get_class($case));
91 return false;
92 }
93
94 if ($case->shouldAdjustRequest()) {
95 $GLOBALS['DIC']->logger()->init()->debug('Case required adjustment:' . get_class($case));
96 if ($case->shouldStoreRequestTarget()) {
97 $this->storeRequest();
98 }
99 $case->adjust();
100 return true;
101 }
102 }
103
104 ilSession::set(__CLASS__ . '_passed', 1);
105 return false;
106 }
107}
user()
Definition: user.php:4
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
An exception for terminatinating execution or to throw for unit testing.
static supportsRedirects()
Are redirects supported?
This class provides processing control methods.
static set($a_var, $a_val)
Set a value.
static get($a_var)
Get a value.
Class ilUserProfileIncompleteAndPasswordResetRequestTargetAdjustmentCase.
Class ilUserAccountMaintenanceEnforcement.
__construct(ilObjUser $user, ilCtrl $ctrl, ServerRequestInterface $request)
$url
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10