-
Notifications
You must be signed in to change notification settings - Fork 300
Phpbb2 display online chat users
Philip Nicolcev edited this page Nov 8, 2013
·
2 revisions
Quick and dirty Display Online Users Hack - for phpBB 2 Note that phpbb2 support was officially discontinued in version 0.8.7.
In includes/page_header.php
Add:
// Chat online users:
$chat_online_user_ids = array();
$chat_online_user_names = array();
$sql = 'SELECT
userID,
userName
FROM
`ajax_chat_online`;';
$result = $db->sql_query($sql);
while($row = $db->sql_fetchrow($result))
{
array_push($chat_online_user_ids, $row['userID']);
array_push($chat_online_user_names, $row['userName']);
}
$db->sql_freeresult($result);
Before:
if (defined('SHOW_ONLINE'))
Add:
if(in_array($row['user_id'], $chat_online_user_ids))
{
$user_online_link = '<span title="* = '.strip_tags($row['username']).' is logged into the Chat">'.$user_online_link.'*</span>';
}
Before:
$online_userlist .= ( $online_userlist != '' ) ? ', ' . $user_online_link : $user_online_link;
Add:
'CHAT_LINK' => '../chat/',
'CHAT_LABEL' => 'Chat ['.count($chat_online_user_names).']',
'CHAT_TITLE' => 'Online: '.htmlentities(implode(', ', $chat_online_user_names), ENT_QUOTES, 'ISO-8859-1'),
Before:
'SITENAME' => $board_config['sitename'],
In templates/[STYLE_NAME]/overall_header.tpl
Add:
<a href="{CHAT_LINK}" title="{CHAT_TITLE}" onclick="openChatWindow(this.href); this.blur(); return false;" class="mainmenu">{CHAT_LABEL}</a>
After:
END switch_user_logged_out -->
Note 1: The code above assumes your chat database table name is "ajax_chat_online" and is stored in the same database as the forums tables.
Note 2: The link used for the chat assumes you have added the following code to the JavaScript section of your template files:
function openChatWindow(url) {
window.open(
url,
'chat',
'screenX='+(screen.width/2-375)+',screenY='+(screen.height/2-255)+',width=750,height=510,resizable=yes'
)
}