@@ -135,6 +135,9 @@ public function checkFileInfo(string $fileId, string $access_token): JSONRespons
135135 $ isSmartPickerEnabled = (bool )$ wopi ->getCanwrite () && !$ isPublic && !$ wopi ->getDirect ();
136136 $ isTaskProcessingEnabled = $ isSmartPickerEnabled && $ this ->taskProcessingManager ->isTaskProcessingEnabled ();
137137
138+ $ share = $ this ->getShareForWopiToken ($ wopi , $ file );
139+ $ shouldUseSecureView = $ this ->permissionManager ->shouldWatermark ($ file , $ wopi ->getEditorUid (), $ share );
140+
138141 // If the file is locked manually by a user we want to open it read only for all others
139142 $ canWriteThroughLock = true ;
140143 try {
@@ -156,7 +159,7 @@ public function checkFileInfo(string $fileId, string $access_token): JSONRespons
156159 'UserExtraInfo ' => [],
157160 'UserPrivateInfo ' => [],
158161 'UserCanWrite ' => $ canWriteThroughLock && (bool )$ wopi ->getCanwrite (),
159- 'UserCanNotWriteRelative ' => $ isPublic || $ this ->encryptionManager ->isEnabled () || $ wopi ->getHideDownload () || $ wopi ->isRemoteToken (),
162+ 'UserCanNotWriteRelative ' => $ isPublic || $ this ->encryptionManager ->isEnabled () || $ wopi ->getHideDownload () || $ wopi ->isRemoteToken () || $ shouldUseSecureView ,
160163 'PostMessageOrigin ' => $ wopi ->getServerHost (),
161164 'LastModifiedTime ' => Helper::toISO8601 ($ file ->getMTime ()),
162165 'SupportsRename ' => !$ isVersion && !$ wopi ->isRemoteToken (),
@@ -166,11 +169,11 @@ public function checkFileInfo(string $fileId, string $access_token): JSONRespons
166169 'EnableShare ' => $ file ->isShareable () && !$ isVersion && !$ isPublic ,
167170 'HideUserList ' => '' ,
168171 'EnableOwnerTermination ' => $ wopi ->getCanwrite () && !$ isPublic ,
169- 'DisablePrint ' => $ wopi ->getHideDownload (),
170- 'DisableExport ' => $ wopi ->getHideDownload (),
171- 'DisableCopy ' => $ wopi ->getHideDownload (),
172- 'HideExportOption ' => $ wopi ->getHideDownload (),
173- 'HidePrintOption ' => $ wopi ->getHideDownload (),
172+ 'DisablePrint ' => $ wopi ->getHideDownload () || $ shouldUseSecureView ,
173+ 'DisableExport ' => $ wopi ->getHideDownload () || $ shouldUseSecureView ,
174+ 'DisableCopy ' => $ wopi ->getHideDownload () || $ shouldUseSecureView ,
175+ 'HideExportOption ' => $ wopi ->getHideDownload () || $ shouldUseSecureView ,
176+ 'HidePrintOption ' => $ wopi ->getHideDownload () || $ shouldUseSecureView ,
174177 'DownloadAsPostMessage ' => $ wopi ->getDirect (),
175178 'SupportsLocks ' => $ this ->lockManager ->isLockProviderAvailable (),
176179 'IsUserLocked ' => $ this ->permissionManager ->userIsFeatureLocked ($ wopi ->getEditorUid ()),
@@ -223,8 +226,7 @@ public function checkFileInfo(string $fileId, string $access_token): JSONRespons
223226 $ response ['TemplateSource ' ] = $ this ->getWopiUrlForTemplate ($ wopi );
224227 }
225228
226- $ share = $ this ->getShareForWopiToken ($ wopi , $ file );
227- if ($ this ->permissionManager ->shouldWatermark ($ file , $ wopi ->getEditorUid (), $ share )) {
229+ if ($ shouldUseSecureView ) {
228230 $ email = $ user !== null && !$ isPublic ? $ user ->getEMailAddress () : '' ;
229231 $ currentDateTime = new \DateTime (
230232 'now ' ,
0 commit comments