Watching Users Macro

Last modified by Thomas Mortagne on 2021/03/17 21:12

cogDisplays users having a specified page in their Watchlist
TypeXAR
Category
Developed by

Anca Luca

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1
Compatibility

XWiki 5.4.5 , basic functions tested on XWiki 6.2.

Installable with the Extension Manager

Description

This macro displays the users having the specified page in their watchlist. If no page is specified, the watchers of the current page are displayed. Note that the macro also takes into account users that are watching the whole space of the page or the whole wiki.

The displayed users are respective of the user scope of the wiki where the specified page is located. Specifically, this means:

  • if the specified page is located on a wiki that has the user scope set to only global users, then the displayed users will be users from the main wiki,
  • if the specified page is located on a wiki that has the user scope set to only local users, then the displayed users will be users from the wiki of the page, even if global users exist and some of the global users might be watching that page,
  • if the specified page is located on a wiki that has the user scope set to both local and global users, then the displayed users will be users from the wiki of the page and users from the main wiki.

The page parameter can be specified absolute (in the form wiki:Space.Page) or relative (Space.Page or even Page only), in which case the page will be looked up in the local context. The page does not have to exist, in which case this macro would be displaying the users that watch the whole space or the whole wiki of the specified inexistent page.

The macro can be used both in inline context (flowing text) and in block context (in its own paragraph).

Examples

The following wiki syntax:

Users watching the current page: {{watchingusers/}} .

Users watching the Main.WebHome page: {{watchingusers page="Sandbox.WebHome"/}}.

Users watching an unexistent page on a subwiki (thus watching the whole space of that page), on a wiki with both local and global users

{{watchingusers page="testmembers:Sandbox.sjdhcybegc67bw4vv738"/}}

would display (executed on the main wiki):

Watching users example

Making the macro available on the whole farm

By default this macro will be available only on the wiki where it is installed with Extension Manager. If it needs to be available on all the wikis of the instance, either install it "on the whole farm" from the Extension Manager, or install it on the main wiki, and after installation, go to the page XWiki.WatchingUsersMacro, edit it in object more with a user having programming rights, and set the WikiMacro visibility to "global". Note that, for versions affected by bug https://jira.xwiki.org/browse/XWIKI-7739, so have no other choice if you plan to use this macro from the WYSIWYG editor on a subwiki.

Prerequisites & Installation Instructions

We recommend using the Extension Manager to install this extension (Make sure that the text "Installable with the Extension Manager" is displayed at the top right location on this page to know if this extension can be installed with the Extension Manager). Note that installing Extensions when being offline is currently not supported and you'd need to use some complex manual method.

You can also use the following manual method, which is useful if this extension cannot be installed with the Extension Manager or if you're using an old version of XWiki that doesn't have the Extension Manager:

  1. Log in the wiki with a user having Administration rights
  2. Go to the Administration page and select the Import category
  3. Follow the on-screen instructions to upload the downloaded XAR
  4. Click on the uploaded XAR and follow the instructions
  5. You'll also need to install all dependent Extensions that are not already installed in your wiki

Get Connected