A new function that allows determination of a user's eligibility for an upcoming vote.

Note that this would not work if someone had a chronological hook in election_vote_before_grant.

Comments

gausie’s picture

Here is my proposed change. There are no changes to existing API calls.

gausie’s picture

Ah this does not work on latest. I will resubmit.

gausie’s picture

Here is the latest patch with useless things removed!

gausie’s picture

pjcdawkins’s picture

Status: Active » Needs review
liam morland’s picture

Reroll with comment indentation corrected.

liam morland’s picture

Status: Needs review » Needs work

election_vote_access_test() needs documentation.

pjcdawkins’s picture

+++ b/election_vote/election_vote.module
@@ -118,6 +118,12 @@ function election_vote_theme() {
+function election_vote_access_test($op, stdClass $post, $account = NULL, $chronological = FALSE) {

OK. Every function needs at least a docblock describing the parameter and return types.

liam morland’s picture

Instead of creating a new function, it might be better to just add $chronological = TRUE as an argument to the existing function. That way, current calls will behave the same way and you can get the non-chronological version by passing in FALSE.

pjcdawkins’s picture

Status: Needs work » Needs review
StatusFileSize
new1.76 KB

This avoids issues with caching and with the hook.

pjcdawkins’s picture

StatusFileSize
new1.76 KB

Oops, wrong var name

The last submitted patch, 10: election-2387261-10.patch, failed testing.

pjcdawkins’s picture

StatusFileSize
new2.03 KB

Oops again.

liam morland’s picture

Reading the code it looks fine. Does it matter that the "$grants[$post->post_id][$account->uid][$op] = FALSE;" line is not being run?

pjcdawkins’s picture

Yes that was intentional - $grants is a static cache, and with this, the cache isn't involved in the cheap election-is-open check. If that was cached, we'd have to add $only_open to the cache key, which would be a bit of a headache.

pjcdawkins’s picture

Status: Needs review » Fixed

Committed (after 1 year...)

  • pjcdawkins committed 386dfc0 on 7.x-1.x
    Issue #2387261 by gausie, Liam Morland, pjcdawkins: Allow access check...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.