X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fxnetsession.php;h=068e6b28c3094205f69995790341a1ea584705ed;hb=cef8ceb20d800a21aa438fd40341793131eb092c;hp=73dd8446900b1ad739b6ae73b8e6ec4640115265;hpb=a62886091365824f04a967638dee269196c3899d;p=platal.git diff --git a/classes/xnetsession.php b/classes/xnetsession.php index 73dd844..068e6b2 100644 --- a/classes/xnetsession.php +++ b/classes/xnetsession.php @@ -19,20 +19,15 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -class XnetSession extends PlSession +class XnetSession extends XorgSession { public function __construct() { parent::__construct(); - S::bootstrap('perms_backup', new PlFlagSet()); } public function startAvailableAuth() { - if (!(S::v('perms') instanceof PlFlagSet)) { - S::set('perms', S::v('perms_backup')); - } - if (!S::logged() && Get::has('auth')) { if (!$this->start(AUTH_MDP)) { return false; @@ -74,7 +69,6 @@ class XnetSession extends PlSession $perms->addFlag('groupannu'); } S::set('perms', $perms); - S::set('perms_backup', $perms); } return true; } @@ -98,24 +92,20 @@ class XnetSession extends PlSession protected function startSessionAs($user, $level) { - global $globals; - if ($level == -1) { S::set('auth', AUTH_MDP); } - $res = XDB::query('SELECT u.user_id AS uid, prenom, nom, perms, promo, password, FIND_IN_SET(\'femme\', u.flags) AS femme, - a.alias AS forlife, a2.alias AS bestalias, q.core_mail_fmt AS mail_fmt, q.core_rss_hash + $res = XDB::query("SELECT u.user_id AS uid, u.hruid, prenom, nom, perms, promo, password, FIND_IN_SET('femme', u.flags) AS femme, + q.core_mail_fmt AS mail_fmt, q.core_rss_hash FROM auth_user_md5 AS u INNER JOIN auth_user_quick AS q USING(user_id) - INNER JOIN aliases AS a ON (u.user_id = a.id AND a.type = \'a_vie\') - INNER JOIN aliases AS a2 ON (u.user_id = a2.id AND FIND_IN_SET(\'bestalias\', a2.flags)) - WHERE u.user_id = {?} AND u.perms IN(\'admin\', \'user\') - LIMIT 1', $user); + WHERE u.user_id = {?} AND u.perms IN('admin', 'user') + LIMIT 1", $user); $sess = $res->fetchOneAssoc(); $perms = $sess['perms']; unset($sess['perms']); $_SESSION = array_merge($_SESSION, $sess); - $this->makePerms($perms); + S::set('perms', User::makePerms($perms)); S::kill('challenge'); S::kill('loginX'); S::kill('may_update'); @@ -135,7 +125,7 @@ class XnetSession extends PlSession if (!$this->startSUID(S::i('uid'))) { return false; } - $this->makePerms('user'); + S::set('perms', User::makePerms('user')); return true; } @@ -149,30 +139,8 @@ class XnetSession extends PlSession S::kill('may_update'); S::kill('is_member'); S::set('perms', $suid['perms']); - S::set('perms_backup', $suid['perms_backup']); return true; } - - public function makePerms($perm) - { - $flags = new PlFlagSet(); - if ($perm == 'disabled' || $perm == 'ext') { - S::set('perms', $flags); - S::set('perms_backup', $flags); - return; - } - $flags->addFlag(PERMS_USER); - if ($perm == 'admin') { - $flags->addFlag(PERMS_ADMIN); - } - S::set('perms', $flags); - S::set('perms_backup', $flags); - } - - public function sureLevel() - { - return AUTH_MDP; - } } // {{{ function may_update