Skip to content

Commit 294d9fc

Browse files
committed
avoid edit in office on a locked document
1 parent ed16d12 commit 294d9fc

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/document/DocumentToolbar.java

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,8 @@ private void addOffice() {
484484
}
485485

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

695-
office.setDisabled(
696-
!Feature.enabled(Feature.OFFICE) || !isOfficeFile || !document.isDownload() || !document.isWrite());
696+
office.setDisabled(!Feature.enabled(Feature.OFFICE) || !isOfficeFile || !document.isDownload()
697+
|| !document.isWrite() || document.getStatus() != Constants.DOC_UNLOCKED);
697698
onlyoffice.setDisabled(!Feature.enabled(Feature.OFFICE) || !Menu.enabled(Menu.ONLYOFFICE)
698-
|| !document.isDownload() || !document.isWrite());
699-
if (document.getStatus() != Constants.DOC_UNLOCKED && !Session.get().getUser().isMemberOf(Constants.GROUP_ADMIN)
700-
&& document.getLockUserId() != null
701-
&& Session.get().getUser().getId() != document.getLockUserId().longValue()) {
702-
office.setDisabled(true);
703-
onlyoffice.setDisabled(true);
704-
}
699+
|| !document.isDownload() || !document.isWrite() || document.getStatus() != Constants.DOC_UNLOCKED);
705700
}
706701

707702
@Override

logicaldoc-gui/src/main/java/com/logicaldoc/gui/frontend/client/document/grid/ContextMenu.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ private void applySecurityPolicies(GUIAccessControlEntry allowedPermissions, fin
307307

308308
applyDownloadSecurity(allowedPermissions, someSelection, justOneSelected);
309309

310-
applyOfficeSecurity(allowedPermissions, justOneSelected);
310+
applyOfficeSecurity(allowedPermissions, selection, justOneSelected);
311311

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

337-
private void applyOfficeSecurity(GUIAccessControlEntry enabledPermissions, boolean justOneSelected) {
337+
private void applyOfficeSecurity(GUIAccessControlEntry enabledPermissions, List<GUIDocument> selection,
338+
boolean justOneSelected) {
338339
office.setEnabled(justOneSelected && Feature.enabled(Feature.OFFICE) && enabledPermissions.isWrite()
339-
&& enabledPermissions.isDownload() && Util.isOfficeFile(grid.getSelectedDocument().getFileName()));
340+
&& enabledPermissions.isDownload() && Util.isOfficeFile(grid.getSelectedDocument().getFileName())
341+
&& checkStatusInSelection(Constants.DOC_UNLOCKED, selection));
340342
}
341343

342344
private void applyDownloadSecurity(GUIAccessControlEntry enabledPermissions, boolean someSelection,

0 commit comments

Comments
 (0)