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.

XWiki Users - HBP Wiki

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


Changes for page XWiki Users

Last modified by bougault on 2022/12/20 15:43

From version 18.1
edited by bougault
on 2022/12/20 09:28
Change comment: There is no comment for this version
To version 30.1
edited by bougault
on 2022/12/20 14:37
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1,27 +1,40 @@
1 -{{velocity output="no"}}
1 +{{velocity}}
2 2  #set($counter = 0)
3 -#set($dateStart = $datetool)
3 +#set($dateStart = $datetool.getSystemTime())
4 +##set($query = $services.query.xwql("from doc.object(XWiki.XWikiUsers) as users where users.email <> ''"))
4 4  #set($query = $services.query.xwql("from doc.object(XWiki.XWikiUsers) as users"))
5 5  #set($users = $query.execute())
6 6  
7 7  #foreach($userId of $users)
8 - #set($counter = $counter + 1)
9 + #set($modif = 0)
9 9   #set($userDoc = $xwiki.getDocument($userId))
10 10   #set($obj = $userDoc.getObject("XWiki.XWikiUsers"))
11 - $obj.set("email", "")
12 + #if($obj.get("email") != "")
13 + change email
14 + #set($modif = 1)
15 + $obj.set("email", "")
16 + #end
12 12   #set($lastName = $obj.get("last_name"))
13 - #if($lastName && $lastName != "")
18 + #if($lastName && $lastName != "" && !$lastName.matches('[A-Z]{1}\.'))
19 + change lastname
20 + #set($modif = 1)
14 14   $obj.set("last_name", $lastName.substring(0,1).toUpperCase().concat("."))
15 15   #end
16 16   ##$userId
17 - $userDoc.save()
24 + #if($modif == 1)
25 + #set($counter = $counter + 1)
26 + $userDoc.save()
27 + #end
18 18  #end
19 19  
20 -#set($dateEnd = $datetool)
30 +#set($dateEnd = $datetool.getSystemTime())
21 21  #set($duration = $datetool.difference($dateStart, $dateEnd))
22 22  {{/velocity}}
23 23  
24 -{{html}}
25 -$counter
26 -$duration
34 +{{velocity}}
35 +
36 +{{html clean="false"}}
37 +<p>Updated $counter users in $duration</p>
27 27  {{/html}}
39 +
40 +{{/velocity}}