I've developed some custom SQL routines to perform different kinds of searches, but I cannot discover how to filter the results based on the signed in user's role settings, for example, if the user doesn't have rights to view certain areas. For example, if I select records from cs_posts that match the user's search terms, how can I exclude the rows from a protected media gallery?