Update Page Restrictions Listener
Use the Update Page Restrictions built-in listener to add and remove restrictions to parent and child pages. You can automatically add or remove restrictions to blogs or pages, by selecting an event as a trigger. Examples are available at the bottom of the page.
Follow these steps to create an Update Page Restrictions listener:
- Navigate to General Configuration > ScriptRunner > Listeners.
- Select Create Listener.
- Select Update Page Restrictions Listener.
- Enter a description or name to help you identify this listener for the Name field.
Choose the Event(s) that triggers this listener.
Enter a Condition.
Select Example Scripts to use provided code.If you enter nothing, the listener is always triggered when the chosen event happens.
- Choose the Restriction Level.
Your choices are:- Anyone can view and edit
- Anyone can view, only users and groups chosen in this script can edit
When you select this option, two more fields appear: Groups and Users, where you determine which users and groups can edit. - Only users and groups chosen in this script can view and edit
When you select this option, two more fields appear: Groups and Users, where you determine which users and groups can view and edit.
- Select Add.
You could also select Run Now to run the listener without adding it. When the listener is finished, you see a message explaining what the listener did.
Examples
You can configure a listener to run on certain events to ensure any parent and/or child page restrictions are in place and left there.
Restrict a new page to certain groups
When a page is created, you can ensure that the new page is restricted to a certain group.
To create the listener, follow these steps:
- Set the Name to When a page is created in the Security space, ensure it is restricted.
- Set the Event(s) to PageCreateEvent.
Set the Condition to the following code:
groovyif (event.page.space.name == 'Security') { return true } false
- Select Only users and groups chosen in this script can view and edit for Restriction Level.
- Select confluence-administrators for Groups.
- Select Add.
Result
The group confluence-administration is now the only group who can see newly created pages in the Security space.