Download & Extend

Results tab not displayed

Project:Advanced Poll
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work

Issue Summary

I've created two polls, and when logged in as a user that has rights to view results, there is no Results tab. I get the Votes tab, though. There are no other modules (such as Decisions) that would conflict with this as far as I know.

Comments

#1

Status:active» needs review

I had the same thing. What's happening is there is incorrect logic within the function which checks if the results tab should be displayed.

Firstly, it only displays the results tab if the current user has voted on the poll (it shouldn't) and secondly, it doesn't even check if the user has the 'inspect all votes' permission.

I've attached a patch to fix it.

AttachmentSize
patch_546518.patch 518 bytes

#2

How should I apply this patch? To which file? Thanks in advance.

#3

@mpray, you can apply the patch by following the directions at http://drupal.org/patch/apply

#4

I don't think that patch has quite the right logic

<?php
-  return strstr($node->type, 'advpoll_') && _advpoll_is_active($node) && $node->votes > 0 && !$node->voted && _advpoll_can_view_results($node);
?>

if
type is advpoll
poll is active
voted
user hasn't voted
can see results

<?php
+  return strstr($node->type, 'advpoll_') && _advpoll_is_active($node) && $node->votes > 0 && user_access('inspect all votes') && _advpoll_can_view_results($node);
?>

if
type is advpoll
poll is active
voted
"user can inspect all votes"
advpoll can view results

From what I understand, in the first case the result tab is shown when the result aren't shown in the node itself; in the second case results are shown ONLY under some of the circumstances and user has inspect all votes.

Results are not determinded by the permission, but by the node type settings. What this issue should be (and I'll change to, but feel free to set it back if I'm not understanding) is to make the result tab by permission also.

Anyhow, in order for the results to actually shown, actually need to edit the advpool can view results function or else it doesn't actually show.

2 patches, one that does that, one that replaces str str with an in_array because they were bothering me.

AttachmentSize
strstr bothers me 1.68 KB
The actually patch 651 bytes

#5

thanks roger. got it to run. new to drupal. thanks for the help.

#6

I unfortunately have the same problem, and despite digging around in the code to debug and applying the various patches that exist i can't get the Results tab to be displayed at all. I get the results of the poll, but i really need to be able to see individual results so that i can contact those who voted in a particular way ( for example, choosing a date ). I've attached an image of the current view.

For my user, user_access('inspect all votes') returns 1.
I've removed the check for if i have voted or not.
I've also updated the strstr with the in_array patch that was mentioned.

I've also attached screenshots of my current permissions and the list of the user that i am using.

Help!!!!

AttachmentSize
pollresults.jpg 35.86 KB
pollperms.jpg 77.12 KB
polluser.jpg 15.49 KB

#7

Note the related thread

#754812: show votes to administrators

As i see is the fix overthere not yet covered by the permission code overhaul happening here.
If someone does even more rework and completes the ckecks here, please mark the other duplicate.

#8

Status:needs review» needs work

hefox
Removing the strstr sounds reasonable in general. however you're doing this for a very expensive price.
All mode "plugins" get loaded, many functions called, ...
In general i see your point. But advpoll currently already is a huge mess regarding performance.

I also don't see why you're checking for && empty($node->voted) ...
I'd even expect the results tab always to be shown - even if no answers. it should contain a message!

Do you see any suggestion how to improve that situation?

#9

+1

#10

Moved my strstr feature request into own issue, #987462: check advpoll_node_info instead of strstr to determine if advpoll type?. (as for performance, that's what static cache is for!)

#11

Status:needs work» needs review

Right, since _advpoll_results_access is already checking !$node->voted.

Update patch, removing the check for vote counts; there's already an empty text so that fallback gracefully.

Added some comments to explain why each check is done in _advpoll_results_access

AttachmentSize
546518_advpoll_perm.patch 1.16 KB

#12

Status:needs review» needs work

I like the description.

Why do we need to remove the tab if the results show (by default theming) in the body?

If we remove the results from the default theming, it should still be possible to visit the unique results page URL.
So i consider outputting this content only a theming composition, while visiting the formal results is a separate use case.

If the tab always shows for people permitted to view the result

#13

Hi I just ran into a comparable problem, only it's the "votes" tab that never shows, not even for user 1. And if you go there the hard way, by URL, node/7/votes for example you get the "You are not authorized to access this page." Not even user 1 either.
Now that I look at it, results tab never shows up either, but we don't use it so I didn't miss it.

This did work correctly in the D5 version, which we are now finally trying to bring to D6.

Disabling advpoll brings the votes tab & access back. So that's an easy solution, but it would be nice to be able to use the additional options.