Thread: vBulletin Forum Sideblocks - Show Poll In Forum Sideblock
View Single Post
  #170  
Old 09-10-2014, 02:34 AM
fxdigi-cash fxdigi-cash is offline
 
Join Date: Jul 2012
Posts: 674
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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'), truefalse);

    
// 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($vbulletinfetch_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"], truefalse);
        
$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'] % 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 {

Reply With Quote
Благодарность от:
tbworld
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01329 seconds
  • Memory Usage 1,959KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_box_bit
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete