X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplsession.php;h=9b6f90e649a9df3628e1a02c261ccffcc1f0f4eb;hb=3c7bc7a377e3d5422f61b92ddf69c4a953ad3d15;hp=688f5f5477dfe0101d8767804348ece4de7f9193;hpb=5a074c2fba4ded858222b91acfa8422799b17182;p=platal.git diff --git a/classes/plsession.php b/classes/plsession.php index 688f5f5..9b6f90e 100644 --- a/classes/plsession.php +++ b/classes/plsession.php @@ -1,6 +1,6 @@ checkAuth($level)) { return true; } @@ -171,14 +170,23 @@ 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; @@ -190,6 +198,9 @@ abstract class PlSession return false; } S::set('user', $user); + if (!is_null($perms)) { + $this->makePerms($perms, false); + } return true; } @@ -197,7 +208,7 @@ abstract class PlSession */ public function stopSUID() { - if (!S::has('suid')) { + if (!S::suid()) { return false; } $_SESSION = $_SESSION['suid'];