TinyPortal

Development => Block Codes => Topic started by: coolmac112 on November 30, 2009, 06:56:43 PM

Title: Poll Block
Post by: coolmac112 on November 30, 2009, 06:56:43 PM
Hi guys,

I've looked around on this site and have seen a few topics regarding displaying the poll to guests but most of them seem to be outdated so i thought i'd just start a new one. I hope im not going against the rules.

Anyways this is what I want:

I want a block that displays the poll even to guest. They might not have voting powers but it should display [maybe when they click on Vote thats when they get told to login/register] or alternatively there could be not button for them. The guests should NOT also see the results of the poll.

I have tried using the ssi php block and its not showing anything to guests...so what'd make them register if they can't even see?

I hope someone can help.

Cheers
Title: Re: Poll Block
Post by: Ken. on November 30, 2009, 07:44:28 PM
In your membergroup permissions check to make sure that it is set so guests can view polls.

Also, check to see that a guest can view the block.
Title: Re: Poll Block
Post by: coolmac112 on November 30, 2009, 08:03:58 PM
Thanks for the reply.

I have both checked and still there's nothing. I am running smf 1.1.10 by the way. On the portal page the block just appears empty.
Title: Re: Poll Block
Post by: JPDeni on November 30, 2009, 08:18:18 PM
Are you using ssi_showPoll? If so, open up SSI.php, find function ssi_showPoll and delete the lines


$boardsAllowed = boardsAllowedTo('poll_view');

if (empty($boardsAllowed))
return array();


and change


$request = db_query("
SELECT
p.ID_POLL, p.question, p.votingLocked, p.hideResults, p.expireTime, p.maxVotes, b.ID_BOARD
FROM ({$db_prefix}topics AS t, {$db_prefix}polls AS p, {$db_prefix}boards AS b)
WHERE p.ID_POLL = t.ID_POLL
AND t.ID_TOPIC = $topic
AND b.ID_BOARD = t.ID_BOARD
AND $user_info[query_see_board]" . (!in_array(0, $boardsAllowed) ? "
AND b.ID_BOARD IN (" . implode(', ', $boardsAllowed) . ")" : '') . "
LIMIT 1", __FILE__, __LINE__);


to


$request = db_query("
SELECT
p.ID_POLL, p.question, p.votingLocked, p.hideResults, p.expireTime, p.maxVotes, b.ID_BOARD
FROM ({$db_prefix}topics AS t, {$db_prefix}polls AS p, {$db_prefix}boards AS b)
WHERE p.ID_POLL = t.ID_POLL
AND t.ID_TOPIC = $topic
AND b.ID_BOARD = t.ID_BOARD
LIMIT 1", __FILE__, __LINE__);


This should allow everyone to be able to see every poll on your forum, including polls that might be in admin-only boards. I haven't tested it, but it seems that these are the lines that are preventing guests from seeing the polls.
Title: Re: Poll Block
Post by: coolmac112 on December 01, 2009, 06:48:31 AM
Thanks a lot. That did it, with a few tweaks though :)

Great work, I like how its looking now.

Cheers
Title: Re: Poll Block
Post by: JPDeni on December 01, 2009, 06:54:09 AM
Oh, yeah. There's always tweakage to be done. ;) I figure if I point you in the right direction, you can figure out how to get to where you want to go.