ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
StaticUrlHandler.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
31
32class StaticUrlHandler extends BaseHandler implements Handler
33{
34 public const string NAMESPACE = 'contact';
35
36 public function getNamespace(): string
37 {
38 return self::NAMESPACE;
39 }
40
41 public function handle(Request $request, Context $context, Factory $response_factory): Response
42 {
43 if (!$context->isUserLoggedIn()) {
44 return $response_factory->loginFirst();
45 }
46
47 if (!\ilBuddySystem::getInstance()->isEnabled()) {
48 return $response_factory->cannot();
49 }
50
51 $params = implode('/', $request->getAdditionalParameters() ?? []);
52 $path = parse_url($params, PHP_URL_PATH);
53
54 return match ($path) {
55 'approve' => $response_factory->can($this->buildProfileUrl(
56 $context->ctrl(),
57 $request->getReferenceId(),
58 'approveContactRequest'
59 )),
60 'ignore' => $response_factory->can($this->buildProfileUrl(
61 $context->ctrl(),
62 $request->getReferenceId(),
63 'ignoreContactRequest'
64 )),
65 default => $response_factory->cannot(),
66 };
67 }
68
69 private function buildProfileUrl(
70 \ilCtrl $ctrl,
71 ?ReferenceId $target_user_id,
72 string $cmd
73 ): string {
74 if ($target_user_id === null) {
75 return $ctrl->getLinkTargetByClass(
76 [\ilDashboardGUI::class],
77 'jumpToProfile'
78 );
79 }
80
81 $ctrl->setParameterByClass(PublicProfileGUI::class, 'user_id', $target_user_id->toInt());
82
83 return $ctrl->getLinkTargetByClass([\ilPublicProfileBaseClassGUI::class, PublicProfileGUI::class], $cmd);
84 }
85}
buildProfileUrl(\ilCtrl $ctrl, ?ReferenceId $target_user_id, string $cmd)
handle(Request $request, Context $context, Factory $response_factory)
can(string $uri_path, bool $shift=false)
Definition: Factory.php:47
GUI class for public user profile presentation.
Class ilCtrl provides processing control methods.
getLinkTargetByClass( $a_class, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false, bool $has_xml_style=false)
@inheritDoc
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
$path
Definition: ltiservices.php:30
if(!file_exists('../ilias.ini.php'))