ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ConfigurableLogoutTarget.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ilLink;
24use ilObject;
25use ilSetting;
28use InvalidArgumentException;
31
33{
34 public const string INTERNAL_RESSOURCE = 'internal_ressource';
35 public const string EXTERNAL_RESSOURCE = 'external_ressource';
36
37 public function __construct(
38 private readonly ilCtrlInterface $ctrl,
39 private readonly ilSetting $settings,
40 private readonly ilAccessHandler $access,
41 private readonly string $http_path = ILIAS_HTTP_PATH,
42 ) {
43 }
44
45 public function asURI(): URI
46 {
47 switch ($this->settings->get('logout_behaviour', '')) {
48 case LogoutDestinations::LOGIN_SCREEN->value:
49 return LogoutDestinations::LOGIN_SCREEN->asURI($this->ctrl, $this->http_path);
50
52 $ref_id = (int) $this->settings->get('logout_behaviour_ref_id', '0');
53 if ($this->isValidInternalResource($ref_id)) {
55 }
56
57 break;
58
60 $url = $this->settings->get('logout_behaviour_url', '');
61 if ($url && $this->isValidExternalResource($url)) {
62 return new URI($url);
63 }
64 break;
65
66 case LogoutDestinations::LOGOUT_SCREEN->value:
67 default:
68 break;
69 }
70
71 return LogoutDestinations::LOGOUT_SCREEN->asURI($this->ctrl, $this->http_path);
72 }
73
74 public function isValidInternalResource(int $ref_id): bool
75 {
76 return $this->isInRepository($ref_id) && $this->isAnonymousAccessible($ref_id);
77 }
78
79 public function isInRepository(int $ref_id): bool
80 {
82 }
83
84 public function isAnonymousAccessible(int $ref_id): bool
85 {
86 return $this->access->checkAccessOfUser(ANONYMOUS_USER_ID, 'read', '', $ref_id);
87 }
88
89 public function isValidExternalResource(string $url): bool
90 {
91 try {
92 $uri = new URI($url);
93 } catch (InvalidArgumentException) {
94 return false;
95 }
96
97 return filter_var($url, FILTER_VALIDATE_URL) !== false;
98 }
99}
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
__construct(private readonly ilCtrlInterface $ctrl, private readonly ilSetting $settings, private readonly ilAccessHandler $access, private readonly string $http_path=ILIAS_HTTP_PATH,)
Class ilObject Basic functions for all objects.
static _isInTrash(int $ref_id)
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
ILIAS Setting Class.
const ANONYMOUS_USER_ID
Definition: constants.php:27
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:66
$url
Definition: shib_logout.php:68