Script - Show Page Watchers (groovy & beanshell)
The script is implemented as a macro, to show watchers of the current page (including space watchers). Two versions are provided here: groovy and beanshell. This was tested in Confluence 2.7.3, 2.10.3 and 3.0, so it should work for most versions.
Macro Name |
watchers |
---|---|
Macro has a body |
Unchecked |
Output |
Macro generates wiki markup |
Groovy
#set ($title = "Notification List") #if ($paramtitle) #set ($title = $paramtitle) #end ## {groovy} import com.atlassian.confluence.util.GeneralUtil; import com.atlassian.confluence.core.ContentEntityObject; import com.atlassian.confluence.mail.notification.Notification; import com.atlassian.confluence.mail.notification.NotificationManager; import com.atlassian.spring.container.ContainerManager; import com.atlassian.user.User; // Get the default Notification Manager NotificationManager nm = ( NotificationManager) ContainerManager.getComponent( "notificationManager" ); // Get the current page object ContentEntityObject page = context.getEntity(); #if ($title.length() > 0) println("<h4>$!{title}</h4>"); #end // Notifications for this page for (Notification notif in nm.getNotificationsByPage(page)) { if (notif.getUserName()) { println(GeneralUtil.getUserAccessor().getUser(notif.getUserName()).getFullName() + "<br />"); } } // Notifications for this space for (Notification notif in nm.getNotificationsBySpace(page.getSpace())) { if (notif.getUserName()) { println(GeneralUtil.getUserAccessor().getUser(notif.getUserName()).getFullName() + " (<i class=smalltext>Watching this Space</i>)<br />"); } } {groovy}
Beanshell
#set ($title = "Notification List") #if ($paramtitle) #set ($title = $paramtitle) #end ## {beanshell} import com.atlassian.confluence.util.GeneralUtil; import com.atlassian.confluence.core.ContentEntityObject; import com.atlassian.confluence.mail.notification.Notification; import com.atlassian.confluence.mail.notification.NotificationManager; import com.atlassian.spring.container.ContainerManager; import com.atlassian.user.User; // Get the default Notification Manager NotificationManager nm = ( NotificationManager) ContainerManager.getComponent( "notificationManager" ); // Get the current page object ContentEntityObject page = context.getEntity(); #if ($title.length() > 0) print("<h4>$!{title}</h4>"); #end // Notifications for this page for (Notification notif : nm.getNotificationsByPage(page)) { if (notif.getUserName() != null) { print(GeneralUtil.getUserAccessor().getUser(notif.getUserName()).getFullName() + "<br />"); } } // Notifications for this space for (Notification notif : nm.getNotificationsBySpace(page.getSpace())) { if (notif.getUserName() != null) { print(GeneralUtil.getUserAccessor().getUser(notif.getUserName()).getFullName() + " (<i class=smalltext>Watching this Space</i>)<br />"); } } {beanshell}
Log a request with our support team.
Confluence®, Jira®, Atlassian Bamboo®, Bitbucket®, Fisheye®, and Atlassian Crucible® are registered trademarks of Atlassian®
Copyright © 2005 - 2024 Appfire | All rights reserved. Appfire™, the 'Apps for makers™' slogan and Bob Swift Atlassian Apps™ are all trademarks of Appfire Technologies, LLC.