Modifiche per il documento Utenti
Dalla versione 5.1
modificato da Andrea Omicini
il 2026/08/29 00:50
il 2026/08/29 00:50
Cambia il commento:
Nessun commento per questa versione
Alla versione 14.1
modificato da Andrea Omicini
il 2026/08/29 18:06
il 2026/08/29 18:06
Cambia il commento:
restore the translated title lost in the rename
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Titolo
-
... ... @@ -1,1 +1,1 @@ 1 -$services.localization.render( 'users')1 +$services.localization.render(users) - Content
-
... ... @@ -5,28 +5,38 @@ 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. 12 12 ################################################################################ 13 13 ## 14 -## the groups, in class order,users themselves 15 -#set( $statusList = $xwiki.getDocument('XWiki.XWiket('status').getListValues() ) 16 -#set( $people = {} ) #foreach( $s in $statusList ) 17 - #set( $discard = $people.put($s, []) ) #end 18 -## distinct: a user page with a translation (XWiki.AntonioNatali.it) returns one rowlocale 19 -#set( $rows = $services.query.xwql("select distinct doc.fullName from Document doc, doc.object(XWiki.XWikiUsers) a.execute() ) 15 +## the groups, in class order, and the people, from the users themselves 16 +#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) ) ) 22 +#set( $people = {} ) 23 +#foreach( $s in $statusList ) 24 + #set( $discard = $people.put($s, []) ) 25 +#end 26 +## distinct: a user page with a translation (XWiki.AntonioNatali.it) returns one row per locale 27 +#set( $rows = $services.query.xwql("select distinct doc.fullName from Document doc, doc.object(XWiki.XWikiUsers) as u where u.status <> ''").execute() ) 20 20 #set( $seen = [] ) 21 21 #foreach( $ref in $rows ) 22 22 #set( $uDoc = $xwiki.getDocument($ref) ) 23 - #set( $uObj = $uDoc.getObjec 31 + #set( $uObj = $uDoc.getObject('XWiki.XWikiUsers') ) 24 24 #set( $st = "$!uObj.getValue('status')" ) 25 - #if( $people.containsKey($st ) 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) ) 26 26 #set( $discard = $seen.add($ref) ) 27 - ## sort key: surname, thenrence 37 + ## sort key: surname, then given name, then the reference 28 28 #set( $last = "$!uObj.getValue('last_name')" ) 29 - #set( $first = "$!uObj.get 39 + #set( $first = "$!uObj.getValue('first_name')" ) 30 30 #set( $discard = $people.get($st).add("${last}|${first}|${ref}") ) 31 31 #end 32 32 #end ... ... @@ -34,45 +34,57 @@ 34 34 ## one person: given name + bold surname, linked to their XWiki user page 35 35 #macro( apicePerson $entry ) 36 36 #set( $bits = $entry.split('\|') ) 37 -[[${bits[1]} **${bits[0]}**>>$ 47 +[[${bits[1]} **${bits[0]}**>>${bits[2]}]]## 38 38 #end 39 39 ## 40 40 ## a section, printed only when somebody is in it 41 41 #macro( apiceGroup $status ) 42 42 #set( $group = $people.get($status) ) 43 - #if( $group && !$group.isEmp 53 + #if( $group && !$group.isEmpty() ) 44 44 #set( $group = $collectiontool.sort($group) ) 45 45 46 46 >$services.localization.render("XWiki.XWikiUsers_status_${status}") 47 -(%%)//($group.size())// 48 48 49 - #foreach( $entry in $group• #end#apicePerson($entry)#end 58 + #foreach( $entry in $group )#if( !$foreach.first ) • #end#apicePerson($entry)#end 50 50 51 51 #end 52 52 #end 53 53 ## 54 -#### CURRENT PEOPLE — every status except students and past members 55 -#foreach( $s in $statusList ) 56 - #if( $s != 'Student' && $s != 'Gone' ) 57 - #apiceGroup($s) 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}")>>path:$doc.getURL('view', "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) 58 58 #end 78 +#else 79 +#### EVERY GROUP THE CLASS DECLARES, in the class's own order 80 +#foreach( $s in $statusList ) 81 + #apiceGroup($s) 59 59 #end 60 60 ## 61 -#### PAST MEMBERS 62 -#apiceGroup('Gone') 63 -## 64 64 #### anyone whose status is not among those declared by the class — should be empty 65 65 #set( $strays = [] ) 66 66 #foreach( $ref in $rows ) 67 - #set( $uObj = $xwiki.getDocui.XWikiUsers') ) 87 + #set( $uObj = $xwiki.getDocument($ref).getObject('XWiki.XWikiUsers') ) 68 68 #set( $st = "$!uObj.getValue('status')" ) 69 - #if( !$people.containsKey($sys.add("${ref} (${st})") )#end 89 + #if( !$people.containsKey($st) )#set( $discard = $strays.add("${ref} (${st})") )#end 70 70 #end 71 71 #if( !$strays.isEmpty() ) 72 72 73 ->{{stringEngIta eng="Unrecogni riconosciuto"/}} 93 +>{{stringEngIta eng="Unrecognised status" ita="Stato non riconosciuto"/}} 74 74 75 - #foreach( $stray in $strays ) • #end#end 95 + #foreach( $stray in $strays )$stray#if( !$foreach.last ) • #end#end 76 76 77 77 #end 98 +#end 78 78 {{/velocity}} 100 +