Skip to content

Commit

Permalink
Extend acl no access to deleted polls via public link #773
Browse files Browse the repository at this point in the history
  • Loading branch information
dartcafe committed Jan 27, 2020
1 parent 3b2695e commit 9576e7f
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions lib/Model/Acl.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ public function getIsAdmin(): bool {
public function getAllowView(): bool {
return (
$this->getIsOwner()
|| $this->getIsAdmin()
|| ($this->getIsAdmin() && $this->poll->getAdminAccess())
|| ($this->getGroupShare() && !$this->poll->getDeleted())
|| ($this->getPersonalShare() && !$this->poll->getDeleted())
|| $this->poll->getAccess() !== 'hidden'
|| ($this->getPublicShare() && !$this->poll->getDeleted())
|| ($this->poll->getAccess() !== 'hidden' && !$this->getPublicShare())
);
}

Expand Down Expand Up @@ -213,6 +214,21 @@ public function getPersonalShare(): bool {
);
}

/**
* @NoAdminRequired
* @return bool
*/
public function getPublicShare(): bool {

return count(
array_filter($this->shareMapper->findByPoll($this->getPollId()), function($item) {
if ($item->getType() === 'public' && $item->getToken() === $this->getToken()) {
return true;
}
})
);
}

/**
* @NoAdminRequired
* @return bool
Expand All @@ -233,6 +249,7 @@ public function getAllowVote(): bool {
($this->getAllowView() || $this->getFoundByToken())
&& !$this->getExpired()
&& !$this->poll->getDeleted()
&& $this->userId

) {
return true;
Expand Down Expand Up @@ -368,6 +385,7 @@ public function jsonSerialize(): array {
'allowSeeAllVotes' => $this->getAllowSeeAllVotes(),
'groupShare' => $this->getGroupShare(),
'personalShare' => $this->getPersonalShare(),
'publicShare' => $this->getPublicShare(),
'foundByToken' => $this->getFoundByToken(),
'accessLevel' => $this->getAccessLevel()
];
Expand Down

0 comments on commit 9576e7f

Please sign in to comment.