ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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  return $capability->withUnlocked(false); // currently not possible in ILIAS 9
44 
45  if ($context->getContext() !== Context::CONTEXT_REPO) {
46  return $capability->withUnlocked(false);
47  }
48  if (!$this->hasPermission($helpers, $context, ...$capability->getPermissions())) {
49  return $capability->withUnlocked(false);
50  }
51 
52  return $capability->withUnlocked($this->hasWopiViewAction($helpers, $info->getSuffix()));
53  }
54 
55  public function maybeBuildURI(Capability $capability, CheckHelpers $helpers, Context $context): Capability
56  {
57  if (!$capability->isUnlocked()) {
58  return $capability;
59  }
60  return $capability->withURI(
61  $helpers->fromTarget(
62  $helpers->ctrl->getLinkTargetByClass(
63  [
64  $this->baseClass($context),
65  \ilObjFileGUI::class,
66  \ilWOPIEmbeddedApplicationGUI::class
67  ],
69  )
70  )
71  );
72  }
73 
74 }
$context
Definition: webdav.php:31
maybeBuildURI(Capability $capability, CheckHelpers $helpers, Context $context)
Definition: ViewContent.php:55
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