Colin Tay wrote:
Hi,
I would like to retrieve the number of document that is viewable by the current user
(Meaning it has the access to the document).
How can i modified the following codes to achieve that feature?
#set($query="select count(doc) from XWikiDocument doc")
#set($resultsCount = $xwiki.search($query).get(0))
Access rights have a complex logic that can't be easily expressed in
HQL. Your only choice is to iterate over all documents and check the
access rights for each one, but this is really hard on performance. What
is your goal?
A better variant is to first get the list of spaces, since spaces are a
little less numerous, and check the access rights on the space's main
page, and sum the number of pages in each accessible space. This assumes
that inside a space the user has the same rights for each document, so
it might not apply to your case.
--
Sergiu Dumitriu
http://purl.org/net/sergiu/