Not Eligable to Login/Reg Links?

twstdelf - August 25, 2009 - 20:24
Project:Advanced Poll
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs review
Description

I would like to change the $message for logged out/not registered users to read something more like, "[login] or [register] to vote" (where login and register are links), I have tried a few things, including editing the translations/advpoll.po file, but nothing seems to work... Any advice would be appreciated. :)
Thanks,
TE

#1

aasarava - September 14, 2009 - 03:49

I'm looking into changing the message, too. It seems that the message is output via Drupal's Forms API, so you could theoretically use hook_form_alter() to modify $form['message']. (I haven't tried it yet.)

That said, I took a closer look at the code in binary.inc, for the binary poll, and think there might be a bug. On line 120, the code uses the isset() function to check if $user->uid is set. But this will evaluate to true even if there's an anonymous user viewing the site -- which is why we're seeing the "not eligible" message.

<?php
    $form
['message']['#value'] = isset($user->uid) ? t('You are not eligible     to vote in this poll.') : $login_message;
?>

Anonymous users should see the "log in" message by default. The "not eligible" message should only be shown to logged-in users who are not in an election group (for polls that have it set).

So, it seems like the fix is to stop using the isset() function and just check if $user->uid is greater than 0. Here's the fix:

<?php
    $form
['message']['#value'] = $user->uid ? t('You are not eligible     to vote in this poll.') : $login_message;
?>

Can any of the module co-maintainers confirm this?

#2

dddave - September 25, 2009 - 06:51
Category:feature request» bug report
Status:active» needs review
 
 

Drupal is a registered trademark of Dries Buytaert.