Changes for page Users
From version 7.1
edited by Andrea Omicini
on 2026/08/29 00:56
on 2026/08/29 00:56
Change comment:
There is no comment for this version
To version 11.1
edited by Andrea Omicini
on 2026/08/29 17:44
on 2026/08/29 17:44
Change comment:
add the ?status= filter, validated against the class's own value list
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -5,7 +5,8 @@ 5 5 ## Nothing is hand-maintained here: the groups are the values declared by 6 6 ## XWiki.XWikiUsers.status, in the class's own order, and every user carrying a 7 7 ## status appears in exactly one of them. Add a status to the class and it shows 8 -## up here; change someone's status and they move. 8 +## up here; change someone's status and they move. Disabled accounts (active = 0) 9 +## are left out. 9 9 ## 10 10 ## Headings use the translation keys XWiki.XWikiUsers_status_<value>, so the page 11 11 ## is bilingual without a single string of its own. ... ... @@ -13,6 +13,11 @@ 13 13 ## 14 14 ## the groups, in class order, and the people, from the users themselves 15 15 #set( $statusList = $xwiki.getDocument('XWiki.XWikiUsers').getxWikiClass().get('status').getListValues() ) 17 +## an optional ?status=<value> filter. The value is validated against the list the 18 +## class itself declares, so no status value is written down here: change the class 19 +## and both the grouping and the filter follow. 20 +#set( $wanted = "$!request.getParameter('status')" ) 21 +#set( $known = ( $wanted == '' || $statusList.contains($wanted) ) ) 16 16 #set( $people = {} ) 17 17 #foreach( $s in $statusList ) 18 18 #set( $discard = $people.put($s, []) ) ... ... @@ -24,7 +24,9 @@ 24 24 #set( $uDoc = $xwiki.getDocument($ref) ) 25 25 #set( $uObj = $uDoc.getObject('XWiki.XWikiUsers') ) 26 26 #set( $st = "$!uObj.getValue('status')" ) 27 - #if( $people.containsKey($st) && !$seen.contains($ref) ) 33 + ## `active` is unset on most user objects, so only an explicit 0 counts as disabled 34 + #set( $isActive = ("$!uObj.getValue('active')" != '0') ) 35 + #if( $people.containsKey($st) && $isActive && !$seen.contains($ref) ) 28 28 #set( $discard = $seen.add($ref) ) 29 29 ## sort key: surname, then given name, then the reference 30 30 #set( $last = "$!uObj.getValue('last_name')" ) ... ... @@ -45,7 +45,7 @@ 45 45 #if( $group && !$group.isEmpty() ) 46 46 #set( $group = $collectiontool.sort($group) ) 47 47 48 ->$services.localization.render("XWiki.XWikiUsers_status_${status}") (%%)//($group.size())//56 +>$services.localization.render("XWiki.XWikiUsers_status_${status}") 49 49 50 50 #foreach( $entry in $group )#if( !$foreach.first ) • #end#apicePerson($entry)#end 51 51 ... ... @@ -52,15 +52,31 @@ 52 52 #end 53 53 #end 54 54 ## 63 +#if( !$known ) 64 +#### the class does not declare this value — say so, and show what it does declare 65 +>{{stringEngIta eng="Unknown status" ita="Stato sconosciuto"/}}: **$escapetool.xml($wanted)** 66 + 67 + #foreach( $s in $statusList )[[$services.localization.render("XWiki.XWikiUsers_status_${s}")>>||queryString="status=${s}"]]#if( !$foreach.last ) • #end#end 68 + 69 +#elseif( $wanted != '' ) 70 +#### ONE GROUP, ASKED FOR BY ?status= — students included, like any other value 71 + #if( $people.get($wanted).isEmpty() ) 72 + 73 +>{{stringEngIta eng="Nobody has this status" ita="Nessuno ha questo stato"/}} 74 + 75 + #else 76 + #apiceGroup($wanted) 77 + #end 78 +#else 55 55 #### CURRENT PEOPLE — every status except students and past members 56 56 #foreach( $s in $statusList ) 57 - #if( $s != ' Student' && $s != 'Gone' )81 + #if( $s != 'student' && $s != 'gone' ) 58 58 #apiceGroup($s) 59 59 #end 60 60 #end 61 61 ## 62 62 #### PAST MEMBERS 63 -#apiceGroup(' Gone')87 +#apiceGroup('gone') 64 64 ## 65 65 #### anyone whose status is not among those declared by the class — should be empty 66 66 #set( $strays = [] ) ... ... @@ -76,5 +76,6 @@ 76 76 #foreach( $stray in $strays )$stray#if( !$foreach.last ) • #end#end 77 77 78 78 #end 103 +#end 79 79 {{/velocity}} 80 80