Jump to content

Need to return a variable for useronline status in vbulletin


Recommended Posts

I am trying to make it so a background image in my postbit changes color depending on if a user is online, offline or invisible.

 

I am doing this by assigning a class which I need to change using conditionals, and I found this bit of code for a plugin: http://www.vbulletin.org/forum/showpost.php?p=1323306&postcount=8

 

However, it's not working, it's showing everyone as offline.

 

What's the best way to go about doing this?

 

I had my class change depending on the users status, ie "class="online1"... The "1" would be the part that changes to either 0, 1 or 2... any ideas how to get this working?

 

Here's what I have so far.

 

I made a custom template.

 

Title: postbit_onlinestatus_two

Inside that template:

<if condition="$onlinestatus==0">0</if><if condition="$onlinestatus==1">1</if><if condition="$onlinestatus==2">2</if>

 

 

I've made a plugin to cache the template.

 

Hook Location: cache_templates

Title: cache custom templates

Code:

$globaltemplates = array_merge($globaltemplates, array('beer','drink','postbit_onlinestatus_two'));

(it's caching other templates as well)

 

 

I've created a plugin to execute the template.

 

Hook Location: postbit_display_complete

Title: Postbit Online Status

Code:

eval('$postbitonlinestatus = "' . fetch_template('postbit_onlinestatus_two') . '";');

 

 

And the code in my postbit template:

<div class="online$postbitonlinestatus">

 

It's currently returning a "0" regardless if I am online or not.

 

Can someone please give me a little guidance to get this working? Thank you. :)

By default, vbulletin returns an image to indicate if a user is online, offline, or invisible, I am trying to return text, I could just do that in the default template, but can't because I am using the default template as it is in other areas, such as the members profile page.

 

This is hard code in one of the files to return a users online status.

 

	$onlinestatus = 0;
// now decide if we can see the user or not
if ($user['lastactivity'] > $datecut AND $user['lastvisit'] != $user['lastactivity'])
{
	if ($user['invisible'])
	{
		if (($vbulletin->userinfo['permissions']['genericpermissions'] & $vbulletin->bf_ugp_genericpermissions['canseehidden']) OR $user['userid'] == $vbulletin->userinfo['userid'])
		{
			// user is online and invisible BUT bbuser can see them
			$user['invisiblemark'] = '*';
			$onlinestatus = 2;
		}
	}
	else
	{
		// user is online and visible
		$onlinestatus = 1;
	}
}

if ($setstatusimage)
{
	eval('$user[\'onlinestatus\'] = "' . fetch_template('postbit_onlinestatus') . '";');
}

return $onlinestatus;
}

 

I hope that helps, I've been trying to figure this out for 2 days.

I came up with a solution but have one last issue, it's not parsing correctly when using quick reply, it loads in using the image code instead, but on refresh it's fine.

 

I don't have to use plugins or anything, I just did this to my postbit_onlinestatus template:

 

<if condition="$vbulletin->userinfo['field8'] != 'Horizontal Postbit' AND in_array(THIS_SCRIPT, array('showthread','private'))"><if condition="$onlinestatus==0">0</if><if condition="$onlinestatus==1">1</if><if condition="$onlinestatus==2">2</if><else /><if condition="$onlinestatus==0"><img class="inlineimg" src="$stylevar[imgdir_statusicon]/user_offline.gif" alt="<phrase 1="$user[username]">$vbphrase[x_is_offline]</phrase>" border="0" /></if>
<if condition="$onlinestatus==1"><img class="inlineimg" src="$stylevar[imgdir_statusicon]/user_online.gif" alt="<phrase 1="$user[username]">$vbphrase[x_is_online_now]</phrase>" border="0" /></if>
<if condition="$onlinestatus==2"><img class="inlineimg" src="$stylevar[imgdir_statusicon]/user_invisible.gif" alt="<phrase 1="$user[username]">$vbphrase[x_is_invisible]</phrase>" border="0" /></if></if>

 

My members can choose their postbit, hence the first part of the code.

 

Any ideas how to make this parse right away with quick reply?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.