who is online on board index cbbchat?


no_avatar
Mightymax
 
Posts: 2
Joined: Mon Oct 01, 2018 4:44 pm
 Tue Oct 02, 2018 12:06 pm • via Web
Hi,

Is it possible to add users present on the chat on the index page of the forum? (with "who is online" phpbb)

Thanks
no_avatar
Mightymax
 
Posts: 2
Joined: Mon Oct 01, 2018 4:44 pm
 Wed Oct 03, 2018 8:46 am • via Web
Hi,
i solved my problem with this topic :
https://www.canidev.com/viewtopic.php?f=22&t=862
https://www.canidev.com/viewtopic.php?t=512&lang=en

but we must adapt the instructions.

open /includes/functions.php

add before $template->assign_vars(array(

Code: Select all
//Begin cbb chatters online
   $chatters = '';
      global $chat;
      $sql = 'SELECT u.user_id, u.username, u.user_colour FROM YOUR PREFIX_chat_users c, ' . USERS_TABLE . ' u
             WHERE c.user_online = 1 AND c.user_id = u.user_id
         AND c.user_lastjoin > ' . $chat->time_limit;

   $result = $db->sql_query($sql);
             while ($row = $db->sql_fetchrow($result)) {   
       $chatters .= get_username_string('full', $row['user_id'], $row['username'], $row['user_colour']) . ', ';
    }
    $db->sql_freeresult($result);

    if ($chatters == '') {$chatters = 'Aucun utilisateur';}
   else {$chatters = '<b></b>&nbsp;</a>' . substr($chatters, 0, -2);}   
   
// End cbb chatters online


add before 'SITENAME' => $config['sitename'],

Code: Select all
'CHATTERS'                     => $chatters,


open /styles/your style/template/index_body.html
add before <!-- EVENT index_body_birthday_block_before -->

Code: Select all
<!-- IF S_REGISTERED_USER -->Qui est sur le Tchat?<!-- ENDIF --><!-- IF S_REGISTERED_USER -->{CHATTERS}<!-- ENDIF -->


Open /phpbb/session.php
add after $provider->logout($this->data, $new_session);

Code: Select all
    if(!empty($config['chat_enabled']))
      {
         global $chat;

         if(!defined('CHAT_USERS_TABLE'))
         {
            include($phpbb_root_path . "ext/canidev/chat/constants.$phpEx");
         }
     
         // Delete from chat users if no banned
         $sql = 'DELETE FROM ' . CHAT_USERS_TABLE . '
            WHERE user_id = ' . $this->data['user_id'] . "
               OR user_ip = '" . $this->ip . "'
            AND exclude_time = 0";
         $db->sql_query($sql);
         
         // Set the correct user statusif banned
         if(!$db->sql_affectedrows())
         {
            $sql = 'UPDATE ' . CHAT_USERS_TABLE . '
               SET user_online = 0
               WHERE user_id = ' . $this->data['user_id'] . '
               AND exclude_time > 0';
            $db->sql_query($sql);
         }
         
         // Delete private messages
         if(method_exists($chat, 'obtain_room'))
         {
            $room_ary = $chat->obtain_rooms();

            $sql = 'DELETE FROM ' . CHAT_MESSAGES_TABLE . '
               WHERE (poster_id = ' . $this->data['user_id'] . '
                  AND ' . $db->sql_in_set('dest_key', array_keys($room_ary), true) . ')
               OR dest_key = ' . $this->data['user_id'];
            $db->sql_query($sql);
         }
         
         $cookie_expire = $this->time_now - 31536000;
         $this->set_cookie('chat_key', '', $cookie_expire);
         $this->set_cookie('chat_lastcheck', '', $cookie_expire);
      }


Thanks to IvanPF and coralyn

and the result:
onlinecbb.PNG

Who is online

Users browsing this forum: No registered users and 0 guests