I want a code that tests all kinds of conditions and stops if at least one of them fails.
Just as a random example (pretending such a function is called COM_getPermSQL_reverse):
Text Formatted Code
$sql = "SELECT '' FROM gl_stories WHERE (sid='foo' OR sid='bar')" . COM_getPermSQL_reverse("AND");
$result = DB_query($sql);
if (!DB_numRows($result))
echo "At least one of these stories is out of your reach, so I decided you can't see the other either";
Text Formatted Code
$sql = "SELECT '' FROM gl_stories WHERE sid='foo' OR sid='bar'";
$result = DB_query($sql);
$sql1 = DB_numRows($result);
if ($sql1 > 0 && !SEC_inGroup('Root')) {
$sql = "SELECT '' FROM gl_stories WHERE (sid='foo' OR sid='bar')" . COM_getPermSQL("AND");
$result = DB_query($sql);
$sql2 = DB_numRows($result);
if ($sql2 < $sql1)
echo "At least one of these stories is out of your reach, so I decided you can't see the other either";
}