Skip to content

Commit

Permalink
XWIKI-20336: Wrong results in NotificationFilterPreferenceLivetableRe…
Browse files Browse the repository at this point in the history
…sults

(cherry picked from commit c8c6545)
  • Loading branch information
surli committed Dec 5, 2023
1 parent f270c4c commit 29e5edb
Showing 1 changed file with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
-->

<xwikidoc version="1.4" reference="XWiki.Notifications.Code.NotificationFilterPreferenceLivetableResults" locale="">
<xwikidoc version="1.5" reference="XWiki.Notifications.Code.NotificationFilterPreferenceLivetableResults" locale="">
<web>XWiki.Notifications.Code</web>
<name>NotificationFilterPreferenceLivetableResults</name>
<language/>
Expand Down Expand Up @@ -55,15 +55,19 @@
##
## Build the list of NotificationFilterPreference related to the given user.
##
#set ($isAccessGranted = false)
#if ("$!request.user" != "")
#set ($document = $xwiki.getDocument($services.model.resolveDocument($request.user)))
#set ($requestedUserDocRef = $services.model.resolveDocument($request.user))
#set ($isAccessGranted = ($services.security.authorization.hasAccess('admin', $requestedUserDocRef) || $xcontext.userReference.equals($requestedUserDocRef)))
#set ($document = $xwiki.getDocument($requestedUserDocRef))
#set ($target = $request.user)
#set ($userTarget = true)
## when request user is not given we are sending the list of NotificationFilterPreference of the current wiki.
#else
#set ($target = $services.wiki.getCurrentWikiReference())
#set ($document = $xwiki.getDocument('XWiki.Notifications.Code.NotificationAdministration'))
#set ($userTarget = false)
#set ($isAccessGranted = true)
#end
#set ($elements = [])
#set ($index = 0)
Expand All @@ -82,7 +86,7 @@
#set ($displayCustom = false)
#end

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

#if ($displayCustom)
#if ($displayCustom &amp;&amp; $isAccessGranted)
## Also get the list of available filters for the user
#set ($filters = $collectiontool.arrayList)
#if ($userTarget)
Expand Down Expand Up @@ -188,22 +192,26 @@
#end
#end
#end
##
## JSON.
##
#set ($discard = $response.setContentType('application/json'))
#set ($offset = $numbertool.toNumber($request.offset))
#if (!$offset)
#set ($offset = 1)
#end
$jsontool.serialize({
'totalrows' : $index,
'reqNo' : $request.reqNo,
'returnedrows': $elements.size(),
'offset' : $offset,
'rows' : $elements
})
#if ($isAccessGranted)
##
## JSON.
##
#set ($discard = $response.setContentType('application/json'))
#set ($offset = $numbertool.toNumber($request.offset))
#if (!$offset)
#set ($offset = 1)
#end
$jsontool.serialize({
'totalrows' : $index,
'reqNo' : $request.reqNo,
'returnedrows': $elements.size(),
'offset' : $offset,
'rows' : $elements
})
#else
#set ($discard = $response.sendError(401))
#end
#end ## (context action)
##
## MACROS
##
Expand Down

0 comments on commit 29e5edb

Please sign in to comment.