News:

Join the Facebook Fan Page.

Main Menu

SSI Poll Bug?

Started by Zetan, November 23, 2007, 07:52:49 PM

Previous topic - Next topic

Zetan

#20
Ok, When I'm logged in I see:

Quote
Either that poll doesn't exist, the poll has been locked, or you tried to vote twice.
View Topic

Guests see
Quote
Sorry, but you cannot vote in polls in this board.
View Topic

No errors in the logs.

In the topic:
http://labradio.co.uk/index.php/topic,1576.0.html

Guests can see the Poll list, but no option to vote.

metallica48423

smf 1.1 does not allow guests to vote. i believe this was added as an option for version 2.
Justin O'Leary
Ex-Project Manager
Ex-Lead Support Specialist

QuoteMicrosoft wants us to "Imagine life without walls"...
I say, "If there are no walls, who needs Windows?"


Useful Links:
Online Manual!
How to Help us Help you
Search
Settings Repair Tool

Zetan

Hi BlackMage.
I don't want guests to vote.. I want them to see the list like they can in the topic I linked.

I would like the SSI Poll to function the same as it does in topics  :)

SleePy

Zetan,

You want them to see the options but not vote? The code I did just returns those errors to the user explaining why they can't see it.

Well if you want to do that it would be better to actually output the code. But since we have already modded the SSI.php it wouldn't make much difference  :P

Find:
elseif (!empty($row['expireTime']) && $row['expireTime'] > time())
{
if(!$context['user']['is_guest'])
echo $txt['smf27'];
else
echo $txt['cannot_poll_vote'];

}
else
{
echo '
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td colspan="2"><b>', $return['question'], '</b></td>
</tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td align="right" valign="top">', $option['option'], '</td>
<td align="left">', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%)</td>
</tr>';
echo '
<tr>
<td colspan="2"><b>', $txt['smf24'], ': ', $return['total_votes'], '</b></td>
</tr>
</table>';
}


Replace
else
{
echo '
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td colspan="2"><b>', $return['question'], '</b></td>
</tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td align="right" valign="top">', $option['option'], '</td>', (!empty($row['expireTime']) && $row['expireTime'] > time() ? '
<td align="left">' . $option['bar'] . ' ' . $option['votes'] . ' (' . $option['percent'] . '%)</td>' : ''), '
</tr>';
echo '
<tr>
<td colspan="2"><b>', $txt['smf24'], ': ', $return['total_votes'], '</b></td>
</tr>
</table>';
}


I can't say which code or if the devs will even use these examples or if they plan to do anything about it though.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Zetan

lol.. Now we are back where we started, guests and members can see the results.

I hate to see a grown man cry.. but here  :'( pass me a hanky.


:P

SleePy

Sorry about that. I didn't actually test these.

In that code find:
(!empty($row['expireTime']) && $row['expireTime'] > time()

Just flip the > to a < and it should work now

I forgot that with > it is seeing that the expire time is still greater than time() itself and showing. So flipping it will reverse this and not show it until time expires.
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

Zetan

W000TERZ  :D

I think you cracked it this time.. Not sure yet how it behaves with different settings in the poll.
I removed one of my votes and the radio buttons for that poll has displayed.

Thank you for looking into it, and I hope the Devs do provide an update for the next release as I had noticed something odd with it before.. Now running 3 polls side by side, it became more apparent.


Cheers SleePy  :)


ZTN

Nicko!

Hi guys,

I have followed all the steps here; and have it kind of working.

Problem is that only the admin can see the radio buttons in my code. I have it set to display the contents of the topic and then the voting options; only allowing logged in users to vote and not display results until after the poll has expired.

SSI.php has been amended as described; with my code for the display of the poll as follows:


function show_poll()
{
global $table_1, $table_h1, $table_h2, $table_2, $table_3;

echo $table_1 . $table_h1 . "CAST YOUR VOTE" . $table_h2 . $table_2;

$topic = $_GET['item'];
    $link = 'http://www.buscevents.com/community/index.php?topic=' . $topic;
$result = ssi_topicNews($topic, $limit = null, $start = null, $length = null, $link = null, $output_method = 'array');

echo "<img src='/pagesetup/bot_spacer.gif' width=690 height=1><br>";
echo "<div style='float: left; margin: 0 0 0 0;'><img src='/pagesetup/bot_spacer.gif' height=800 width=1></div>";

foreach ($result as $news)
    {
echo "<b>" . $news['subject'] . "</b><p>", $news['body'] . "<br><p>";

ssi_showPoll($topic);

echo '<p><font size=-2>', $news['link'], ' | ', $news['new_comment'], ' | ', $news['time'], ' | ', $news['poster']['link'], '</font>';
    }


echo $table_3;
}


Any thoughts?

[SiNaN]

#28
I got the same problem. Only admins can vote.

//Edit: Have found the answer, thanks akabugeyes.

http://www.simplemachines.org/community/index.php?topic=135131.msg860679#msg860679
Former SMF Core Developer | My Mods | SimplePortal

Kender

i did a hack to get this to work how i wanted.

Guest sees options, with button that is disabled, saying login to vote
user with voting permissions sees options,  with button to vote
admin sees options with button to vote

once voted, you see results (except guest again, who will see disabled options)

FIND (assuming you made changes suggested earlier in the thread)

// Check if they can vote.
if ($user_info['is_guest'] || !empty($row['expireTime']) && $row['expireTime'] < time())
$allow_vote = false;


REPLACE WITH (removing the bit about guests)

// Check if they can vote.
if (!empty($row['expireTime']) && $row['expireTime'] < time())
$allow_vote = false;


FIND

if ($return['allow_vote'])


ADD BEFORE

if ($user_info['is_guest'])
{
echo '
<form action="', $boardurl, '/SSI.php?ssi_function=pollVote" method="post" accept-charset="', $context['character_set'], '">
<input type="hidden" name="poll" value="', $return['id'], '" />
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td><b>', $return['question'], '</b></td>
</tr>
<tr>
<td>', $return['allowed_warning'], '</td>
</tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td><label for="', $option['id'], '">', $option['vote_button'], ' ', $option['option'], '</label></td>
</tr>';
echo '
<tr>
<td><input type="submit" value="Login to Vote" DISABLED /></td>
</tr>
</table>
<input type="hidden" name="sc" value="', $sc, '" />
</form>';
}

This sets up a view for guests only, allowing a view of options, but disabled button

FIND

else
{

echo '
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td colspan="2"><b>', $return['question'], '</b></td>
</tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td align="right" valign="top">', $option['option'], '</td>
<td align="left">', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%)</td>
</tr>';
echo '
<tr>
<td colspan="2"><b>', $txt['smf24'], ': ', $return['total_votes'], '</b></td>
</tr>
</table>';
}
}


REPLACE WITH

else
if (!$user_info['is_guest'])
{

echo '
<table border="0" cellspacing="1" cellpadding="0" class="ssi_table">
<tr>
<td colspan="2"><b>', $return['question'], '</b></td>
</tr>';
foreach ($return['options'] as $option)
echo '
<tr>
<td align="right" valign="top">', $option['option'], '</td>
<td align="left">', $option['bar'], ' ', $option['votes'], ' (', $option['percent'], '%)</td>
</tr>';
echo '
<tr>
<td colspan="2"><b>', $txt['smf24'], ': ', $return['total_votes'], '</b></td>
</tr>
</table>';
}
}

in this part, we are adding a "if user is NOT a guest" but doesn't fit the other criteria, then we show them the results
http://chucknorris2012.com  Avoid a roundhouse kick to the head!  Sign the petition

Advertisement: