ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ViewContent.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
26 
30 class ViewContent extends BaseCheck implements Check
31 {
32  public function canUnlock(): Capabilities
33  {
34  return Capabilities::VIEW_EXTERNAL;
35  }
36 
37  public function maybeUnlock(
38  Capability $capability,
39  CheckHelpers $helpers,
40  \ilObjFileInfo $info,
42  ): Capability {
43  if ($context->getContext() !== Context::CONTEXT_REPO) {
44  return $capability->withUnlocked(false);
45  }
46  if (!$this->hasPermission($helpers, $context, ...$capability->getPermissions())) {
47  return $capability->withUnlocked(false);
48  }
49 
50  return $capability->withUnlocked($this->hasWopiViewAction($helpers, $info->getSuffix()));
51  }
52 
53  public function maybeBuildURI(Capability $capability, CheckHelpers $helpers, Context $context): Capability
54  {
55  if (!$capability->isUnlocked()) {
56  return $capability;
57  }
58  return $capability->withURI(
59  $helpers->fromTarget(
60  $helpers->ctrl->getLinkTargetByClass(
61  [
62  $this->baseClass($context),
63  \ilObjFileGUI::class,
64  \ilWOPIEmbeddedApplicationGUI::class
65  ],
67  )
68  )
69  );
70  }
71 
72 }
$context
Definition: webdav.php:31
maybeBuildURI(Capability $capability, CheckHelpers $helpers, Context $context)
Definition: ViewContent.php:53
hasPermission(CheckHelpers $helpers, Context $context, Permissions ... $permission)
Definition: BaseCheck.php:36
maybeUnlock(Capability $capability, CheckHelpers $helpers, \ilObjFileInfo $info, Context $context,)
Definition: ViewContent.php:37
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: BaseCheck.php:21
hasWopiViewAction(CheckHelpers $helpers, string $suffix)
Definition: BaseCheck.php:75