*/
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')) {
return false;
return false;
}
S::set('user', $user);
+ if (!is_null($perms)) {
+ $this->makePerms($perms, false);
+ }
return true;
}
return (string)S::v($key, $default);
}
+ public static function b($key, $default = false)
+ {
+ return (bool)S::v($key, $default);
+ }
+
public static function i($key, $default = 0)
{
$i = S::v($key, $default);
if (isset($_SESSION['log'])) {
S::logger()->log("suid_start", "login by " . S::user()->login());
}
- Platal::session()->startSUID(S::i('uid'));
- Platal::session()->makePerms($level);
+ Platal::session()->startSUID(S::i('uid'), $level);
pl_redirect('/');
}