Skip to content

Commit c8c6545

Browse files
committed
XWIKI-20336: Wrong results in NotificationFilterPreferenceLivetableResults
1 parent aedba33 commit c8c6545

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

xwiki-platform-core/xwiki-platform-notifications/xwiki-platform-notifications-ui/src/main/resources/XWiki/Notifications/Code/NotificationFilterPreferenceLivetableResults.xml

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
2121
-->
2222

23-
<xwikidoc version="1.4" reference="XWiki.Notifications.Code.NotificationFilterPreferenceLivetableResults" locale="">
23+
<xwikidoc version="1.5" reference="XWiki.Notifications.Code.NotificationFilterPreferenceLivetableResults" locale="">
2424
<web>XWiki.Notifications.Code</web>
2525
<name>NotificationFilterPreferenceLivetableResults</name>
2626
<language/>
@@ -55,15 +55,19 @@
5555
##
5656
## Build the list of NotificationFilterPreference related to the given user.
5757
##
58+
#set ($isAccessGranted = false)
5859
#if ("$!request.user" != "")
59-
#set ($document = $xwiki.getDocument($services.model.resolveDocument($request.user)))
60+
#set ($requestedUserDocRef = $services.model.resolveDocument($request.user))
61+
#set ($isAccessGranted = ($services.security.authorization.hasAccess('admin', $requestedUserDocRef) || $xcontext.userReference.equals($requestedUserDocRef)))
62+
#set ($document = $xwiki.getDocument($requestedUserDocRef))
6063
#set ($target = $request.user)
6164
#set ($userTarget = true)
6265
## when request user is not given we are sending the list of NotificationFilterPreference of the current wiki.
6366
#else
6467
#set ($target = $services.wiki.getCurrentWikiReference())
6568
#set ($document = $xwiki.getDocument('XWiki.Notifications.Code.NotificationAdministration'))
6669
#set ($userTarget = false)
70+
#set ($isAccessGranted = true)
6771
#end
6872
#set ($elements = [])
6973
#set ($index = 0)
@@ -82,7 +86,7 @@
8286
#set ($displayCustom = false)
8387
#end
8488

85-
#if ($displaySystem)
89+
#if ($displaySystem &amp;&amp; $isAccessGranted)
8690
## First: get the list of available toggeable filters for the user
8791
## We display them first because we don't want them to be hidden by thousands of page filters the autowatch option
8892
## might have created. It would be not good to have to go to the last page of the livetable to find out these commonly
@@ -126,7 +130,7 @@
126130
#set ($elements = $collectiontool.sort($elements, ['name']))
127131
#end
128132

129-
#if ($displayCustom)
133+
#if ($displayCustom &amp;&amp; $isAccessGranted)
130134
## Also get the list of available filters for the user
131135
#set ($filters = $collectiontool.arrayList)
132136
#if ($userTarget)
@@ -188,22 +192,26 @@
188192
#end
189193
#end
190194
#end
191-
##
192-
## JSON.
193-
##
194-
#set ($discard = $response.setContentType('application/json'))
195-
#set ($offset = $numbertool.toNumber($request.offset))
196-
#if (!$offset)
197-
#set ($offset = 1)
198-
#end
199-
$jsontool.serialize({
200-
'totalrows' : $index,
201-
'reqNo' : $request.reqNo,
202-
'returnedrows': $elements.size(),
203-
'offset' : $offset,
204-
'rows' : $elements
205-
})
195+
#if ($isAccessGranted)
196+
##
197+
## JSON.
198+
##
199+
#set ($discard = $response.setContentType('application/json'))
200+
#set ($offset = $numbertool.toNumber($request.offset))
201+
#if (!$offset)
202+
#set ($offset = 1)
203+
#end
204+
$jsontool.serialize({
205+
'totalrows' : $index,
206+
'reqNo' : $request.reqNo,
207+
'returnedrows': $elements.size(),
208+
'offset' : $offset,
209+
'rows' : $elements
210+
})
211+
#else
212+
#set ($discard = $response.sendError(401))
206213
#end
214+
#end ## (context action)
207215
##
208216
## MACROS
209217
##

0 commit comments

Comments
 (0)