Disallowing unprivileged users from viewing poll results

Roger Saner - November 4, 2009 - 18:00
Project:Advanced Poll
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review
Description

Use case: a site wants to collect info from users without users being able to see what everyone else voted for. A user can vote, but can't see how many people voted for the different options.

How the current advpoll works: view your advanced poll and vote. You'll see the results of what other people voted for - there's no way to hide those results.

The solution is to create a new permission called 'hide vote results' which hides vote results from the user with that permission to see votes, like so: http://drupal.org/files/advpoll_results.png

The permission is 'hide vote results' instead of 'view vote results' because we want this module to work out-of-the-box with sensible defaults. The default is that most people want their users to be able to view vote results, and only in special cases do we want to hide it.

If a user has the permission 'hide vote results' then this is what they'd see after voting: http://drupal.org/files/advpoll_hide-vote-results_vote.png
Of course, if they don't have the 'cancel own vote' permission then that button wouldn't show up.

Patch attached.

The only addition I can think to add to this is to allow a user to see their own vote, even if they can't see everyone else's.

AttachmentSize
advpoll_results.png12.81 KB
advpoll_hide-vote-results_vote.png11.33 KB

#1

Roger Saner - November 4, 2009 - 18:02

Here's the patch.

AttachmentSize
patch_623426.patch 1.7 KB

#2

Roger Saner - November 6, 2009 - 12:10

I've re-thought this - it doesn't make sense to have the permission be 'hide vote results' because if that is granted to registered users, then no-one can view the results. Much better to grant a 'show vote results' permission to a role. I've changed my patch to reflect that.

AttachmentSize
patch_623426.patch 1.7 KB

#3

Roger Saner - November 6, 2009 - 12:09
Status:active» needs review
 
 

Drupal is a registered trademark of Dries Buytaert.