I found this written by SiNaN but it doesn't load the polls at all, just a blank block and it causes everything under the block preview to not even load. Am I doing something wrong? Those poll-ids are the topic id's the poll is tied to.
global $db_prefix, $user_info, $boarddir, $ID_MEMBER;
require_once($boarddir . '/SSI.php');
$poll_ids = array(15, 16, 17);
$boardsAllowed = boardsAllowedTo('poll_view');
$request = db_query("
SELECT t.ID_TOPIC
FROM ({$db_prefix}polls AS p, {$db_prefix}boards AS b, {$db_prefix}topics AS t)
LEFT JOIN {$db_prefix}log_polls AS lp ON (lp.ID_POLL = p.ID_POLL AND lp.ID_MEMBER = $ID_MEMBER)
WHERE p.votingLocked = 0
AND lp.ID_CHOICE IS NULL
AND t.ID_POLL = p.ID_POLL
AND b.ID_BOARD = t.ID_BOARD
AND $user_info[query_see_board]" . (!in_array(0, $boardsAllowed) ? "
AND b.ID_BOARD IN (" . implode(', ', $boardsAllowed) . ")" : '') . "
AND t.ID_TOPIC IN (" . implode(', ', $poll_ids) . ")" . "
ORDER BY RAND()
LIMIT 1", __FILE__, __LINE__);
list ($poll) = mysql_fetch_row($request);
mysql_free_result($request);
if (empty($poll))
{
$request = db_query("
SELECT t.ID_TOPIC
FROM ({$db_prefix}polls AS p, {$db_prefix}boards AS b, {$db_prefix}topics AS t)
WHERE t.ID_POLL = p.ID_POLL
AND b.ID_BOARD = t.ID_BOARD
AND $user_info[query_see_board]" . (!in_array(0, $boardsAllowed) ? "
AND b.ID_BOARD IN (" . implode(', ', $boardsAllowed) . ")" : '') . "
AND t.ID_TOPIC IN (" . implode(', ', $poll_ids) . ")" . "
ORDER BY RAND()
LIMIT 1", __FILE__, __LINE__);
list ($poll) = mysql_fetch_row($request);
mysql_free_result($request);
}
if (empty($poll))
{
echo 'There are no polls to show!';
return;
}
ssi_showPoll($poll);
I know I could use blocks in blocks but I'd rather not update 3 blocks every time I post a new poll. If I have to I will, but if I can get this working first I'd be very happy. Thanks again any help is appreciated.