added dynamic user preferences #7 #9 (#90)

- fixed user settings database #9
- added dynamic user preferences #9
- added form to edit user preferences #9
- removed user language #7
This commit is contained in:
Kevin Papst
2018-01-14 22:47:20 +01:00
committed by GitHub
parent 023fef6a70
commit 49d8796f6b
23 changed files with 758 additions and 181 deletions

View File

@@ -27,8 +27,20 @@ class UserVoter extends AbstractVoter
const DELETE = 'delete';
const PASSWORD = 'password';
const ROLES = 'roles';
const PREFERENCES = 'preferences';
const VIEW_ALL = 'view_all';
const ALLOWED_ATTRIBUTES = [
self::VIEW,
self::VIEW_ALL,
self::EDIT,
self::CREATE,
self::ROLES,
self::PASSWORD,
self::DELETE,
self::PREFERENCES
];
/**
* @param string $attribute
* @param mixed $subject
@@ -36,10 +48,7 @@ class UserVoter extends AbstractVoter
*/
protected function supports($attribute, $subject)
{
if (!in_array(
$attribute,
[self::VIEW, self::VIEW_ALL, self::EDIT, self::CREATE, self::ROLES, self::PASSWORD, self::DELETE]
)) {
if (!in_array($attribute, self::ALLOWED_ATTRIBUTES)) {
return false;
}
@@ -69,6 +78,7 @@ class UserVoter extends AbstractVoter
return $this->canView($subject, $user, $token);
case self::EDIT:
case self::PASSWORD:
case self::PREFERENCES:
return $this->canEdit($subject, $user, $token);
case self::DELETE:
return $this->canDelete($subject, $user, $token);