[xwiki-users] Display users that are not hidden
I have a script as follows that displays a list of users that meet some criteria (the actual where clause I'm using is a bit more complicated than shown below): {{velocity}} #set ($users=$services.query.xwql("FROM doc.object(XWiki.XWikiUsers) AS user WHERE (user.first_name LIKE '%Mar%')").execute()) #set ($numUsers = $users.size()) #if ($numUsers > 0) #foreach ($user in $users) #if (!$user.isHidden()) [[$user]] #end #end #end {{/velocity}} My problem is that the isHidden method is filtering out the users whose pages I've marked as hidden. How can I fix this script to list only the users who are not hidden? Mark -- View this message in context: http://xwiki.475771.n2.nabble.com/Display-users-that-are-not-hidden-tp759883... Sent from the XWiki- Users mailing list archive at Nabble.com.
Instead of testing yourself in your script you should add a filter in your query. See http://extensions.xwiki.org/xwiki/bin/view/Extension/Query+Module#HFromVeloc... for some examples. On Wed, Apr 6, 2016 at 5:33 PM, Mark Sack <mark.sack@secti.al.gov.br> wrote:
I have a script as follows that displays a list of users that meet some criteria (the actual where clause I'm using is a bit more complicated than shown below):
{{velocity}} #set ($users=$services.query.xwql("FROM doc.object(XWiki.XWikiUsers) AS user WHERE (user.first_name LIKE '%Mar%')").execute()) #set ($numUsers = $users.size()) #if ($numUsers > 0) #foreach ($user in $users) #if (!$user.isHidden()) [[$user]] #end #end #end {{/velocity}}
My problem is that the isHidden method is filtering out the users whose pages I've marked as hidden. How can I fix this script to list only the users who are not hidden?
Mark
-- View this message in context: http://xwiki.475771.n2.nabble.com/Display-users-that-are-not-hidden-tp759883... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
Thanks for the pointer. The filter is a big improvement on what I had before. However, it only excludes hidden users if the logged in user has not chosen to display hidden documents. For this particular case, it would be preferable to always exclude hidden users from the output of the script. Is there a way to do that? I had thought about using the 'active' property in the user profile (I'm not sure what is its intended function within the Xwiki application). But if I add it in for editing, then the users can set themselves as active/inactive. In our situation, this would be exclusively an administrative function. Regards Mark -- View this message in context: http://xwiki.475771.n2.nabble.com/Display-users-that-are-not-hidden-tp759883... Sent from the XWiki- Users mailing list archive at Nabble.com.
On Thu, Apr 7, 2016 at 2:16 PM, Mark Sack <mark.sack@secti.al.gov.br> wrote:
Thanks for the pointer. The filter is a big improvement on what I had before. However, it only excludes hidden users if the logged in user has not chosen to display hidden documents. For this particular case, it would be preferable to always exclude hidden users from the output of the script. Is there a way to do that?
Indeed this filter is dynamic. What you could do is the same thing than the filter: add "(doc.hidden <> true or doc.hidden is null)" to your query.
I had thought about using the 'active' property in the user profile (I'm not sure what is its intended function within the Xwiki application). But if I add it in for editing, then the users can set themselves as active/inactive. In our situation, this would be exclusively an administrative function.
Regards Mark
-- View this message in context: http://xwiki.475771.n2.nabble.com/Display-users-that-are-not-hidden-tp759883... Sent from the XWiki- Users mailing list archive at Nabble.com. _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
-- Thomas Mortagne
participants (2)
-
Mark Sack -
Thomas Mortagne