From: Vincent Zanotti Date: Mon, 14 Jul 2008 00:49:44 +0000 (+0200) Subject: Adds the User object to the platal-core session. X-Git-Tag: core/1.0.0~61 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=c12e921105fecafcf2be1fce956d54dc7a148bfb;p=platal.git Adds the User object to the platal-core session. Currently the corresponding code (PlUser & User) does not exists in core nor in master branches, but user() is not called yet in any of those branches. Signed-off-by: Vincent Zanotti --- diff --git a/classes/s.php b/classes/s.php index 7ba3b24..eb55adb 100644 --- a/classes/s.php +++ b/classes/s.php @@ -85,6 +85,23 @@ class S 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() { return Platal::session()->checkPerms(PERMS_ADMIN);