diff options
author | dartcafe <github@dartcafe.de> | 2022-03-24 01:23:43 +0300 |
---|---|---|
committer | dartcafe <github@dartcafe.de> | 2022-03-24 01:23:43 +0300 |
commit | 3a91570cb414cb141ea2d215342ab68f4f65b754 (patch) | |
tree | c26fdbc745fe4706d85c50e4f5bbe385e632903d /lib | |
parent | 0ec00ec87b6771b87045b06746510250ae070192 (diff) |
migrate access type hidden, public to private, open
Signed-off-by: dartcafe <github@dartcafe.de>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Db/Poll.php | 12 | ||||
-rw-r--r-- | lib/Migration/TableSchema.php | 2 | ||||
-rw-r--r-- | lib/Model/Acl.php | 2 | ||||
-rw-r--r-- | lib/Service/PollService.php | 8 |
4 files changed, 18 insertions, 6 deletions
diff --git a/lib/Db/Poll.php b/lib/Db/Poll.php index 1b4026f8..95ddda25 100644 --- a/lib/Db/Poll.php +++ b/lib/Db/Poll.php @@ -85,6 +85,8 @@ class Poll extends Entity implements JsonSerializable { public const TYPE_TEXT = 'textPoll'; public const ACCESS_HIDDEN = 'hidden'; public const ACCESS_PUBLIC = 'public'; + public const ACCESS_PRIVATE = 'private'; + public const ACCESS_OPEN = 'open'; public const SHOW_RESULTS_ALWAYS = 'always'; public const SHOW_RESULTS_CLOSED = 'closed'; public const SHOW_RESULTS_NEVER = 'never'; @@ -283,6 +285,16 @@ class Poll extends Entity implements JsonSerializable { $this->setOwner($userId); } + public function getAccess() { + if ($this->access === self::ACCESS_PUBLIC) { + return self::ACCESS_OPEN; + } + if ($this->access === self::ACCESS_HIDDEN) { + return self::ACCESS_PRIVATE; + } + return $this->access; + } + public function getProposalsExpired(): bool { return ( $this->getProposalsExpire() > 0 diff --git a/lib/Migration/TableSchema.php b/lib/Migration/TableSchema.php index b9359f2f..d1e8476e 100644 --- a/lib/Migration/TableSchema.php +++ b/lib/Migration/TableSchema.php @@ -150,7 +150,7 @@ abstract class TableSchema { 'created' => ['type' => Types::INTEGER, 'options' => ['notnull' => true, 'default' => 0]], 'expire' => ['type' => Types::INTEGER, 'options' => ['notnull' => true, 'default' => 0]], 'deleted' => ['type' => Types::INTEGER, 'options' => ['notnull' => true, 'default' => 0]], - 'access' => ['type' => Types::STRING, 'options' => ['notnull' => true, 'default' => 'hidden', 'length' => 1024]], + 'access' => ['type' => Types::STRING, 'options' => ['notnull' => true, 'default' => 'private', 'length' => 1024]], 'anonymous' => ['type' => Types::INTEGER, 'options' => ['notnull' => true, 'default' => 0]], 'allow_maybe' => ['type' => Types::INTEGER, 'options' => ['notnull' => true, 'default' => 1]], 'vote_limit' => ['type' => Types::INTEGER, 'options' => ['notnull' => true, 'default' => 0]], diff --git a/lib/Model/Acl.php b/lib/Model/Acl.php index b616dfbe..79dba8d5 100644 --- a/lib/Model/Acl.php +++ b/lib/Model/Acl.php @@ -182,7 +182,7 @@ class Acl implements JsonSerializable { return false; // always deny access, if poll is archived } - if ($this->poll->getAccess() === Poll::ACCESS_PUBLIC) { + if ($this->poll->getAccess() === Poll::ACCESS_OPEN) { return true; // grant access if poll poll is public } diff --git a/lib/Service/PollService.php b/lib/Service/PollService.php index c028680d..85a45bb6 100644 --- a/lib/Service/PollService.php +++ b/lib/Service/PollService.php @@ -222,7 +222,7 @@ class PollService { $this->poll->setOwner($this->userSession->getUser()->getUID()); $this->poll->setTitle($title); $this->poll->setDescription(''); - $this->poll->setAccess(Poll::ACCESS_HIDDEN); + $this->poll->setAccess(Poll::ACCESS_PRIVATE); $this->poll->setExpire(0); $this->poll->setAnonymous(0); $this->poll->setAllowMaybe(0); @@ -259,7 +259,7 @@ class PollService { throw new EmptyTitleException('Title must not be empty'); } - if (isset($poll['access']) && $poll['access'] === (Poll::ACCESS_PUBLIC)) { + if (isset($poll['access']) && $poll['access'] === (Poll::ACCESS_OPEN)) { $this->acl->request(Acl::PERMISSION_ALL_ACCESS); } @@ -328,7 +328,7 @@ class PollService { $this->poll->setOwner($this->userSession->getUser()->getUID()); $this->poll->setTitle('Clone of ' . $origin->getTitle()); $this->poll->setDeleted(0); - $this->poll->setAccess(Poll::ACCESS_HIDDEN); + $this->poll->setAccess(Poll::ACCESS_PRIVATE); $this->poll->setType($origin->getType()); $this->poll->setDescription($origin->getDescription()); @@ -401,7 +401,7 @@ class PollService { * @psalm-return array{0: string, 1: string} */ private function getValidAccess(): array { - return [Poll::ACCESS_HIDDEN, Poll::ACCESS_PUBLIC]; + return [Poll::ACCESS_PRIVATE, Poll::ACCESS_OPEN]; } /** |