• This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

Show user is online

Here's how I got this working:

First, upload the contents of the library file and install the addon (both attached).

This adds a method to determine the posting user's online/offlline status based on their last activity. In order to see it, you need to make a code edit to add the method call within the relevant thread controller actions. For example, in XenForo_ControllerPublic_Thread::actionIndex() I found this code starting at line 100:
PHP:
            if (!$firstUnreadPostId && $post['isNew'])
            {
                $firstUnreadPostId = $post['post_id'];
            }
And added this directly below it:
PHP:
$this->_getUserOnlineInfo($post);

And then wrap the html in the message_user_info template with a <xen:if></xen:if>.

HTML:
<xen:if is="{$message.online}"><span class="userOnline"><span></span>Online</span></xen:if>

This uses your last activity in the session_activity table, so logging out won't necessarily clear the activity. Rule of thumb...if you show as online on the main page, you'll show online within the thread.
 

Attachments

  • Screen shot 2010-11-20 at 9.47.01 PM.webp
    Screen shot 2010-11-20 at 9.47.01 PM.webp
    5.1 KB · Views: 133
  • Online Status.zip
    Online Status.zip
    5.9 KB · Views: 25
I've been playing around with many different variations for this code. I still have yet to make this work on my test board (no mods or template changes made...besides this).

Only stable version I've came up with, which doesn't work is this (although since the original one didn't work, I truly don't know...I added the comments as I posted this):
Code:
<xen:if hascontent="true"> //Think this checks to see if there is something there first
<xen:contentcheck> //Validates the first IF statement?
<xen:if is="{$canViewOnlineStatus}"> //Hidden members stay hidden unless you have permission
     <xen:if is="{$user.activity}"> //checks to see if there is user activity?
          <span class="userOnline"><span></span>Online</span>
     </xen:if>
</xen:if>
</xen:contentcheck>
</xen:if>

I originally tried to use the Sidebar_online_users script that shows the Staff members online. That only got a lot of errors of invalid arguments (using the original coding).
This is just my toying around with it.

[Edit]
lol Well guess people have posted since I originally wrote this (but not posting it) and tested out different theories of mine. Good that someone found something that knows what they are doing lol
 
Here's how I got this working:

In XenForo/ControllerHelper/ForumThreadPost.php add this:
PHP:
        public function getUserOnlineInfo(array &$post)
        {
            $session_timeout = $this->_controller->getModelFromCache('XenForo_Model_Session')->getOnlineStatusTimeout();

            $post['last_activity'] > $session_timeout ? $post['online'] = true : $post['online'] = false;

        }

Then to get it working, you need to call this method, passing the post variable to it. For example, in XenForo_ControllerPublic_Thread::actionIndex() I added this at line 105:
PHP:
$ftpHelper->getUserOnlineInfo($post);

And then wrap the html in the message_user_info template with a <xen:if></xen:if>.

HTML:
<xen:if is="{$message.online}"><span class="userOnline"><span></span>Online</span></xen:if>
Wow! Thanks!
But I think there is a small bug here.
I've made all the changes and then opened my test thread. Of course I was online. Then I wanted to test if it works. I've logged out and opened the thread again. And here is what I've seen.
test1.webp

Hmm, also when I log in and refresh the page I see that I'm not showing as online.
 
Hmm...this morning I'm seeing a rather big bug with it.

Should be fairly easy to resolve. Just a quick plugin. I should be able to fix, test, and update this morning yet. :)
 
Are all these changes being updated and posted within the first post? And Could we have a screenshot to see what it looks like so users can see the placement of this. I think it's important to type up and post screenshots where applicable in this case, it is. I appreciate the efforts here.
 
Are all these changes being updated and posted within the first post? And Could we have a screenshot to see what it looks like so users can see the placement of this. I think it's important to type up and post screenshots where applicable in this case, it is. I appreciate the efforts here.
I think this will be a plugin (hope Arik would make a release :) ), but when we will have a stable version I update the first post of course.
 
I've updated my post with the plugin. It should work better now...I had originally made the assumption that the user's last activity was updated slightly more frequently than it actually is. Can't get rid of the code edit, but I minimized it.

Also fixed another issue I had (forgot to check the user's privacy settings).
 
I've updated my post with the plugin. It should work better now...I had originally made the assumption that the user's last activity was updated slightly more frequently than it actually is. Can't get rid of the code edit, but I minimized it.

Also fixed another issue I had (forgot to check the user's privacy settings).

Would it be possible for you to create a new thread for your online_status that way your post is not buried within a thread as it's a little confusing plus new members to the site will most probably miss this after they read the first post in this thread. Thanks for your efforts. :)
 
I'd still prefer a green or blue dot if I would install this feature, but nice work nonetheless.
You can do that with something like this.
Add this to message_user_info.css:

HTML:
.online_dot {
position:absolute;
right:3px;
top:3px;
height:6px;
width:6px;
border-radius:3px;
background-color:green;
}

Edit the message_user_info template:
HTML:
<div class="avatarHolder"><span class="online_dot"></span><xen:avatar user="$user" size="m" itemprop="photo" /></div>

It looks like this:

online_dot.webponline_dot_ie.webp

That's quick and dirty so it would need tidying up a bit but it's what I'll be doing.
I just want something very subtle which is noticeable but not overly so.
 
Nicely done with the css, didn't think of that. I would prefer a different location but that's personal.

But tbh I don't think I find this feature important enough to show it on thread view :)
 
I still think it's all a bit bulky, but the simple css solutions look out of place as well.
 
You can do that with something like this.
Add this to message_user_info.css:

HTML:
.online_dot {
position:absolute;
right:3px;
top:3px;
height:6px;
width:6px;
border-radius:3px;
background-color:green;
}

Edit the message_user_info template:
HTML:
<div class="avatarHolder"><span class="online_dot"></span><xen:avatar user="$user" size="m" itemprop="photo" /></div>

It looks like this:

View attachment 6199View attachment 6200

That's quick and dirty so it would need tidying up a bit but it's what I'll be doing.
I just want something very subtle which is noticeable but not overly so.

I dunno if it was you paul saying about it not being needed but after thinking about this I am now in the camp that this online status is not needed. Took a while for me to come to my senses. :P
 
Here's how I got this working:
This adds a method to determine the posting user's online/offlline status based on their last activity. In order to see it, you need to make a code edit to add the method call within the relevant thread controller actions. For example, in XenForo_ControllerPublic_Thread::actionIndex() I added this at line 105:
PHP:
$this->_getUserOnlineInfo($post);
Where do we add this bit? What file?
 
I'll use one of the original ones here in the thread and put "On the Air!" on it for our themed approach to the user online :D
 
Top Bottom