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'] > 0 && $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']) / $jointime, 2);
}
$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!