|
20 | 20 | * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
21 | 21 | -->
|
22 | 22 |
|
23 |
| -<xwikidoc version="1.4" reference="XWiki.Notifications.Code.NotificationFilterPreferenceLivetableResults" locale=""> |
| 23 | +<xwikidoc version="1.5" reference="XWiki.Notifications.Code.NotificationFilterPreferenceLivetableResults" locale=""> |
24 | 24 | <web>XWiki.Notifications.Code</web>
|
25 | 25 | <name>NotificationFilterPreferenceLivetableResults</name>
|
26 | 26 | <language/>
|
|
55 | 55 | ##
|
56 | 56 | ## Build the list of NotificationFilterPreference related to the given user.
|
57 | 57 | ##
|
| 58 | +#set ($isAccessGranted = false) |
58 | 59 | #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)) |
60 | 63 | #set ($target = $request.user)
|
61 | 64 | #set ($userTarget = true)
|
62 | 65 | ## when request user is not given we are sending the list of NotificationFilterPreference of the current wiki.
|
63 | 66 | #else
|
64 | 67 | #set ($target = $services.wiki.getCurrentWikiReference())
|
65 | 68 | #set ($document = $xwiki.getDocument('XWiki.Notifications.Code.NotificationAdministration'))
|
66 | 69 | #set ($userTarget = false)
|
| 70 | + #set ($isAccessGranted = true) |
67 | 71 | #end
|
68 | 72 | #set ($elements = [])
|
69 | 73 | #set ($index = 0)
|
|
82 | 86 | #set ($displayCustom = false)
|
83 | 87 | #end
|
84 | 88 |
|
85 |
| -#if ($displaySystem) |
| 89 | +#if ($displaySystem && $isAccessGranted) |
86 | 90 | ## First: get the list of available toggeable filters for the user
|
87 | 91 | ## We display them first because we don't want them to be hidden by thousands of page filters the autowatch option
|
88 | 92 | ## 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 | 130 | #set ($elements = $collectiontool.sort($elements, ['name']))
|
127 | 131 | #end
|
128 | 132 |
|
129 |
| -#if ($displayCustom) |
| 133 | +#if ($displayCustom && $isAccessGranted) |
130 | 134 | ## Also get the list of available filters for the user
|
131 | 135 | #set ($filters = $collectiontool.arrayList)
|
132 | 136 | #if ($userTarget)
|
|
188 | 192 | #end
|
189 | 193 | #end
|
190 | 194 | #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)) |
206 | 213 | #end
|
| 214 | +#end ## (context action) |
207 | 215 | ##
|
208 | 216 | ## MACROS
|
209 | 217 | ##
|
|
0 commit comments