Skip to content

Commit

Permalink
avoid edit in office on a locked document
Browse files Browse the repository at this point in the history
  • Loading branch information
car031 committed Dec 10, 2024
1 parent ed16d12 commit 294d9fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,8 @@ private void addOffice() {
}

private void addOnlyOffice() {
if (Feature.visible(Feature.ONLYOFFICE) && Menu.enabled(Menu.ONLYOFFICE) && Session.get().getConfigAsBoolean("converter.OnlyOfficeConverter.enabled")) {
if (Feature.visible(Feature.ONLYOFFICE) && Menu.enabled(Menu.ONLYOFFICE)
&& Session.get().getConfigAsBoolean("converter.OnlyOfficeConverter.enabled")) {
addButton(onlyoffice);
onlyoffice.setTooltip(I18N.message("editwithonlyoffice"));
onlyoffice.setTitle("<i class='fal fa-briefcase fa-lg fa-lg' aria-hidden='true'></i>");
Expand Down Expand Up @@ -692,16 +693,10 @@ private void updateUsingDocument(GUIDocument document) {
else if (document.getType() != null)
isOfficeFile = Util.isOfficeFileType(document.getType());

office.setDisabled(
!Feature.enabled(Feature.OFFICE) || !isOfficeFile || !document.isDownload() || !document.isWrite());
office.setDisabled(!Feature.enabled(Feature.OFFICE) || !isOfficeFile || !document.isDownload()
|| !document.isWrite() || document.getStatus() != Constants.DOC_UNLOCKED);
onlyoffice.setDisabled(!Feature.enabled(Feature.OFFICE) || !Menu.enabled(Menu.ONLYOFFICE)
|| !document.isDownload() || !document.isWrite());
if (document.getStatus() != Constants.DOC_UNLOCKED && !Session.get().getUser().isMemberOf(Constants.GROUP_ADMIN)
&& document.getLockUserId() != null
&& Session.get().getUser().getId() != document.getLockUserId().longValue()) {
office.setDisabled(true);
onlyoffice.setDisabled(true);
}
|| !document.isDownload() || !document.isWrite() || document.getStatus() != Constants.DOC_UNLOCKED);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ private void applySecurityPolicies(GUIAccessControlEntry allowedPermissions, fin

applyDownloadSecurity(allowedPermissions, someSelection, justOneSelected);

applyOfficeSecurity(allowedPermissions, justOneSelected);
applyOfficeSecurity(allowedPermissions, selection, justOneSelected);

convert.setEnabled(justOneSelected && Feature.enabled(Feature.FORMAT_CONVERSION));
archive.setEnabled(someSelection && allowedPermissions.isArchive() && Feature.enabled(Feature.ARCHIVING));
Expand All @@ -334,9 +334,11 @@ private void applySplitSecurity(GUIAccessControlEntry enabledPermissions, List<G
merge.setEnabled(moreSelected && enabledPermissions.isWrite());
}

private void applyOfficeSecurity(GUIAccessControlEntry enabledPermissions, boolean justOneSelected) {
private void applyOfficeSecurity(GUIAccessControlEntry enabledPermissions, List<GUIDocument> selection,
boolean justOneSelected) {
office.setEnabled(justOneSelected && Feature.enabled(Feature.OFFICE) && enabledPermissions.isWrite()
&& enabledPermissions.isDownload() && Util.isOfficeFile(grid.getSelectedDocument().getFileName()));
&& enabledPermissions.isDownload() && Util.isOfficeFile(grid.getSelectedDocument().getFileName())
&& checkStatusInSelection(Constants.DOC_UNLOCKED, selection));
}

private void applyDownloadSecurity(GUIAccessControlEntry enabledPermissions, boolean someSelection,
Expand Down

0 comments on commit 294d9fc

Please sign in to comment.