-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from ONLYOFFICE/develop
Release/2.4.0
- Loading branch information
Showing
34 changed files
with
770 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[submodule "src/main/resources/app_data"] | ||
path = src/main/resources/app_data | ||
url = https://github.com/ONLYOFFICE/document-templates | ||
branch = main/new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* | ||
* (c) Copyright Ascensio System SIA 2020 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package onlyoffice; | ||
|
||
import com.atlassian.confluence.pages.Page; | ||
import com.atlassian.confluence.pages.PageManager; | ||
import com.atlassian.confluence.security.Permission; | ||
import com.atlassian.confluence.security.PermissionManager; | ||
import com.atlassian.confluence.user.AuthenticatedUserThreadLocal; | ||
import com.atlassian.confluence.user.ConfluenceUser; | ||
import com.atlassian.plugin.PluginParseException; | ||
import com.atlassian.plugin.web.Condition; | ||
import com.atlassian.spring.container.ContainerManager; | ||
import com.opensymphony.webwork.ServletActionContext; | ||
import javax.servlet.http.HttpServletRequest; | ||
import java.util.Map; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
public class IsOfficePageAttachments implements Condition { | ||
private String pageAttachments = "viewpageattachments.action"; | ||
|
||
public void init(Map<String, String> map) throws PluginParseException { | ||
|
||
} | ||
|
||
public boolean shouldDisplay(Map<String, Object> context) { | ||
HttpServletRequest request = ServletActionContext.getRequest(); | ||
|
||
if (request != null){ | ||
String uri = request.getServletPath(); | ||
Pattern pattern = Pattern.compile(".*/" + pageAttachments + ".*"); | ||
Matcher matcher = pattern.matcher(uri); | ||
|
||
String pageId = request.getParameter("pageId"); | ||
boolean access = false; | ||
if (pageId != null){ | ||
ConfluenceUser user = AuthenticatedUserThreadLocal.get(); | ||
PermissionManager permissionManager = (PermissionManager) ContainerManager.getComponent("permissionManager"); | ||
PageManager pageManager = (PageManager) ContainerManager.getComponent("pageManager"); | ||
|
||
Page page = pageManager.getPage(Long.parseLong(pageId)); | ||
access = permissionManager.hasPermission(user, Permission.EDIT, page); | ||
} | ||
return matcher.matches() && access; | ||
}else { | ||
return false; | ||
} | ||
} | ||
} |
Oops, something went wrong.