return array_map(array('S', 'v'), $keys);
}
- public static function set($key, &$value)
+ public static function set($key, $value)
{
$_SESSION[$key] =& $value;
}
- public static function bootstrap($key, &$value)
+ public static function bootstrap($key, $value)
{
if (!S::has($key)) {
S::set($key, $value);
}
}
+ public static function logger($uid = null)
+ {
+ if (!S::has('log')) {
+ if (S::has('suid')) {
+ $suid = S::v('suid');
+ S::set('log', new PlLogger(S::v('uid', $uid), $suid['uid']));
+ } else if (S::has('uid') || $uid) {
+ S::set('log', new PlLogger(S::v('uid', $uid)));
+ }
+ }
+ return S::v('log');
+ }
+
+ /** User object storage and accessor. The user object (an instance of the
+ * local subclass of PlUser) is currently stored as a S class variable, and
+ * not as a session variable, so as to avoid bloating the global on-disk
+ * session.
+ * TODO: When all the codebase will use S::user() as the only source for
+ * user ids, fullname/displayname, and forlife/bestalias, S::$user should
+ * move into the php session (and data it helds should be removed from
+ * the php session). */
+ private static $user = null;
+ public static function &user()
+ {
+ if (self::$user == null) {
+ self::$user = User::getSilentWithValues(S::i('uid'), $_SESSION);
+ }
+ return self::$user;
+ }
+
public static function has_perms()
{
- global $session;
- return $session->checkPerms(PERMS_ADMIN);
+ return Platal::session()->checkPerms(PERMS_ADMIN);
}
public static function logged()
public static function identified()
{
- global $session;
- return S::v('auth', AUTH_PUBLIC) >= $session->sureLevel();
+ return S::v('auth', AUTH_PUBLIC) >= Platal::session()->sureLevel();
}
// Anti-XSRF protections.