Created by
Added
movedPageInheritsParentRestrictions- Ignore whitespace
+/* The code below should be added to a Scripted Event Handler which listens to the PageMoveCompletedEvent.
+ * This script ensures that whenever a page is moved in Confluence, it will inherit the permissions of its new parent page.
+ * All right, title and interest in this code snippet shall remain the exclusive intellectual property of Adaptavist Group Ltd and its affiliates. Customers with a valid ScriptRunner
+ * license shall be granted a non-exclusive, non-transferable, freely revocable right to use this code snippet only within their own instance of Atlassian products. This licensing notice cannot be removed
+ * or amended and must be included in any circumstances where the code snippet is shared by You or a third party."
+def contentPermissionManager = ComponentLocator.getComponent(ContentPermissionManager) as ContentPermissionManager
+ def parentPermissions = contentPermissionManager.getContentPermissionSets(parent, permissionType).findAll {
+ contentPermissionManager.setContentPermissions(contentPermissionsFromSet(parentPermissions), movedPage, permissionType)
+List<ContentPermission> contentPermissionsFromSet(List<ContentPermissionSet> contentPermissionSets) {
+ ContentPermission.createUserPermission(contentPermission.getType(), contentPermission.getUserSubject())
+ ContentPermission.createGroupPermission(contentPermission.getType(), contentPermission.getGroupName())