Changed user settings to be stored as arrays

This commit is contained in:
Marcin Kurczewski 2014-10-03 20:55:37 +02:00
parent 22e7d3657b
commit 614111a5f0
3 changed files with 7 additions and 7 deletions

View file

@ -26,7 +26,7 @@ App.BrowsingSettings = function(
function getDefaultSettings() {
return {
hideDownvoted: true,
endlessScroll: true,
endlessScroll: false,
listPosts: {
safe: true,
sketchy: true,

View file

@ -16,7 +16,7 @@ class UserEntityConverter extends AbstractEntityConverter implements IEntityConv
'registrationTime' => $this->entityTimeToDbTime($entity->getRegistrationTime()),
'lastLoginTime' => $this->entityTimeToDbTime($entity->getLastLoginTime()),
'avatarStyle' => $entity->getAvatarStyle(),
'browsingSettings' => $entity->getBrowsingSettings(),
'browsingSettings' => json_encode($entity->getBrowsingSettings()),
'accountConfirmed' => $entity->isAccountConfirmed(),
'banned' => $entity->isBanned(),
];
@ -33,7 +33,7 @@ class UserEntityConverter extends AbstractEntityConverter implements IEntityConv
$entity->setRegistrationTime($this->dbTimeToEntityTime($array['registrationTime']));
$entity->setLastLoginTime($this->dbTimeToEntityTime($array['lastLoginTime']));
$entity->setAvatarStyle(intval($array['avatarStyle']));
$entity->setBrowsingSettings($array['browsingSettings']);
$entity->setBrowsingSettings(json_decode($array['browsingSettings']));
$entity->setAccountConfirmed($array['accountConfirmed']);
$entity->setBanned($array['banned']);
return $entity;

View file

@ -24,7 +24,7 @@ class UserEditFormData implements \Szurubooru\IValidatable
if ($inputReader->avatarStyle !== null)
$this->avatarStyle = \Szurubooru\Helpers\EnumHelper::avatarStyleFromString($inputReader->avatarStyle);
$this->avatarContent = $inputReader->decodeBase64($inputReader->avatarContent);
$this->browsingSettings = $inputReader->browsingSettings;
$this->browsingSettings = json_decode($inputReader->browsingSettings);
$this->banned = boolval($inputReader->banned);
}
}
@ -52,9 +52,9 @@ class UserEditFormData implements \Szurubooru\IValidatable
if ($this->browsingSettings !== null)
{
if (!is_string($this->browsingSettings))
throw new \InvalidArgumentException('Browsing settings must be stringified JSON.');
else if (strlen($this->browsingSettings) > 300)
if (!is_object($this->browsingSettings))
throw new \InvalidArgumentException('Browsing settings must be valid JSON.');
else if (strlen(json_encode($this->browsingSettings)) > 300)
throw new \InvalidArgumentException('Stringified browsing settings can have at most 300 characters.');
}
}