Hi,
Souldn't we check if the user can set priorities or see a survey's results before displaying a link? If so we should replace if ($status < 2) { by if ($status < 2 && priorities_set_access($survey)) { ligne 1268 and if (in_array($status, array(0, 2))) { by if (in_array($status, array(0, 2)) && priorities_get_access($survey)) { ligne 1274.
Regards,
Comments
Comment #1
gibus commentedActually user access seems to be already checked line 1257, resulting that when checking the status of each survey in a list of surveys, this list includes only surveys which the current users has access to.
Comment #2
ec commentedHum, hum ...
Here is my test case. Whith out those new checks, if for example you have a "closed" survey, then an anonymous user with out the permission to see the results, will see a link to the results page but will receive an "access denied" while trying to access that page! Hence adding those 2 checks will prevent displaying something a user will not be able to access later.
Comment #3
gibus commentedJust to be sure, in your test case, has anonymous user the permission to set the survey?
Comment #4
ec commentedYes but this doesn't change anything as long as the feature "anonymous voting" in not allowed. You have a similar scenario for a survey in public status. Imagine that logged in user can set the priorities but can't see the results unless they belong to a second role. In this case the user will be able to vote, he will see the link to go to the results page while he hasn't got the right to see them. Hence for consistency and to not confuse the user we need to check his acces rights before displaying any link.
Comment #5
gibus commentedOK, I need to test this carefully. In addition to your proposed fixes, the check already in place line 1257 seems to need some testing and/or completly removed if your additional checks are implemented. I need some time (I'm not supposed to work today) but I think I'll do a release next week, with this fix and all minor fixes already comitted. Then, I'll release your proposed enhancements.
Comment #6
ec commentedOk, thanks a lot for looking at this. In fact I have more mods for
theme_priorities_surveys()as in my understanding, there is no need to checkempty($survey)at the beginning of the function. Indeed if there is no survey the user will never access an empty page aspriorities_overview_access()will always return "false" and hence, we will always receive an "access denied" message.Hence, please see below, my rewrite of this function (which comes whith all the enhancements). I'm currently using it on my test platform ... and so far so good! Though you may find something hidden somewhere.
Regards,
Comment #7
gibus commentedOK, I've committed a fix and published a new release 6.x-2.17 including previous minor patches.
Finally I've fixed priorities_overview_access() to let theme_priorities_surveys display something in case there is no survey. And I've also kept (as in your proposed source code) the initial check with "priorities_get_set_access" since it also allows to display a specific message when the user has no rights on any survey.
Next release will include your proposed enhancement patches...
Comment #8
ec commentedOk works as expected. We can see now the message if there is no survey. For consistency of the display I suggest to use
drupal_set_message(). Here is a proposal:instead of: