Correct SQL for documents selection

Fetches all documents user has access to, even if he is not the admin,
as long as he belongs to the adequate group