Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 03-11-2006, 11:30 PM
dbfury dbfury is offline
 
Join Date: Oct 2005
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Globalize some variables

Hi!
I am trying to display the zero tolerance's welcome panel plugin on all the pages of my forum.

Here is the related source code:
PHP Code:
if ($vbulletin->userinfo['userid'] > && $vbulletin->userinfo['userid'] != '' || !$vbulletin->userinfo['userid'])
{
    require_once(
DIR '/includes/functions_user.php');
    
$vbulletin->userinfo['avatar_build'] = fetch_avatar_url($vbulletin->userinfo['userid']);

    if (empty(
$vbulletin->userinfo['avatar_build']) || !is_array($vbulletin->userinfo['avatar_build']))
    {
        
$vbulletin->userinfo['avatar_build'] = array('noavatar.gif');
    }

    
$vbulletin->userinfo['avatar_build'] = '<img src="' $vbulletin->userinfo['avatar_build'][0] . '"'.iif($vbulletin->userinfo['avatar_build'][1],$vbulletin->userinfo['avatar_build'][1],'').'border="0" alt="Edit Your Avatar" />';

    
$postsin = array();
    
$gp      $vbulletin->db->query_read("select p.threadid, t.forumid from ".TABLE_PREFIX."post p left join ".TABLE_PREFIX."thread t on(t.threadid = p.threadid) where p.userid = {$vbulletin->userinfo['userid']}");
    while (
$gpb $vbulletin->db->fetch_array($gp))
    {
        if (!
$postsin[$gpb[forumid]])
        {
            
$postsin[$gpb[forumid]] = 1;
        }
        else
        {
            
$postsin[$gpb[forumid]]++;
        }
    }

    
$active = array(0);

    if (
is_array($postsin) && is_array($vbulletin->forumcache))
    {
        foreach (
$postsin as $forumid => $pi)
        {
            if (
$pi $active[0])
            {
                
$active = array($pi$forumid);
            }
        }
    }

    if (!empty(
$active[1]))
    {
        
$vbulletin->userinfo['active'] = array($vbulletin->forumcache[$active[1]], $active[0]);
    }
    else
    {
        
$vbulletin->userinfo['active'] = false;
    }

    
$exec_totalposts str_replace(','''$totalposts);

    if (
$exec_totalposts 1)
    {
        
$exec_totalposts 1;
    }

    
$vbulletin->userinfo['posts'] = vb_number_format($vbulletin->userinfo['posts']);
    
$jointime = (TIMENOW $vbulletin->userinfo['joindate']) / 86400;

    if (
$jointime 1)
    {
        
$vbulletin->userinfo['postsperday'] = $vbulletin->userinfo['posts'];
    }
    else
    {
        
$vbulletin->userinfo['postsperday'] = vb_number_format(str_replace(','''$vbulletin->userinfo['posts']) / $jointime2);
    }

    
$vbulletin->userinfo['postpercent'] = vb_number_format(((str_replace(','''$vbulletin->userinfo['posts']) / $exec_totalposts ) * 100),2);

    
$vbulletin->userinfo['newposts'] = $vbulletin->db->query_first("select count(*) as newposts from ".TABLE_PREFIX."post where dateline >= {$vbulletin->userinfo['lastvisit']} and visible = 1");
    
$vbulletin->userinfo['newposts'] = vb_number_format($vbulletin->userinfo['newposts']['newposts']);

    
$vbulletin->userinfo['newthreads'] = $vbulletin->db->query_first("select count(*) as newthreads from ".TABLE_PREFIX."thread where dateline >= {$vbulletin->userinfo['lastvisit']} and visible = 1 and sticky in(0,1)");
    
$vbulletin->userinfo['newthreads'] = vb_number_format($vbulletin->userinfo['newthreads']['newthreads']);

    
$vbulletin->userinfo['lastvisit'] = vbdate($vbulletin->options['timeformat'], $vbulletin->userinfo['lastvisit']) . ', ' vbdate($vbulletin->options['dateformat'], $vbulletin->userinfo['lastvisit']);

    
$exec_lastposts $vbulletin->db->query_first("select count(*) as lastposts from ".TABLE_PREFIX."post where visible = 1 and dateline >= ".(TIMENOW 86400));
    
$exec_lastposts vb_number_format($exec_lastposts['lastposts']);

    
$vbulletin->templatecache['FORUMHOME'] = str_replace('$navbar','$navbar ' $vbulletin->templatecache[forumhome_welcomepanel],$vbulletin->templatecache['FORUMHOME']);

I suppose I should put it in the "global_complete" hook, but when I do it, I get error saying
Quote:
Fatal error: Call to a member function query_read() on a non-object in /home/web/htdocs/forums/includes/functions.php(4320) : eval()'d code on line 79
So I had like to ask you what I should do to globalize this module?

Thank you for your help!
Reply With Quote
  #2  
Old 03-12-2006, 12:37 AM
Adrian Schneider's Avatar
Adrian Schneider Adrian Schneider is offline
 
Join Date: Jul 2004
Posts: 2,528
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try using $vbulletin->db instead of $db. Making $db global might also work.
PHP Code:
global $db
Also, use [code] or [php] tags instead of [quote], it will keep the whitespace intact making it much easier to read.
Reply With Quote
  #3  
Old 03-12-2006, 01:36 PM
dbfury dbfury is offline
 
Join Date: Oct 2005
Posts: 9
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello
Thanks, there is no more error. But the infos aren't displayed at all.
What could I do to make the variables be able to be displayed on all the pages of my forum?
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:54 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03414 seconds
  • Memory Usage 2,226KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (3)post_thanks_box
  • (3)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit_info
  • (3)postbit
  • (3)postbit_onlinestatus
  • (3)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete