Closed (fixed)
Project:
Fivestar
Version:
5.x-1.7
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
18 May 2007 at 09:47 UTC
Updated:
29 Apr 2010 at 00:54 UTC
Jump to comment: Most recent file
Anonymous users do not have the "view ratings" permission of the fivestar module on my site (in fact none of the three fivestar permissions are set for anonymous users). Nevertheless, the fivestar widget and the average ratings are shown for anonymous users. The widget itself can be clicked, but it does nothing (no vote is submitted).
The widget and the average ratings should not be shown when the corresponding permission is unchecked for a user role.
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | fivestar.module.patch | 506 bytes | yched |
| #13 | fivestar.module.patch | 933 bytes | jhedstrom |
| #7 | fivestar_perms.patch | 6 KB | edrex |
Comments
Comment #1
hgmichna commentedPriority critical for a display problem that doesn't have any functional implication? Oh well ...
Comment #2
katin commentedHere is the code patch to implement this feature:
At line 274 of the current version of fivestar.module:
Comment #3
katin commentedHere's the better patch, one that works for all role permissions and is set up to allow future Javascript support of different form behavior based on "view ratings" and "rate content" permissions:
Comment #4
katin commentedDoh - forgot we don't need $user anymore... and, since we are down to one conditional, we can just add it to the if statement already in place. Here's an even better patch, same place in the file:
This tested fine on my site. The "view ratings" permission now overrides the "rate content" permission, so presently, the logic is: if you aren't allowed to see the ratings then you aren't allowed to vote.
Comment #5
raintonr commentedThis patch works for removing the whole form when viewing is not allowed. However, this isn't how I imagine the function should work.
When viewing is allowed the current rating should be shown at least. If voting by authenticated users is allowed a message such as, 'Login to vote' should then be shown. Or of course the 'Your Vote' part if the user is logged in.
Comment #6
quicksketchIndeed, this a fairly significant (and misleading) bug. It did something very, very early in development, but has just sat there ever since.
raintonr has some good suggestions on usability that would be good to include in this request. Also, an update function in the .install file will be necessary for this request, since the access permission currently doesn't do anything, it should be enabled on all sites during the upgrade process.
Also, please submit changes as patches: http://drupal.org/patch/create
Comment #7
edrex commented#2 could well be an option in the fivestar admin page
[x]'show "login to vote..." links", but it should go in as a separate patch....
time passes
...
Well I had a patch going but then I saw that the summary results are being done on the client-side. This makes no sense to me, since they are already being calculated on the server and sent over the wire by fivestar_vote() in the "" tag. How about we just display the contents of that tag so we don't need so much javascript? (yes, javascript is pretty)
Here is the beginning of a patch. I shifted all of the '#type'=> 'hidden' form elts to 'value', which prevents them being sent to the client (since they shouldn't be). This breaks the javascript markup generation for the results, but since a markup string for the result is already being passed back, this code is redundant. If somebody wants to finish this by fixing the JS I'll work on it more.
Comment #8
quicksketchI'm still interested in committing this if we can finish the work. edrex's last patch made good headway but has some additional problems also:
The
needs to stay intact, as fivestar_form() is meant as a public function that can be called independently. We need to ensure the javascript is always added if the form is being displayed.
Second, this will need an _update hook in fivestar.install. We'd have a lot of shocked users if no one could see the results suddenly! It should just set the permission "view fivestar results" to TRUE for all roles, since this is effectively what the current setting is.
Comment #9
quicksketchI've removed the 'view rating' permission entirely for the time being, since it doesn't do anything. This makes this thread a feature request. :)
Comment #10
ekrispin commentedI agrre with raintor. This is the behavior adapted in community portals (e.g. see in youtube.com - when you are not logged in you can only view the rating and you get a message to login in order to be able to vote...)
Comment #11
drywall commentedI'm with raintor and ekrispin; stars should be hidden with some t() text to the effect of "login to vote"
Comment #12
ekrispin commentedHas someone managed to adjust Fivestar functionality to the popular way of allowing all to view the average score and displaying 'Login to vote' for anonymous users?
Comment #13
jhedstromIn order to get the static version of the stars to show for users without rating access, I simply checked for user_access('rate content'), and if it returned false, I fall through to the static version instead of calling the form.
Attached is the patch.
Comment #14
yched commentedMay I suggest this patch instead (operates inside fivestar_custom_widget() - same effect, but also handles the case where fivestar_widget_form($node) is called directly)
Comment #15
quicksketchI committed #13 with some enhancements. If the display is set to the 'smart', 'combo', or 'user' styles but the user is not allowed to vote, the static version falls back to average. There wouldn't be much point in displaying the user's rating if they weren't allowed to vote!
yched, I didn't use the approach in #14 because not displaying the vote widget would only work if the display was 'dual', because then the static widget is already loaded. In all other cases it would prevent any thing from displaying at all.
I didn't add a 'login to vote' text because like edrex mentioned, it doesn't make sense in all cases. What if only moderators or site admins are allowed to vote? Telling a user to login to vote is misleading. If we can come up with a sound solution we'll implement it, but in the mean time you can over ride theme_fivestar_static_element() to display a message when the description is empty and the current user is anonymous.
I'm keeping the issue open because we haven't yet addressed the 'view ratings' permission. Any takers to put the final nail in this one?
Comment #16
jhedstrom[edit] nevermind, I wasn't looking at cvs head
Comment #17
quicksketchLooks like there's a patch for 'view ratings' permission in progress here: http://drupal.org/node/221181, we'll continue discussion on that topic there.
Comment #18
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #19
andrewsuth commented+1 to display "login to vote" as an OPTION in the module configuration.
You're right that it does not apply to all cases, like in the example you gave above, but I think the majority of Drupal developers implement fivestar for authenticated users and not just moderators or administrators.
I think it would be a really good option.