-> logged users have the 'user' permission.
-> site administrators have the 'admin' permission.
-> other permissions comes from account_types.
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
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))
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.
}
// 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;
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)
}
// Finalizes the session setup.
- S::set('perms', User::makePerms($perms));
+ $this->makePerms($perms, S::b('is_admin'));
$this->securityChecks();
$this->setSkin();
$this->updateNbNotifs();
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()
-Subproject commit 7c8d7022042ef34cbf8c16531a3b5eaecf46bfd2
+Subproject commit db3659bb4a5790db592359ae50c64ae340a806dd