public static final function render(array $params) { // Set some page default things Lib\Display::addKey('title', DEFAULT_TITLE); Lib\Display::setLayout('default'); static::_initTemplateHelpers(); Lib\Display::addKey('CSS_VERSION', CSS_VERSION); Lib\Display::addKey('JS_VERSION', JS_VERSION); Lib\Display::addKey('USE_MIN', USE_MIN); $user = Api\User::getCurrentUser(); Lib\Display::addKey('user', $user); // If we have a user, seed the test bucket so that // random distribution is deterministic if ($user) { Lib\TestBucket::initialize($user->id); } // Kick off page specific rendering static::generate($params); }
protected static function _checkLogin() { $user = Api\User::getCurrentUser(); $readonly = Lib\Url::GetBool('readonly', null); if (!$user && !$readonly && stripos($_SERVER['HTTP_USER_AGENT'], 'google') === false) { header('Location: /user/login/?redirect=' . urlencode($_GET['q'])); exit; } // Setup a default user if we're in readonly if (!$user) { $user = new stdClass(); $user->id = 0; } // Seed the test bucket with the user's ID Lib\TestBucket::initialize($user->id); return $user; }