ok, spent few minutes on this and just noticed that the PHP code in the mod doesn't get filled up when installed to the vb board. when you go to your sideblock in the
forum blocks manager, you can edit the poll block and find no PHP code; it is empty. That's why it won't work. I grabed the code from the xml file so anyone can use it. place it in the PHP code area in the sideblock for poll and save it. it works fine.
PHP Code:
global $vbulletin, $vbphrase, $db;
if ($vbulletin->options['poll_on_sideblock_vb4']) {
if (!empty($vbulletin->options['poll_on_sideblock_vb4_thread'])) {
$getthread = $db->query_first("SELECT threadid, pollid, forumid, open, lastpost FROM ".TABLE_PREFIX."thread where threadid = ".$vbulletin->options['poll_on_sideblock_vb4_thread']."");
}
elseif (!empty($vbulletin->options['poll_on_sideblock_vb4_forum'])) {
$getthread = $db->query_first("SELECT forum.forumid, thread.threadid, thread.pollid, thread.forumid, thread.open, thread.lastpost FROM ".TABLE_PREFIX."forum as forum
LEFT join ".TABLE_PREFIX."thread as thread ON thread.forumid = forum.forumid where forum.forumid IN (".$vbulletin->options['poll_on_sideblock_vb4_forum'].") ORDER BY thread.pollid DESC LIMIT 1");
}
$poll = '';
if ($getthread['pollid'])
{
$pollbits = '';
$counter = 1;
$pollid = $getthread['pollid'];
$show['editpoll'] = iif(can_moderate($getthread['forumid'], 'caneditpoll'), true, false);
// get poll info
$pollinfo = $db->query_first_slave("
SELECT *
FROM " . TABLE_PREFIX . "poll
WHERE pollid = $pollid
");
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser = new vB_BbCodeParser($vbulletin, fetch_tag_list());
$pollinfo['question'] = $bbcode_parser->parse(unhtmlspecialchars($pollinfo['question']), $getthread['forumid'], true);
$splitoptions = explode('|||', $pollinfo['options']);
$splitoptions = array_map('rtrim', $splitoptions);
$splitvotes = explode('|||', $pollinfo['votes']);
$showresults = 0;
$uservoted = 0;
$forumperms = fetch_permissions($getthread['forumid']);
if (!($forumperms & $vbulletin->bf_ugp_forumpermissions['canvote']))
{
$nopermission = 1;
}
if (!$pollinfo['active'] OR !$getthread['open'] OR ($pollinfo['dateline'] + ($pollinfo['timeout'] * 86400) < TIMENOW AND $pollinfo['timeout'] != 0) OR $nopermission)
{
//thread/poll is closed, ie show results no matter what
$showresults = 1;
}
else
{
//get userid, check if user already voted
$voted = intval(fetch_bbarray_cookie('poll_voted', $pollid));
if ($voted)
{
$uservoted = 1;
}
}
if ($pollinfo['timeout'] AND !$showresults)
{
$pollendtime = vbdate($vbulletin->options['timeformat'], $pollinfo['dateline'] + ($pollinfo['timeout'] * 86400));
$pollenddate = vbdate($vbulletin->options['dateformat'], $pollinfo['dateline'] + ($pollinfo['timeout'] * 86400));
$show['pollenddate'] = true;
}
else
{
$show['pollenddate'] = false;
}
foreach ($splitvotes AS $index => $value)
{
$pollinfo['numbervotes'] += $value;
}
if ($vbulletin->userinfo['userid'] > 0)
{
$pollvotes = $db->query_read_slave("
SELECT voteoption
FROM " . TABLE_PREFIX . "pollvote
WHERE userid = " . $vbulletin->userinfo['userid'] . " AND pollid = $pollid
");
if ($db->num_rows($pollvotes) > 0)
{
$uservoted = 1;
}
}
if ($showresults OR $uservoted)
{
if ($uservoted)
{
$uservote = array();
while ($pollvote = $db->fetch_array($pollvotes))
{
$uservote["$pollvote[voteoption]"] = 1;
}
}
}
$left = vB_Template_Runtime::fetchStyleVar('left');
$right = vB_Template_Runtime::fetchStyleVar('right');
$option['open'] = $left[0];
$option['close'] = $right[0];
foreach ($splitvotes AS $index => $value)
{
$arrayindex = $index + 1;
$option['uservote'] = iif($uservote["$arrayindex"], true, false);
$option['question'] = $bbcode_parser->parse($splitoptions["$index"], $getthread['forumid'], true);
// public link
if ($pollinfo['public'] AND $value)
{
$option['votes'] = '<a href="' . fetch_seo_url('poll', $pollinfo, array('do' => 'showresults')) .
'">' . vb_number_format($value) . '</a>';
}
else
{
$option['votes'] = vb_number_format($value); //get the vote count for the option
}
$option['number'] = $counter; //number of the option
//Now we check if the user has voted or not
if ($showresults OR $uservoted)
{ // user did vote or poll is closed
if ($value <= 0)
{
$option['percentraw'] = 0;
}
else if ($pollinfo['multiple'])
{
$option['percentraw'] = ($value < $pollinfo['voters']) ? $value / $pollinfo['voters'] * 100 : 100;
}
else
{
$option['percentraw'] = ($value < $pollinfo['numbervotes']) ? $value / $pollinfo['numbervotes'] * 100 : 100;
}
$option['percent'] = vb_number_format($option['percentraw'], 2);
$option['graphicnumber'] = $option['number'] % 6 + 1;
$option['barnumber'] = round($option['percent']) * 2;
$option['remainder'] = 201 - $option['barnumber'];
// Phrase parts below
if ($nopermission)
{
$pollstatus = $vbphrase['you_may_not_vote_on_this_poll'];
}
else if ($showresults)
{
$pollstatus = $vbphrase['this_poll_is_closed'];
}
else if ($uservoted)
{
$pollstatus = $vbphrase['you_have_already_voted_on_this_poll'];
}
$templater = vB_Template::create('sideblock_pollresult');
$templater->register('names', $names);
$templater->register('option', $option);
$pollbits .= $templater->render();
}
else
{
if ($pollinfo['multiple'])
{
$templater = vB_Template::create('sideblock_polloption_multiple');
$templater->register('option', $option);
$pollbits .= $templater->render();
}
else
{
$templater = vB_Template::create('sideblock_polloption');
$templater->register('option', $option);
$pollbits .= $templater->render();
}
}
$counter++;
}
if ($pollinfo['multiple'])
{
$pollinfo['numbervotes'] = $pollinfo['voters'];
$show['multiple'] = true;
}
if ($pollinfo['public'])
{
$show['publicwarning'] = true;
}
else
{
$show['publicwarning'] = false;
}
$displayed_dateline = $getthread['lastpost'];
$pollinfo['threadid'] = $getthread['threadid'];
if ($showresults OR $uservoted)
{
$templater = vB_Template::create('sideblock_pollresults_table');
$templater->register('pollbits', $pollbits);
$templater->register('pollenddate', $pollenddate);
$templater->register('pollendtime', $pollendtime);
$templater->register('pollinfo', $pollinfo);
$templater->register('show', $show);
$templater->register('pollstatus', $pollstatus);
$poll = $templater->render();
}
else
{
$templater = vB_Template::create('sideblock_polloptions_table');
$templater->register('pollbits', $pollbits);
$templater->register('pollenddate', $pollenddate);
$templater->register('pollendtime', $pollendtime);
$templater->register('show', $show);
$templater->register('pollinfo', $pollinfo);
$poll = $templater->render();
}
return $poll;
}
}
else {
}