<?php
/***************************************************************************
- * Copyright (C) 2003-2010 Polytechnique.org *
+ * Copyright (C) 2003-2011 Polytechnique.org *
* http://opensource.polytechnique.org/ *
* *
* This program is free software; you can redistribute it and/or modify *
public static function i($key, $default = 0)
{
- $i = S::v($key, $default);
- return is_numeric($i) ? intval($i) : $default;
+ $i = to_integer(S::v($key, $default));
+ return $i === false ? $default : $i;
}
public static function t($key, $default = '')
{
$uid = S::i('uid', $uid);
if (!S::has('log') || !S::v('log')->isValid($uid)) {
+ global $platal;
if (S::has('suid')) {
$suid = S::v('suid');
- S::set('log', PlLogger::get(S::i('uid', $uid), $suid['uid']));
+ S::set('log', $platal->buildLogger(S::i('uid', $uid), $suid['uid']));
} else if (S::has('uid') || $uid) {
- S::set('log', PlLogger::get(S::i('uid', $uid)));
+ S::set('log', $platal->buildLogger(S::i('uid', $uid)));
} else {
S::set('log', PlLogger::dummy($uid));
}
* move into the php session (and data it helds should be removed from
* the php session). */
private static $user = null;
- public static function &user()
+ public static function &user($forceFetch = false)
{
- if (self::$user == null && class_exists('User')) {
- self::$user = User::getSilentWithValues(S::i('uid'), $_SESSION);
+ if (($forceFetch || self::$user == null) && class_exists('User')) {
+ if (S::has('user') && S::v('user') instanceof User) {
+ self::$user = S::v('user');
+ } else {
+ self::$user = User::getSilentWithValues(S::i('uid'), $_SESSION);
+ }
}
return self::$user;
}
+ public static function changeSession(array $newSession)
+ {
+ $oldSession = $_SESSION;
+ $_SESSION = $newSession;
+ self::$user = null;
+ return $oldSession;
+ }
+
public static function logged()
{
return S::i('auth', AUTH_PUBLIC) >= Platal::session()->loggedLevel();