From: Florent Bruneau Date: Mon, 22 Dec 2008 16:47:36 +0000 (+0100) Subject: Use permissions from account_types: X-Git-Tag: xorg/1.0.0~332^2~475 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=365ba8c32d586aeec614b69fca8c9d566713d488;p=platal.git Use permissions from account_types: -> logged users have the 'user' permission. -> site administrators have the 'admin' permission. -> other permissions comes from account_types. Signed-off-by: Florent Bruneau --- diff --git a/classes/user.php b/classes/user.php index f4c2732..616ce56 100644 --- a/classes/user.php +++ b/classes/user.php @@ -139,8 +139,11 @@ class User extends PlUser CONCAT(af.alias, '@{$globals->mail->domain}') AS forlife, CONCAT(ab.alias, '@{$globals->mail->domain}') AS bestalias, a.full_name, a.display_name, a.sex = 'female' AS gender, - a.email_format, a.state AS perms + a.email_format, + IF (a.state = 'active', at.perms, '') AS perms, + a.is_admin FROM accounts AS a + INNER JOIN account_types AS at ON (at.type = a.type) INNER JOIN profile_display AS d ON (d.uid = a.uid) LEFT JOIN aliases AS af ON (af.id = a.uid AND af.type = 'a_vie') LEFT JOIN aliases AS ab ON (ab.id = a.uid AND FIND_IN_SET('bestalias', ab.flags)) @@ -195,7 +198,7 @@ class User extends PlUser if ($this->perms === null) { $this->loadMainFields(); } - $this->perm_flags = self::makePerms($this->perms); + $this->perm_flags = self::makePerms($this->perms, $this->is_admin); } /** Return the main profile attached with this account if any. @@ -206,14 +209,11 @@ class User extends PlUser } // Return permission flags for a given permission level. - public static function makePerms($perms) + public static function makePerms($perms, $is_admin) { - $flags = new PlFlagSet(); - if (is_null($flags) || $perms == 'disabled' || $perms == 'ext') { - return $flags; - } + $flags = new PlFlagSet($perms); $flags->addFlag(PERMS_USER); - if ($perms == 'admin') { + if ($is_admin) { $flags->addFlag(PERMS_ADMIN); } return $flags; diff --git a/classes/xorgsession.php b/classes/xorgsession.php index ed3382d..c0166fd 100644 --- a/classes/xorgsession.php +++ b/classes/xorgsession.php @@ -192,8 +192,9 @@ class XorgSession extends PlSession UNIX_TIMESTAMP(q.banana_last) AS banana_last, q.watch_last, q.last_version, g.g_account_name IS NOT NULL AS googleapps, UNIX_TIMESTAMP(s.start) AS lastlogin, s.host, - IF(a.is_admin, 'admin', 'user') AS perms + a.is_admin, at.perms FROM accounts AS a + INNER JOIN account_types AS at ON(a.type = at.type) INNER JOIN auth_user_quick AS q ON(a.uid = q.user_id) LEFT JOIN gapps_accounts AS g ON(a.uid = g.l_userid AND g.g_status = 'active') LEFT JOIN logger.last_sessions AS ls ON (ls.uid = a.uid) @@ -224,7 +225,7 @@ class XorgSession extends PlSession } // Finalizes the session setup. - S::set('perms', User::makePerms($perms)); + $this->makePerms($perms, S::b('is_admin')); $this->securityChecks(); $this->setSkin(); $this->updateNbNotifs(); @@ -271,18 +272,9 @@ class XorgSession extends PlSession return null; } - public function makePerms($perm) + protected function makePerms($perm, $is_admin) { - $flags = new PlFlagSet(); - if ($perm == 'disabled' || $perm == 'ext') { - S::set('perms', $flags); - return; - } - $flags->addFlag(PERMS_USER); - if ($perm == 'admin') { - $flags->addFlag(PERMS_ADMIN); - } - S::set('perms', $flags); + S::set('perms', User::makePerms($perm, $is_admin)); } public function setSkin() diff --git a/core b/core index 7c8d702..db3659b 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 7c8d7022042ef34cbf8c16531a3b5eaecf46bfd2 +Subproject commit db3659bb4a5790db592359ae50c64ae340a806dd