Skip to content

Commit

Permalink
[FIX] missing commands in action dropdowns
Browse files Browse the repository at this point in the history
  • Loading branch information
chfsx committed Jan 27, 2025
1 parent 58352a1 commit 7f23537
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
6 changes: 4 additions & 2 deletions Modules/File/classes/Capabilities/CapabilityBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public function __construct(
private \ilCtrlInterface $ctrl,
private ActionRepository $action_repository,
private Services $http,
private TypeResolver $type_resolver = new CoreTypeResolver(),
private \ilWorkspaceAccessHandler $workspace_access_handler = new \ilWorkspaceAccessHandler()
private ?TypeResolver $type_resolver = null,
private ?\ilWorkspaceAccessHandler $workspace_access_handler = null
) {
$this->checks = [
new ForcedInfo(),
Expand All @@ -65,6 +65,8 @@ public function __construct(
new Unzip(),
new ViewContent(),
];
$this->type_resolver = $this->type_resolver ?? new CoreTypeResolver();
$this->workspace_access_handler = $this->workspace_access_handler ?? new \ilWorkspaceAccessHandler();
}

public function get(Context $context): CapabilityCollection
Expand Down
8 changes: 7 additions & 1 deletion Modules/File/classes/Capabilities/Check/BaseCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ protected function hasPermission(
);
}

return $helpers->access->checkAccess($permission_string, '', $context->getCallingId(), 'file');
foreach ($permission as $p) {
if ($helpers->access->checkAccess($p->value, '', $context->getCallingId(), 'file')) {
return true;
}
}

return false;
}

protected function hasWopiAction(CheckHelpers $helpers, string $suffix, ActionTarget ...$action): bool
Expand Down
22 changes: 14 additions & 8 deletions Modules/File/classes/class.ilObjFileListGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ public function __construct(int $context = self::CONTEXT_REPOSITORY)

}

protected function updateContext(): void
{
$this->capability_context = $this->capability_context
->withCallingId($this->ref_id ?? 0)
->withObjectId($this->obj_id ?? 0);
}

/**
* initialisation
*/
Expand All @@ -89,15 +96,12 @@ public function init(): void
}

$this->commands = ilObjFileAccess::_getCommands();
$this->capability_context = $this->capability_context
->withCallingId($this->ref_id ?? 0)
->withObjectId(
$this->obj_id ?? 0
);
$this->updateContext();
}

public function getCommands(): array
{
$this->updateContext();
$this->capabilities = $this->capability_builder->get($this->capability_context);

$best = $this->capabilities->getBest();
Expand All @@ -114,6 +118,7 @@ public function getCommands(): array

public function getCommandLink(string $cmd): string
{
$this->updateContext();
$info = $this->file_info->getByObjectId($this->obj_id);
$this->capabilities = $this->capability_builder->get($this->capability_context);

Expand Down Expand Up @@ -158,6 +163,7 @@ public function stripTitleOfFileExtension(string $a_title): string
*/
public function getCommandFrame(string $cmd): string
{
$this->updateContext();
$info = $this->file_info->getByObjectId($this->obj_id);

$frame = "";
Expand All @@ -168,10 +174,9 @@ public function getCommandFrame(string $cmd): string
}
break;
case "":
default:
$frame = ilFrameTargetInfo::_getFrame("RepositoryContent");
break;

default:
}

return $frame;
Expand Down Expand Up @@ -279,10 +284,11 @@ public function checkCommandAccess(
string $type,
?int $obj_id = null
): bool {
$this->updateContext();

$this->capability_context = $this->capability_context
->withCallingId($ref_id)
->withObjectId($obj_id ?? 0);
->withObjectId($obj_id ?? $this->capability_context->getObjectId());

// LP settings only in repository
if ($this->context !== self::CONTEXT_REPOSITORY && $permission === "edit_learning_progress") {
Expand Down

0 comments on commit 7f23537

Please sign in to comment.