initial (wip) for new prefs
This commit is contained in:
parent
922a699215
commit
988eb3ac91
|
@ -124,12 +124,12 @@ class Config {
|
||||||
|
|
||||||
list ($defval, $deftype) = $this::_DEFAULTS[$const];
|
list ($defval, $deftype) = $this::_DEFAULTS[$const];
|
||||||
|
|
||||||
$this->params[$cvalue] = [ $this->cast_to(!empty($override) ? $override : $defval, $deftype), $deftype ];
|
$this->params[$cvalue] = [ self::cast_to(!empty($override) ? $override : $defval, $deftype), $deftype ];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function cast_to(string $value, int $type_hint) {
|
static function cast_to(string $value, int $type_hint) {
|
||||||
switch ($type_hint) {
|
switch ($type_hint) {
|
||||||
case self::T_BOOL:
|
case self::T_BOOL:
|
||||||
return sql_bool_to_bool($value);
|
return sql_bool_to_bool($value);
|
||||||
|
@ -149,7 +149,7 @@ class Config {
|
||||||
private function _add(string $param, string $default, int $type_hint) {
|
private function _add(string $param, string $default, int $type_hint) {
|
||||||
$override = getenv($this::_ENVVAR_PREFIX . $param);
|
$override = getenv($this::_ENVVAR_PREFIX . $param);
|
||||||
|
|
||||||
$this->params[$param] = [ $this->cast_to(!empty($override) ? $override : $default, $type_hint), $type_hint ];
|
$this->params[$param] = [ self::cast_to(!empty($override) ? $override : $default, $type_hint), $type_hint ];
|
||||||
}
|
}
|
||||||
|
|
||||||
static function add(string $param, string $default, int $type_hint = Config::T_STRING) {
|
static function add(string $param, string $default, int $type_hint = Config::T_STRING) {
|
||||||
|
|
|
@ -354,10 +354,12 @@ class Handler_Public extends Handler {
|
||||||
$remember_me = clean($_POST["remember_me"] ?? false);
|
$remember_me = clean($_POST["remember_me"] ?? false);
|
||||||
$safe_mode = checkbox_to_sql_bool(clean($_POST["safe_mode"] ?? false));
|
$safe_mode = checkbox_to_sql_bool(clean($_POST["safe_mode"] ?? false));
|
||||||
|
|
||||||
if ($remember_me) {
|
if (session_status() != PHP_SESSION_ACTIVE) {
|
||||||
@session_set_cookie_params(Config::get(Config::SESSION_COOKIE_LIFETIME));
|
if ($remember_me) {
|
||||||
} else {
|
session_set_cookie_params(Config::get(Config::SESSION_COOKIE_LIFETIME));
|
||||||
@session_set_cookie_params(0);
|
} else {
|
||||||
|
session_set_cookie_params(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (UserHelper::authenticate($login, $password)) {
|
if (UserHelper::authenticate($login, $password)) {
|
||||||
|
|
|
@ -1370,6 +1370,8 @@ class Pref_Prefs extends Handler_Protected {
|
||||||
|
|
||||||
static function _init_user_prefs($uid, $profile = false) {
|
static function _init_user_prefs($uid, $profile = false) {
|
||||||
|
|
||||||
|
Prefs::initialize($uid, $profile);
|
||||||
|
|
||||||
if (get_schema_version() < 63) $profile_qpart = "";
|
if (get_schema_version() < 63) $profile_qpart = "";
|
||||||
|
|
||||||
$pdo = Db::pdo();
|
$pdo = Db::pdo();
|
||||||
|
|
|
@ -18,7 +18,9 @@ class UserHelper {
|
||||||
|
|
||||||
if ($user_id && !$check_only) {
|
if ($user_id && !$check_only) {
|
||||||
|
|
||||||
session_start();
|
if (session_status() != PHP_SESSION_ACTIVE)
|
||||||
|
session_start();
|
||||||
|
|
||||||
session_regenerate_id(true);
|
session_regenerate_id(true);
|
||||||
|
|
||||||
$_SESSION["uid"] = $user_id;
|
$_SESSION["uid"] = $user_id;
|
||||||
|
|
Loading…
Reference in New Issue