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
22
24use ILIAS\Export\ExportHandler\Factory as ilExportHandler;
29
31{
32 public const NAMESPACE = "export";
33 public const DOWNLOAD = 'download';
34
35 protected ilExportHandler $export_handler;
36
37
38 public function __construct()
39 {
40 $this->export_handler = new ilExportHandler();
41 }
42
43 public function getNamespace(): string
44 {
45 return self::NAMESPACE;
46 }
47
48 public function handle(Request $request, Context $context, Factory $response_factory): Response
49 {
50 $ref_id = $request->getReferenceId();
51 if (is_null($request->getReferenceId())) {
52 return $response_factory->can($context->ctrl()->getLinkTargetByClass(ilDashboardGUI::class));
53 }
54 $operation = $request->getAdditionalParameters()[0] ?? "";
55 $object_id = $ref_id->toObjectId();
56 $access_granted = false;
57 $pa_possible = false;
58 $key = $this->export_handler->publicAccess()->repository()->key()->handler()->withObjectId($object_id);
59 $element = $this->export_handler->publicAccess()->repository()->handler()->getElement($key);
60 $export_option = is_null($element)
61 ? null
62 : $this->export_handler->consumer()->exportOption()->exportOptionWithId($element->getValues()->getExportOptionId());
63 if ($context->isUserLoggedIn() and $context->checkPermission("read", $ref_id->toInt())) {
64 $access_granted = true;
65 }
66 if (
67 $context->getUserId() === ANONYMOUS_USER_ID and
68 $context->isPublicSectionActive() and
69 $context->checkPermission('read', $ref_id->toInt())
70 ) {
71 $access_granted = true;
72 }
73 if (
74 is_null($element) or
75 is_null($export_option) or
76 !$export_option->isPublicAccessPossible() or
77 !$access_granted or
78 $operation !== self::DOWNLOAD
79 ) {
80 return $response_factory->can($context->ctrl()->getLinkTargetByClass(ilDashboardGUI::class));
81 }
82 $export_option->onDownloadWithLink(
83 $ref_id,
84 $this->export_handler->consumer()->file()->identifier()->handler()->withIdentifier($element->getValues()->getIdentification())
85 );
86 return $response_factory->cannot();
87 }
88}
handle(Request $request, Context $context, Factory $response_factory)
@ilCtrl_Calls ilDashboardGUI: ILIAS\User\Profile\PersonalProfileGUI @ilCtrl_Calls ilDashboardGUI: ilO...
const ANONYMOUS_USER_ID
Definition: constants.php:27
$ref_id
Definition: ltiauth.php:66
$context
Definition: webdav.php:31