Customize mChat users list

Support area for phpBB's mChat extension
Post Reply
EVO_VV
Posts: 40
Joined: 23 Jun 2017, 16:03

Customize mChat users list

#1

Post by EVO_VV » 15 Jul 2017, 14:58

My requirement is that the MCHAT_USERS_LIST be filled with only the members who currently have the index page open or have had in the past x minutes.
Any help with how to achieve this would be greatly appreciated.

EVO_VV
Posts: 40
Joined: 23 Jun 2017, 16:03

Re: A small suggestion

#2

Post by EVO_VV » 09 Feb 2018, 14:23

Finally got round to solving what I wanted - had to work on getting a new server up and running first.
Turned out it was sufficient for my members to be able to see who was (or had been recently) logged on and so potentially available to respond to a chat.
In order to achieve this a small edit was required :-

Find in /core/functions.php

Code: Select all

		$sql_array = array(
			'SELECT'	=> 'u.user_id, u.username, u.user_colour, s.session_viewonline',
			'FROM'		=> array(
				$this->mchat_sessions_table => 'ms'
			),
			'LEFT_JOIN'	=> array(
				array(
					'FROM'	=> array(SESSIONS_TABLE => 's'),
					'ON'	=> 'ms.user_id = s.session_user_id',
				),
				array(
					'FROM'	=> array(USERS_TABLE => 'u'),
					'ON'	=> 'ms.user_id = u.user_id',
				),
			),
			'WHERE'		=> 'u.user_id <> ' . ANONYMOUS . ' AND s.session_viewonline IS NOT NULL AND ms.user_lastupdate > ' . (int) $check_time,
			'ORDER_BY'	=> 'u.username ASC',
		);
		
Change to :-

Code: Select all

$sql_array = array(
	'SELECT' => 'u.user_id, u.username, u.user_colour, s.session_user_id',
	'FROM' => array(USERS_TABLE => 'u'
	),
	'LEFT_JOIN' => array(
        	 array(
           		'FROM' => array(SESSIONS_TABLE => 's'),
          		 'ON' => 'u.user_id = s.session_user_id'
           )),
	'WHERE' =>  'u.user_id <> ' . ANONYMOUS . ' AND s.session_time > ' . (int) $check_time,
	'ORDER_BY'	=> 'u.username ASC',
);
Adding another LEFT JOIN for the forum_id would solve my original requirement to have only those who were(had been) actually on the index page.

Oh and , of course. editing the language/php so it reads online not chatting.

User avatar
kasimi
mChat developer
Posts: 925
Joined: 06 Oct 2016, 09:56
Location: Germany
Contact:

Re: Customize mChat users list

#3

Post by kasimi » 09 Feb 2018, 14:41

I totally missed your first post, sorry about that. :oops:

So basically you want a trimmed down who is online list, like the one phpBB provides, that only shows users who are on the index page?

The forum_id can't be used to check if a user is on the index. Maybe try adding this to the WHERE clause:

Code: Select all

s.session_page LIKE 'index.%'

EVO_VV
Posts: 40
Joined: 23 Jun 2017, 16:03

Re: Customize mChat users list

#4

Post by EVO_VV » 09 Feb 2018, 15:13

Thanks for moving the post, much better to have it as a separate topic.

Have to disagree regarding the forum_id and the index page. I have found that forum_id = 0 is the index page and so can be used.
Works just fine in SQL

Code: Select all

			'LEFT_JOIN'	=> array(
					array(
						'FROM'	=> array(FORUMS_TABLE => 'f'),
						'ON'	=> 's.session_forum_id = f.forum_id',
					),
				),
and I have also used a similar thing in the HTML <!-- IF not S_FORUM_ID -->
Last edited by EVO_VV on 09 Feb 2018, 15:36, edited 1 time in total.

User avatar
kasimi
mChat developer
Posts: 925
Joined: 06 Oct 2016, 09:56
Location: Germany
Contact:

Re: Customize mChat users list

#5

Post by kasimi » 09 Feb 2018, 15:22

session_forum_id = 0 can also mean the user is in the ACP or UCP (composing a PM for example), basically any page not related to a forum.

EVO_VV
Posts: 40
Joined: 23 Jun 2017, 16:03

Re: Customize mChat users list

#6

Post by EVO_VV » 09 Feb 2018, 15:38

Ahhhh OK, was not aware of that.
However it would still work for my purposes as that would mean that the user is active.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest