/** * Returns true if the current user may access this file * * @param string $f file to access * @return bool * @author Thibaud Rohmer */ public static function view($f) { // Check if user has an account if (!isset(CurrentUser::$account)) { // User is not logged in $judge = new Judge($f); return $judge->public; } if (!Judge::inGoodPlace($f)) { return false; } // No Judge required for the admin. This guy rocks. if (CurrentUser::$admin) { return true; } // Create Judge $judge = new Judge($f); // Public file if ($judge->public) { return true; } // User allowed if (in_array(CurrentUser::$account->login, $judge->users)) { return true; } // User in allowed group foreach (CurrentUser::$account->groups as $group) { if (in_array($group, $judge->groups)) { return true; } } return false; }