Failed to execute template. Cause: [Access denied when checking [script] access to [xwiki:Collaboratory.UX.HbpSkin.WebHome] for user [xwiki:XWiki.Admin]]. Click on this message for details.

Query Users - HBP Wiki

IAM21 instance, do not create collab nor modify a team, your changes will be lost


Changes for page Query Users

Last modified by bougault on 2023/09/28 17:01

From version 1.1
edited by bougault
on 2022/12/20 12:54
Change comment: There is no comment for this version
To version 11.5
edited by bougault
on 2023/09/28 17:01
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1,6 +1,35 @@
1 -{{velocity}}
2 -#set($query = $services.query.xwql("from doc.object(XWiki.XWikiUsers) as users where users.email != ''"))
1 +{{velocity output="no"}}
2 +#set($query = $services.query.xwql("from doc.object(XWiki.XWikiUsers) as users"))
3 3  #set($users = $query.execute())
4 +#set($warnings = [])
5 +#set($userIds = [])
6 +#foreach($userId in $users)
7 + #set($userDoc = $xwiki.getDocument($userId))
8 + #set($obj = $userDoc.getObject("XWiki.XWikiUsers"))
9 + #set($lastName = $obj.get("last_name"))
10 + #if(!$lastName.matches('[A-Z]{1}\.'))
11 + $warnings.add("user $userId lastname does not match privacy rules")
12 + #end
13 + #set($email = $obj.getValue("email"))
14 + #if($email != "")
15 + $warnings.add("user $userId email does not match privacy rules")
16 + #end
17 + $userIds.add($userId)
18 +#end
19 +{{/velocity}}
4 4  
5 -$users
21 +{{velocity}}
22 +
23 +{{html clean="false"}}
24 +<ul>
25 +#foreach($warning in $warnings)
26 + <li>$warning</li>
27 +#end
28 +</ul>
29 +<ul>
30 +#foreach($user in $userIds)
31 + <li>$user.replaceFirst('XWiki.', '')</li>
32 +#end
33 +</ul>
34 +{{/html}}
6 6  {{/velocity}}