ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
StaticURLHandler.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\User;
22
31
32class StaticURLHandler extends BaseHandler implements Handler
33{
34 public const NAMESPACE = 'user';
35 public const CHANGE_EMAIL_OPERATIONS = 'email';
36
37 public function getNamespace(): string
38 {
39 return self::NAMESPACE;
40 }
41
42 public function handle(
43 Request $request,
45 Factory $response_factory
46 ): Response {
47 $additional_params = $request->getAdditionalParameters();
48
49 $uri = match ($additional_params[0] ?? 'default') {
50 self::CHANGE_EMAIL_OPERATIONS => $context->isUserLoggedIn()
51 ? $this->buildChangeEmailUrl($additional_params[1], $context->ctrl())
52 : $this->getLoginUrl($request, $context),
53 default => $context->ctrl()->getLinkTargetByClass([\ilDashboardGUI::class], 'jumpToProfile'),
54 };
55
56 return $response_factory->can($uri);
57 }
58
59 private function buildChangeEmailUrl(string $token, \ilCtrl $ctrl): string
60 {
61 $ctrl->setParameterByClass(PersonalProfileGUI::class, 'token', $token);
62 $link = $ctrl->getLinkTargetByClass([\ilDashboardGUI::class, PersonalProfileGUI::class], PersonalProfileGUI::CHANGE_EMAIL_CMD);
63 $ctrl->clearParameterByClass(PersonalProfileGUI::class, 'token');
64 return $link;
65 }
66
67 private function getLoginUrl(
68 Request $request,
70 ): string {
71 $target = (new StandardURIBuilder(ILIAS_HTTP_PATH, false))->buildTarget(
72 $request->getNamespace(),
73 $request->getReferenceId(),
74 $request->getAdditionalParameters()
75 );
76
77 return '/login.php?target='
78 . str_replace('/', '_', rtrim($target, '/'))
79 . '&cmd=force_login&lang=' . $context->getUserLanguage();
80
81 }
82}
handle(Request $request, Context $context, Factory $response_factory)
buildChangeEmailUrl(string $token, \ilCtrl $ctrl)
getLoginUrl(Request $request, Context $context)
Class ilCtrl provides processing control methods.
clearParameterByClass(string $a_class, string $a_parameter)
@inheritDoc
setParameterByClass(string $a_class, string $a_parameter, $a_value)
@inheritDoc
getLinkTargetByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: UserEvent.php:21
$context
Definition: webdav.php:31
$token
Definition: xapitoken.php:70