ILIAS  trunk Revision v12.0_alpha-1338-g8f7e531aa3c
ilFileStaticURLHandler Class Reference
+ Inheritance diagram for ilFileStaticURLHandler:
+ Collaboration diagram for ilFileStaticURLHandler:

Public Member Functions

 __construct ()
 
 getNamespace ()
 
 handle (Request $request, Context $context, Factory $response_factory)
 
- Public Member Functions inherited from ILIAS\StaticURL\Handler\BaseHandler
 __construct ()
 
 canHandle (Request $request)
 
- Public Member Functions inherited from ILIAS\StaticURL\Handler\Handler
 __construct ()
 
 getNamespace ()
 
 canHandle (Request $request)
 
 handle (Request $request, Context $context, Factory $response_factory)
 

Data Fields

const DOWNLOAD = 'download'
 
const VERSIONS = 'versions'
 
const EDIT = 'edit'
 
const VIEW = 'view'
 

Private Attributes

readonly CapabilityBuilder $capabilities
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilFileStaticURLHandler::__construct ( )

Reimplemented from ILIAS\StaticURL\Handler\BaseHandler.

Definition at line 40 of file class.ilFileStaticURLHandler.php.

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 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26

References $DIC, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ getNamespace()

ilFileStaticURLHandler::getNamespace ( )

Implements ILIAS\StaticURL\Handler\Handler.

Definition at line 54 of file class.ilFileStaticURLHandler.php.

54 : string
55 {
56 return 'file';
57 }

◆ handle()

ilFileStaticURLHandler::handle ( Request  $request,
Context  $context,
Factory  $response_factory 
)

Implements ILIAS\StaticURL\Handler\Handler.

Definition at line 59 of file class.ilFileStaticURLHandler.php.

59 : 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 // special case for cloned objects
82 $forced = null;
83 $referrer = $context->http()->request()->getServerParams()['HTTP_REFERER'] ?? '';
84 if (str_contains(strtolower($referrer), strtolower(ilObjectCopyGUI::class))) {
85 $forced = $capabilities->get(Capabilities::INFO_PAGE);
86 }
87
88 // Determine Capability to redirect
89 $capability = match ($additional_params) {
90 self::DOWNLOAD => $capabilities->get(Capabilities::DOWNLOAD),
91 self::VERSIONS => $capabilities->get(Capabilities::MANAGE_VERSIONS),
92 self::EDIT => $capabilities->get(Capabilities::EDIT_EXTERNAL),
93 self::VIEW => $capabilities->get(Capabilities::VIEW_EXTERNAL),
94 default => $forced ?? $capabilities->getBest(),
95 };
96
97 if (!$capability->isUnlocked() || $capability->getUri() === null) {
98 return $response_factory->loginFirst();
99 }
100
101 $uri = $capability->getUri();
102
103 return $response_factory->can($uri->getPath() . '?' . $uri->getQuery());
104 }
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
readonly CapabilityBuilder $capabilities
static _gotoSharedWorkspaceNode(int $wsp_id)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References $capabilities, ilObjectGUI\_gotoSharedWorkspaceNode(), ILIAS\StaticURL\Response\Factory\can(), ILIAS\StaticURL\Response\Factory\cannot(), ILIAS\File\Capabilities\CapabilityBuilder\get(), ILIAS\StaticURL\Request\Request\getAdditionalParameters(), ILIAS\StaticURL\Request\Request\getReferenceId(), ILIAS\StaticURL\Context\http(), and ILIAS\StaticURL\Response\Factory\loginFirst().

+ Here is the call graph for this function:

Field Documentation

◆ $capabilities

readonly CapabilityBuilder ilFileStaticURLHandler::$capabilities
private

Definition at line 38 of file class.ilFileStaticURLHandler.php.

Referenced by handle().

◆ DOWNLOAD

const ilFileStaticURLHandler::DOWNLOAD = 'download'

Definition at line 34 of file class.ilFileStaticURLHandler.php.

◆ EDIT

const ilFileStaticURLHandler::EDIT = 'edit'

Definition at line 36 of file class.ilFileStaticURLHandler.php.

◆ VERSIONS

const ilFileStaticURLHandler::VERSIONS = 'versions'

Definition at line 35 of file class.ilFileStaticURLHandler.php.

◆ VIEW

const ilFileStaticURLHandler::VIEW = 'view'

Definition at line 37 of file class.ilFileStaticURLHandler.php.


The documentation for this class was generated from the following file: