ILIAS  trunk Revision v13.0_alpha-52-g21c366bbdd4
StaticUrlHandler.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\PermanentLink;
22
29
30class StaticURLHandler extends BaseHandler implements Handler
31{
32 public function getNamespace(): string
33 {
34 return 'blog';
35 }
36
37 public function handle(Request $request, Context $context, Factory $response_factory): Response
38 {
39 // For bootstrapping, DIC can't be in the constructor
40 global $DIC;
41
42 $blog_service = $DIC->blog()->internal();
43 $ctrl = $blog_service->gui()->ctrl();
44 $access = $blog_service->domain()->access();
45 $uri = null;
46 $blog_domain = $blog_service->domain();
47
48 $id = $request->getReferenceId()?->toInt() ?? 0;
49 $additional_params = $request->getAdditionalParameters() ?? [];
50 $wsp = count($additional_params) > 0 &&
51 $additional_params[count($additional_params) - 1] === "wsp";
52 $posting_id = 0;
53 if (is_numeric($additional_params[0] ?? "")) {
54 $posting_id = (int) $additional_params[0];
55 }
56 $edit = false;
57 if ($posting_id > 0 && (($additional_params[1] ?? "") === "edit")) {
58 $edit = true;
59 }
60 if ($posting_id > 0) {
61 $ctrl->setParameterByClass(\ilBlogPostingGUI::class, "blpg", $posting_id);
62 }
63 if ($wsp) {
64 $ctrl->setParameterByClass(\ilObjBlogGUI::class, "wsp_id", $id);
65 if ($posting_id > 0) {
66 if ($edit) {
67 $uri = $ctrl->getLinkTargetByClass([
68 \ilDashboardGUI::class,
69 \ilPersonalWorkspaceGUI::class,
70 \ilObjBlogGUI::class,
71 \ilBlogPostingGUI::class,
72 ], "edit");
73 } else {
74 $uri = $ctrl->getLinkTargetByClass([
75 \ilSharedResourceGUI::class,
76 \ilObjBlogGUI::class,
77 \ilBlogPostingGUI::class,
78 ], "previewFullscreen");
79 }
80 } else {
81 $uri = $ctrl->getLinkTargetByClass([
82 \ilSharedResourceGUI::class,
83 \ilObjBlogGUI::class
84 ], "preview");
85 }
86 } else {
87 $ctrl->setParameterByClass(\ilRepositoryGUI::class, "ref_id", $id);
88 if ($posting_id > 0) {
89 if ($edit && $access->checkAccess("write", "", $id)) {
90 $uri = $ctrl->getLinkTargetByClass([
91 \ilRepositoryGUI::class,
92 \ilObjBlogGUI::class,
93 \ilBlogPostingGUI::class,
94 ], "edit");
95 } elseif ($access->checkAccess("read", "", $id)) {
96 $uri = $ctrl->getLinkTargetByClass([
97 \ilRepositoryGUI::class,
98 \ilObjBlogGUI::class,
99 \ilBlogPostingGUI::class,
100 ], "previewFullscreen");
101 }
102 } else {
103 if ($access->checkAccess("read", "", $id)) {
104 $uri = $ctrl->getLinkTargetByClass([
105 \ilRepositoryGUI::class,
106 \ilObjBlogGUI::class
107 ], "preview");
108 }
109 }
110
111 if ($uri === "" &&
112 $access->checkAccess("visible", "", $id)) {
113 $uri = $ctrl->getLinkTargetByClass([
114 \ilRepositoryGUI::class,
115 \ilObjBlogGUI::class
116 ], "infoScreen");
117 }
118 }
119 if (is_null($uri)) {
120 if ($blog_domain->user()->isAnonymous() || $blog_domain->user()->getId() == 0) {
121 return $response_factory->loginFirst();
122 } else {
123 return $response_factory->cannot();
124 }
125 }
126 return $response_factory->can($uri);
127 }
128
129}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
loginFirst()
Convenience: the Handler cannot serve the target with the current permissions.
Definition: Factory.php:74
can(string $uri_path, bool $shift=false)
The Handler successfully resolved the target.
Definition: Factory.php:88
cannot()
The Handler cannot process the given Request at all, e.g.
Definition: Factory.php:47
$request
@ilCtrl_Calls ilObjLearningSequenceContentGUI: ilObjLearningSequenceConditionsGUI
Definition: ltiauth.php:39
global $DIC
Definition: shib_login.php:26