diff options
Diffstat (limited to 'lib/Model/Acl.php')
-rw-r--r-- | lib/Model/Acl.php | 77 |
1 files changed, 14 insertions, 63 deletions
diff --git a/lib/Model/Acl.php b/lib/Model/Acl.php index 71319436..10760008 100644 --- a/lib/Model/Acl.php +++ b/lib/Model/Acl.php @@ -53,9 +53,6 @@ class Acl implements JsonSerializable { /** @var string */ private $token = ''; - /** @var bool */ - private $foundByToken = false; - /** @var string */ private $userId; @@ -77,7 +74,6 @@ class Acl implements JsonSerializable { /** @var Poll */ private $poll; - /** * Acl constructor. * @param string $appName @@ -129,27 +125,20 @@ class Acl implements JsonSerializable { } } - /** * @NoAdminRequired - * @return bool + * @return string */ - public function setPollIdOrToken($pollId = 0, $token = '') { - - if ($token) { - $this->setToken($token); - } elseif ($pollId) { - $this->setPollId($pollId); - } - - return $this; + public function getIsExternalUser() { + return !($this->userManager->get($this->userId) instanceof IUser); } + /** * @NoAdminRequired * @return bool */ - public function checkAuthorize($pollId = 0, $token = '') { + public function setPollIdOrToken($pollId = 0, $token = '') { if ($token) { $this->setToken($token); @@ -157,7 +146,7 @@ class Acl implements JsonSerializable { $this->setPollId($pollId); } - return ($this->userId && $this->poll->getId()); + return $this; } /** @@ -309,17 +298,10 @@ class Acl implements JsonSerializable { * @return bool */ public function getAllowVote(): bool { - if ( - ($this->getAllowView() || $this->getFoundByToken()) + return ($this->getAllowView() || $this->getToken()) && !$this->getExpired() && !$this->poll->getDeleted() - && $this->userId - - ) { - return true; - } else { - return false; - } + && $this->userId; } /** @@ -343,15 +325,9 @@ class Acl implements JsonSerializable { * @return bool */ public function getAllowSeeResults(): bool { - if ($this->poll->getShowResults() === 'always' || $this->getIsOwner()) { - return true; - } elseif ($this->poll->getShowResults() === 'never') { - return false; - } elseif ($this->poll->getShowResults() === 'expired') { - return $this->getExpired(); - } else { - return false; - } + return $this->poll->getShowResults() === 'always' + || ($this->poll->getShowResults() === 'expired' && $this->getExpired()) + || $this->getIsOwner(); } /** @@ -359,28 +335,7 @@ class Acl implements JsonSerializable { * @return bool */ public function getAllowSeeUsernames(): bool { - return !($this->poll->getAnonymous() && !$this->getIsOwner()); ; - } - - /** - * @NoAdminRequired - * @return bool - */ - public function getAllowSeeAllVotes(): bool { - // TODO: preparation for polls without displaying other votes - if ($this->pollId) { - return true; - } else { - return false; - } - } - - /** - * @NoAdminRequired - * @return bool - */ - public function getFoundByToken(): bool { - return $this->foundByToken; + return !$this->poll->getAnonymous() || $this->getIsOwner(); } /** @@ -401,7 +356,6 @@ class Acl implements JsonSerializable { $this->token = $token; $share = $this->shareMapper->findByToken($token); - $this->foundByToken = true; $this->setPollId($share->getPollId()); \OC::$server->getLogger()->debug('Share PollId: ' . $share->getPollId()); @@ -410,7 +364,6 @@ class Acl implements JsonSerializable { $this->setPollId(0); $this->setUserId(null); $this->token = ''; - $this->foundByToken = false; } else if (($share->getType() === 'group' || $share->getType() === 'public') && \OC::$server->getUserSession()->isLoggedIn()) { // Use user name of authorized user shareType public and group if user is logged in $this->setUserId($this->userId); @@ -423,7 +376,6 @@ class Acl implements JsonSerializable { $this->setPollId(0); $this->setUserId(null); $this->token = ''; - $this->foundByToken = false; } return $this; } @@ -436,6 +388,7 @@ class Acl implements JsonSerializable { 'userId' => $this->getUserId(), 'displayName' => $this->getDisplayName(), 'loggedIn' => $this->getLoggedIn(), + 'externalUser' => $this->getIsExternalUser(), 'pollId' => $this->getPollId(), 'token' => $this->getToken(), 'isOwner' => $this->getIsOwner(), @@ -446,12 +399,10 @@ class Acl implements JsonSerializable { 'allowEdit' => $this->getAllowEdit(), 'allowSeeResults' => $this->getAllowSeeResults(), 'allowSeeUsernames' => $this->getAllowSeeUsernames(), - 'allowSeeAllVotes' => $this->getAllowSeeAllVotes(), 'userHasVoted' => $this->getUserHasVoted(), 'groupShare' => $this->getGroupShare(), 'personalShare' => $this->getPersonalShare(), - 'publicShare' => $this->getPublicShare(), - 'foundByToken' => $this->getFoundByToken() + 'publicShare' => $this->getPublicShare() ]; } } |