I'm trying to display a poll in forumhome for a time now.
What I've done is copy pasting the following code from vBindex index.php into my main index.php:
PHP Code:
// ######################### PROCESS POLL ###############################
if ($vbindex['options'] & VBI_SHOWPOLL) {
// the $pollinfo query here is experimental, to save one query later on I have joined
// the pollvote table if the bbuser is registed, this seems to work fine from my testing
$pollinfo = $DB_site->query_first("
## GET POLL ##
SELECT thread.pollid, thread.forumid, open, threadid, replycount, question, poll.dateline,
options, votes, active, numberoptions, timeout, multiple, voters,
pollvote.voteoption, pollvote.userid AS voteuserid
FROM ".TABLE_PREFIX."thread AS thread
LEFT JOIN ".TABLE_PREFIX."poll AS poll ON (thread.pollid = poll.pollid)
LEFT JOIN ".TABLE_PREFIX."deletionlog AS deletionlog ON(thread.threadid = deletionlog.primaryid AND type = 'thread')
LEFT JOIN ".TABLE_PREFIX."pollvote AS pollvote ON(thread.pollid = pollvote.pollid AND pollvote.userid = $bbuserinfo[userid])
WHERE forumid NOT IN (".implode(',', $limitfids).")
AND deletionlog.primaryid IS NULL
AND thread.pollid <> 0
AND thread.open <> 10
AND thread.visible = '1'
".iif(strtoupper($vbindex['pollsforumid']) != 'ALL', "AND thread.forumid IN ($vbindex[pollsforumid])")."
$globalignore
$ignorelist
ORDER BY ".iif($vbindex['options'] & VBI_RANDOMPOLL, 'RAND()', 'thread.threadid')." DESC
LIMIT 1");
if ($pollinfo['pollid']) {
$pollinfo['question'] = fetch_censored_text($pollinfo['question']);
$splitoptions = explode('|||', $pollinfo['options']);
$splitvotes = explode('|||', $pollinfo['votes']);
$showresults = '';
$uservoted = '';
if (!$pollinfo['active' || !$pollinfo['open'] || ($pollinfo['dateline'] + ($pollinfo['timeout'] * 86400) < TIMENOW && $pollinfo['timeout'])) {
// poll closed
$showresults = true;
} elseif (!($forumperms["$pollinfo[forumid]"] & CANVOTE)) {
// user cannot vote on this poll
$nopermission = true;
} elseif (fetch_bbarray_cookie('poll_voted', $pollinfo['pollid'])) {
// cookie shows user has voted
$uservoted = true;
} elseif ($bbuserinfo['userid'] == $pollinfo['voteuserid'] && !empty($pollinfo['voteoption'])) {
// pollinfo query shows user has voted
$uservoted = true;
}
$i = 0;
while($i++ < $pollinfo['numberoptions']) {
$pollinfo['numbervotes'] += $splitvotes[$i - 1];
}
$i = 0;
$option = array();
while($i++ < $pollinfo['numberoptions']) {
exec_switch_bg();
$option['question' = fetch_censored_text(parse_bbcode($splitoptions[$i - 1], $pollinfo['forumid'], $pollinfo['allowsmilies']));
$option['votes'] = $splitvotes[$i - 1];
$option['number'] = $i;
if ($showresults || $uservoted || $nopermission) {
if ($showresults) {
$status = $vbphrase['this_poll_is_closed'];
} elseif ($uservoted) {
$status = $vbphrase['you_have_already_voted_on_this_poll'];
} elseif ($nopermission) {
$status = $vbphrase['you_may_not_vote_on_this_poll'];
}
$percent = 0;
if ($option['votes']) {
$percent = vb_number_format($option['votes'] / $pollinfo['numbervotes'] * 100, 2);
}
$option['graphicnumber'] = $option['number'] % 6 + 1;
$option['barnumber'] = round($percent) * 1.3;
$showform = false;
eval("\$home[pollbits] .= \"".fetch_template('vbindex_poll_result')."\";");
} elseif ($pollinfo['multiple']) {
// mutiple choice poll
$multiple = true;
$showform = true;
eval("\$home[pollbits] .= \"".fetch_template('vbindex_poll_option')."\";");
} else {
// single choice poll
$multiple = false;
$showform = true;
eval("\$home[pollbits] .= \"".fetch_template('vbindex_poll_option')."\";");
}
}
eval("\$side[poll] = \"".fetch_template('vbindex_poll')."\";");
}
}
I copied the globaltemplates arrayes, and created the necessary template.
in forumhome I put $pollbits.
the thing is that I dont know excatly what I have to change in the php code to remove vBindex installation dependance. So I need some help on that.
Right now - nothing is displayed in my forumhome.
any help would be appreciated.