Customize mChat users list

Support area for phpBB's mChat extension
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: 1009
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: 1009
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.

DJ Cas
Donor
Posts: 9
Joined: 17 Oct 2019, 18:39

Re: Customize mChat users list

#7

Post by DJ Cas » 04 Jan 2020, 13:57

Hi,

I really like this, but there is one problem
After the change, i will see it, but other users don't, they only see their name, even they have the good permissions
What can i do the make it happen that the other users see it?

Painkiller88
Distinguished Donor
Posts: 27
Joined: 01 Jan 2019, 12:41
Contact:

Re: Customize mChat users list

#8

Post by Painkiller88 » 08 Jan 2020, 12:51

maybe u need to purge the cache of the board, so other users will see it after a while (depends on their browser cache also)

additionally you can also enable recompile old server styles so it will check for code changes in html and php files, and purge the cache again.

afterwards you can disable the recompile styles again because it will need a bit more load. This should help :)

DJ Cas
Donor
Posts: 9
Joined: 17 Oct 2019, 18:39

Re: Customize mChat users list

#9

Post by DJ Cas » 09 Jan 2020, 15:38

thnx for the answer Painkiller,

I did purge the cache and did the step you provided, but no result..

the strange thing is that only owners can see it..

Painkiller88
Distinguished Donor
Posts: 27
Joined: 01 Jan 2019, 12:41
Contact:

Re: Customize mChat users list

#10

Post by Painkiller88 » 09 Jan 2020, 15:49

Strange, because i can't see something like if ACP or something that would suggest only the founder/admin can see.


Do you have a testuser on your board. Try it with this user and your normal browser if you can see it


Maybe Kasimi has another idea

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests