From c72aab299fb842fb60ac56957dbb750f661a08b5 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 7 Aug 2013 16:28:07 +0200 Subject: [PATCH] Fixed display of poll participants for guests --- com.woltlab.wcf/templates/poll.tpl | 25 ++++++++++++------- .../files/lib/data/poll/Poll.class.php | 13 ++++++++++ .../files/lib/data/poll/PollAction.class.php | 7 +++++- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/com.woltlab.wcf/templates/poll.tpl b/com.woltlab.wcf/templates/poll.tpl index d33fbf93ea..ef272e2c23 100644 --- a/com.woltlab.wcf/templates/poll.tpl +++ b/com.woltlab.wcf/templates/poll.tpl @@ -1,4 +1,4 @@ -{if $__wcf->getUser()->userID && !$__pollLoadedJavaScript|isset} +{if ($__wcf->getUser()->userID || $poll->canSeeResult() || $poll->canViewParticipants()) && !$__pollLoadedJavaScript|isset} {assign var=__pollLoadedJavaScript value=true} {/if} -
+
{$poll->question} {#$poll->votes} @@ -33,13 +33,20 @@
- {if $__wcf->getUser()->userID} + {hascontent}
- - - - - {event name='pollButtons'} + {content} + {if $__wcf->getUser()->userID} + + + + {/if} + {if $poll->canViewParticipants()} + + {/if} + + {event name='pollButtons'} + {/content}
- {/if} + {/hascontent}
\ No newline at end of file diff --git a/wcfsetup/install/files/lib/data/poll/Poll.class.php b/wcfsetup/install/files/lib/data/poll/Poll.class.php index 1f2791a336..71a63723a6 100644 --- a/wcfsetup/install/files/lib/data/poll/Poll.class.php +++ b/wcfsetup/install/files/lib/data/poll/Poll.class.php @@ -165,6 +165,19 @@ class Poll extends DatabaseObject { return false; } + /** + * Returns true if current user can view the participant list. + * + * @return boolean + */ + public function canViewParticipants() { + if ($this->canSeeResult() && $this->isPublic) { + return true; + } + + return false; + } + /** * Sets related object for this poll. * diff --git a/wcfsetup/install/files/lib/data/poll/PollAction.class.php b/wcfsetup/install/files/lib/data/poll/PollAction.class.php index 6e7049ed51..437a97c023 100644 --- a/wcfsetup/install/files/lib/data/poll/PollAction.class.php +++ b/wcfsetup/install/files/lib/data/poll/PollAction.class.php @@ -19,6 +19,11 @@ use wcf\system\WCF; * @category Community Framework */ class PollAction extends AbstractDatabaseObjectAction implements IGroupedUserListAction { + /** + * @see wcf\data\AbstractDatabaseObjectAction::$allowGuestAccess + */ + protected $allowGuestAccess = array('getGroupedUserList'); + /** * @see wcf\data\AbstractDatabaseObjectAction::$className */ @@ -245,7 +250,7 @@ class PollAction extends AbstractDatabaseObjectAction implements IGroupedUserLis if (!$this->poll->pollID) { throw new UserInputException('pollID'); } - else if (!$this->poll->isPublic || !$this->poll->canSeeResult()) { + else if (!$this->poll->canViewParticipants()) { throw new PermissionDeniedException(); } } -- 2.20.1