X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplsession.php;h=9b6f90e649a9df3628e1a02c261ccffcc1f0f4eb;hb=2779e65f509a1f04cb5976d245da9f3a9028934d;hp=bc5f5082777b78d8baeb775c5442205c47947e9d;hpb=8cd8f58b0e58ee8ebc2ebf1bb79f2e20eb05808d;p=platal.git diff --git a/classes/plsession.php b/classes/plsession.php index bc5f508..9b6f90e 100644 --- a/classes/plsession.php +++ b/classes/plsession.php @@ -1,6 +1,6 @@ checkAuth($level)) { return true; } @@ -170,25 +170,37 @@ abstract class PlSession */ abstract public function tokenAuth($login, $token); + /** Set the permissions to the given flagset. + * + * This function sets S::set('perms') with a flagset represeting the combination of + * $perms and $is_admin. + * + * $perms is an abstract object representing the permissions. + * $is_admin is a boolean, true if the current user has site-administration rights. + */ + abstract protected function makePerms($perms, $is_admin); /*** SUID management ***/ /** Start a new SUID session. */ - public function startSUID($user) + public function startSUID($user, $perms = null) { - if (S::has('suid')) { + if (S::suid()) { return false; } $backup = $_SESSION; $_SESSION = array(); $this->fillSession(); S::set('suid', $backup); - if (!$this->startSessionAs($user, -1)) { + if (!$this->startSessionAs($user, AUTH_SUID)) { $this->stopSUID(); return false; } S::set('user', $user); + if (!is_null($perms)) { + $this->makePerms($perms, false); + } return true; } @@ -196,7 +208,7 @@ abstract class PlSession */ public function stopSUID() { - if (!S::has('suid')) { + if (!S::suid()) { return false; } $_SESSION = $_SESSION['suid'];