Changed user settings to be stored as arrays
This commit is contained in:
parent
22e7d3657b
commit
614111a5f0
3 changed files with 7 additions and 7 deletions
|
@ -26,7 +26,7 @@ App.BrowsingSettings = function(
|
||||||
function getDefaultSettings() {
|
function getDefaultSettings() {
|
||||||
return {
|
return {
|
||||||
hideDownvoted: true,
|
hideDownvoted: true,
|
||||||
endlessScroll: true,
|
endlessScroll: false,
|
||||||
listPosts: {
|
listPosts: {
|
||||||
safe: true,
|
safe: true,
|
||||||
sketchy: true,
|
sketchy: true,
|
||||||
|
|
|
@ -16,7 +16,7 @@ class UserEntityConverter extends AbstractEntityConverter implements IEntityConv
|
||||||
'registrationTime' => $this->entityTimeToDbTime($entity->getRegistrationTime()),
|
'registrationTime' => $this->entityTimeToDbTime($entity->getRegistrationTime()),
|
||||||
'lastLoginTime' => $this->entityTimeToDbTime($entity->getLastLoginTime()),
|
'lastLoginTime' => $this->entityTimeToDbTime($entity->getLastLoginTime()),
|
||||||
'avatarStyle' => $entity->getAvatarStyle(),
|
'avatarStyle' => $entity->getAvatarStyle(),
|
||||||
'browsingSettings' => $entity->getBrowsingSettings(),
|
'browsingSettings' => json_encode($entity->getBrowsingSettings()),
|
||||||
'accountConfirmed' => $entity->isAccountConfirmed(),
|
'accountConfirmed' => $entity->isAccountConfirmed(),
|
||||||
'banned' => $entity->isBanned(),
|
'banned' => $entity->isBanned(),
|
||||||
];
|
];
|
||||||
|
@ -33,7 +33,7 @@ class UserEntityConverter extends AbstractEntityConverter implements IEntityConv
|
||||||
$entity->setRegistrationTime($this->dbTimeToEntityTime($array['registrationTime']));
|
$entity->setRegistrationTime($this->dbTimeToEntityTime($array['registrationTime']));
|
||||||
$entity->setLastLoginTime($this->dbTimeToEntityTime($array['lastLoginTime']));
|
$entity->setLastLoginTime($this->dbTimeToEntityTime($array['lastLoginTime']));
|
||||||
$entity->setAvatarStyle(intval($array['avatarStyle']));
|
$entity->setAvatarStyle(intval($array['avatarStyle']));
|
||||||
$entity->setBrowsingSettings($array['browsingSettings']);
|
$entity->setBrowsingSettings(json_decode($array['browsingSettings']));
|
||||||
$entity->setAccountConfirmed($array['accountConfirmed']);
|
$entity->setAccountConfirmed($array['accountConfirmed']);
|
||||||
$entity->setBanned($array['banned']);
|
$entity->setBanned($array['banned']);
|
||||||
return $entity;
|
return $entity;
|
||||||
|
|
|
@ -24,7 +24,7 @@ class UserEditFormData implements \Szurubooru\IValidatable
|
||||||
if ($inputReader->avatarStyle !== null)
|
if ($inputReader->avatarStyle !== null)
|
||||||
$this->avatarStyle = \Szurubooru\Helpers\EnumHelper::avatarStyleFromString($inputReader->avatarStyle);
|
$this->avatarStyle = \Szurubooru\Helpers\EnumHelper::avatarStyleFromString($inputReader->avatarStyle);
|
||||||
$this->avatarContent = $inputReader->decodeBase64($inputReader->avatarContent);
|
$this->avatarContent = $inputReader->decodeBase64($inputReader->avatarContent);
|
||||||
$this->browsingSettings = $inputReader->browsingSettings;
|
$this->browsingSettings = json_decode($inputReader->browsingSettings);
|
||||||
$this->banned = boolval($inputReader->banned);
|
$this->banned = boolval($inputReader->banned);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,9 +52,9 @@ class UserEditFormData implements \Szurubooru\IValidatable
|
||||||
|
|
||||||
if ($this->browsingSettings !== null)
|
if ($this->browsingSettings !== null)
|
||||||
{
|
{
|
||||||
if (!is_string($this->browsingSettings))
|
if (!is_object($this->browsingSettings))
|
||||||
throw new \InvalidArgumentException('Browsing settings must be stringified JSON.');
|
throw new \InvalidArgumentException('Browsing settings must be valid JSON.');
|
||||||
else if (strlen($this->browsingSettings) > 300)
|
else if (strlen(json_encode($this->browsingSettings)) > 300)
|
||||||
throw new \InvalidArgumentException('Stringified browsing settings can have at most 300 characters.');
|
throw new \InvalidArgumentException('Stringified browsing settings can have at most 300 characters.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue