Skip to content

Instantly share code, notes, and snippets.

@sdumitriu
Created January 19, 2017 18:54
Show Gist options
  • Save sdumitriu/67d6ce60dc977c525196f61a0b51f997 to your computer and use it in GitHub Desktop.
Save sdumitriu/67d6ce60dc977c525196f61a0b51f997 to your computer and use it in GitHub Desktop.
{{html clean="false"}}
<form action="" method="POST">
<fieldset>
<legend>Check a user's activity and collaborations</legend>
<input type="text" name="uid" class="suggestUsers"/> <span class="buttonwrapper"><input type="submit" value="Check" class="button"/></span>
</fieldset>
{{/html}}
{{velocity}}
#if ("$!request.uid" != '')
#set ($ruid = $services.model.resolveDocument($request.uid, 'user/current').toString())
#set ($duid = "{{html}}$xwiki.getUserName($ruid){{/html}} ($ruid)")
#set ($owendByUser = $services.query.hql(', BaseObject o, StringProperty p where o.name = doc.fullName and p.id.id = o.id and p.id.name = ''owner'' and p.value = :uid').bindValue('uid', $ruid).execute())
#set ($sharedWithUser = $services.query.hql(', BaseObject o, StringProperty p where o.name = doc.fullName and p.id.id = o.id and p.id.name = ''collaborator'' and p.value = :uid').bindValue('uid', $ruid).execute())
#set ($groups = $services.query.hql(', BaseObject o, StringProperty p where o.name = doc.fullName and p.id.id = o.id and p.id.name = ''member'' and p.value = :uid').bindValue('uid', $ruid).execute())
#set ($mentions = $mathtool.add($mathtool.add($owendByUser.size(), $sharedWithUser.size()), $groups.size()))
#if ($owendByUser.size() > 0)
{{warning}}$duid owns $owendByUser.size() patient records:
#foreach ($e in $owendByUser)
* [[$e]]
#end
{{/warning}}
#end
#if ($sharedWithUser.size() > 0)
{{warning}}$duid is a collaborator for $sharedWithUser.size() patient records:
#foreach ($e in $sharedWithUser)
* [[$e]]
#end
{{/warning}}
#end
#if ($groups.size() > 0)
{{warning}}$duid is part of $groups.size() groups:
#foreach ($e in $groups)
* [[$e]]
#end
{{/warning}}
#end
#if ($mentions == 0)
{{info}}$duid appears isolated and inactive, may be safe to delete.{{/info}}
#end
#end
{{/velocity}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment