Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/polls.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authordartcafe <github@dartcafe.de>2021-03-02 21:32:15 +0300
committerdartcafe <github@dartcafe.de>2021-03-02 21:32:15 +0300
commit7b2e40a4ad0efd84eac7e863748c4e438598ac74 (patch)
treefd738d774148dedbbf14f49181aa2d01f35ce19a /lib
parent902a7a7e066f0a9f8481da6ad8108cf18412573a (diff)
Hide counter and participants, if results are hidden
Signed-off-by: dartcafe <github@dartcafe.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/Model/Acl.php12
-rw-r--r--lib/Service/PollService.php8
2 files changed, 12 insertions, 8 deletions
diff --git a/lib/Model/Acl.php b/lib/Model/Acl.php
index e001afd0..a8c03dff 100644
--- a/lib/Model/Acl.php
+++ b/lib/Model/Acl.php
@@ -187,13 +187,9 @@ class Acl implements JsonSerializable {
case self::PERMISSION_VOTE:
return !$this->poll->getExpired() && $this->share->getType() !== Share::TYPE_PUBLIC;
case self::PERMISSION_SEE_RESULTS:
- if ($this->getIsOwner()) {
- return true;
- } elseif ($this->poll->getShowResults() === Poll::SHOW_RESULTS_ALWAYS) {
- return true;
- } elseif ($this->poll->getShowResults() === Poll::SHOW_RESULTS_CLOSED && $this->poll->getExpired()) {
- return true;
- }
+ return $this->getIsOwner()
+ || $this->poll->getShowResults() === Poll::SHOW_RESULTS_ALWAYS
+ || $this->poll->getShowResults() === Poll::SHOW_RESULTS_CLOSED && $this->poll->getExpired();
break;
case self::PERMISSION_SEE_USERNAMES:
return $this->getIsOwner() || !$this->poll->getAnonymous();
@@ -228,6 +224,8 @@ class Acl implements JsonSerializable {
'userHasVoted' => $this->getUserHasVoted(),
'userId' => $this->getUserId(),
'userIsInvolved' => $this->getUserIsInvolved(),
+ 'pollExpired' => $this->poll->getExpired(),
+ 'pollExpire' => $this->poll->getExpire(),
];
}
diff --git a/lib/Service/PollService.php b/lib/Service/PollService.php
index b92dad06..f161affd 100644
--- a/lib/Service/PollService.php
+++ b/lib/Service/PollService.php
@@ -237,8 +237,14 @@ class PollService {
if (isset($poll['title']) && !$poll['title']) {
throw new EmptyTitleException('Title must not be empty');
}
- $this->poll->deserializeArray($poll);
+ // Set the expiry time to the actual servertime to avoid an
+ // expiry misinterpration when using acl
+ if (isset($poll['expire']) && $poll['expire']) {
+ $poll['expire'] = time();
+ }
+
+ $this->poll->deserializeArray($poll);
$this->pollMapper->update($this->poll);
$this->watchService->writeUpdate($this->poll->getId(), Watch::OBJECT_POLLS);
$this->logService->setLog($this->poll->getId(), Log::MSG_ID_UPDATEPOLL);