ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilFileStaticURLHandler.php
Go to the documentation of this file.
1<?php
2
28
33{
34 public const DOWNLOAD = 'download';
35 public const VERSIONS = 'versions';
36 public const EDIT = 'edit';
37 public const VIEW = 'view';
39
40 public function __construct()
41 {
42 global $DIC;
44 $this->capabilities = new CapabilityBuilder(
46 $DIC->access(),
47 $DIC->ctrl(),
48 new ActionDBRepository($DIC->database()),
49 $DIC->http(),
50 $DIC['static_url.uri_builder']
51 );
52 }
53
54 public function getNamespace(): string
55 {
56 return 'file';
57 }
58
59 public function handle(Request $request, Context $context, Factory $response_factory): Response
60 {
61 $reference_id = $request->getReferenceId();
62 if ($reference_id === null) {
63 return $response_factory->cannot();
64 }
65
66 // special case for shared workspace
67 $additional_params = $request->getAdditionalParameters()[0] ?? null;
68 if ($additional_params === '_wsp') {
69 ilObjectGUI::_gotoSharedWorkspaceNode($reference_id->toInt());
70 return $response_factory->loginFirst();
71 }
72
73 $capability_context = new \ILIAS\File\Capabilities\Context(
74 $reference_id->toObjectId()->toInt(),
75 $reference_id->toInt(),
76 \ILIAS\File\Capabilities\Context::CONTEXT_REPO
77 );
78
79 $capabilities = $this->capabilities->get($capability_context);
80
81 $capability = match ($additional_params) {
82 self::DOWNLOAD => $capabilities->get(Capabilities::DOWNLOAD),
83 self::VERSIONS => $capabilities->get(Capabilities::MANAGE_VERSIONS),
84 self::EDIT => $capabilities->get(Capabilities::EDIT_EXTERNAL),
85 self::VIEW => $capabilities->get(Capabilities::VIEW_EXTERNAL),
86 default => $capabilities->get(Capabilities::INFO_PAGE),
87 };
88
89 if (!$capability->isUnlocked() || $capability->getUri() === null) {
90 return $response_factory->loginFirst();
91 }
92
93 $uri = $capability->getUri();
94
95 return $response_factory->can($uri->getPath() . '?' . $uri->getQuery());
96 }
97
98}
readonly CapabilityBuilder $capabilities
handle(Request $request, Context $context, Factory $response_factory)
static _gotoSharedWorkspaceNode(int $wsp_id)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $DIC
Definition: shib_login.php:26
$context
Definition: webdav.php:31