/** * Create the part of WHERE in the sql queries used to filter forums for a * specific user (MinClassRead, restricted and permitted forums). * @return string */ public static function user_forums_sql() { // I couldn't come up with a good name, please rename this if you can. -- Y $RestrictedForums = self::get_restricted_forums(); $PermittedForums = self::get_permitted_forums(); if (Donations::has_donor_forum(G::$LoggedUser['ID']) && !in_array(DONOR_FORUM, $PermittedForums)) { $PermittedForums[] = DONOR_FORUM; } $SQL = "((f.MinClassRead <= '" . G::$LoggedUser['Class'] . "'"; if (count($RestrictedForums)) { $SQL .= " AND f.ID NOT IN ('" . implode("', '", $RestrictedForums) . "')"; } $SQL .= ')'; if (count($PermittedForums)) { $SQL .= " OR f.ID IN ('" . implode("', '", $PermittedForums) . "')"; } $SQL .= ')'; return $SQL; }