Apply ACL restriction filters for a search query

Put this in a function :)