I've been fooling around with a Chat module for my CMPS and I got it to work. I took part of the stock onlineusers.php file and part of the vBchat php coding that is edited into the index.php file. Making the template was the easy part. I just copied a stock mini module and inserted the html coding from the FORUMHOME edit in the vBChat install. Heres' my adv_portal_chatroom template:
HTML Code:
<script type="text/javascript">
<!--
function OpenvBChat(){
vBChat = window.open('/yourforumdirectory/vBChat.php?$session[sessionurl]','vBChat','directories=no,height='+window.screen.height+',width='+window.screen.width+',location=no,menubar=no,scrollbars=yes,status=no,toolbar=no')
return false;
}
-->
</script>
<table align="center" border="0" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" class="tborder" width="100%">
<tr>
<td class="tcat"><span class="smallfont"><b>$vba_options[portal_blockbullet] <b>The Chat Room</b></span></td>
</tr>
<tr>
<td class="alt1" colspan="2"><span class="smallfont">Users Currently Inside the Chat Room</span></td>
</tr>
<tr>
<td class="alt2" width="100%">
<div class="smallfont">{$invBChat}</div>
</td>
</tr>
<tr>
<td class="alt1" align="center"><a href="/yourforumdirectory/vBChat.php?$session[sessionurl]" onclick='return OpenvBChat();'><span class="smallfont">Open Chat Room</span></a></td>
</tr>
</table>
<br />
If you already have a link to your Chat in the navbar, and your navbar is displayed on your CMPS Pages, you probally don't need to include the java script in the template file.
Here's my module file - chat_portal.php:
PHP Code:
<?php
$forumusers = '';
$forumusers = $DB_site->query("
SELECT session.userid, username, usergroupid, (user.options & $_USEROPTIONS[invisible]) AS invisible,
session.location
FROM " . TABLE_PREFIX . "session AS session
LEFT JOIN " . TABLE_PREFIX . "user AS user USING (userid)
WHERE session.lastactivity > " . (TIMENOW - $vboptions['cookietimeout']) . "
ORDER BY invisible ASC, username ASC
");
if ($DB_site->num_rows($forumusers))
{
// Get the users in vBChat
$vbchat_users = array();
while ($loggedin = $DB_site->fetch_array($forumusers))
{
$userid = $loggedin['userid'];
if (!$userid)
{ // Guest
$numberguest++;
$inforum["$loggedin[inforum]"]++;
}
else if (empty($userinfos["$userid"]) OR ($userinfos["$userid"]['lastactivity'] < $loggedin['lastactivity']))
{
$userinfos["$userid"] = $loggedin;
}
if(preg_match("/vBChat.php/",$loggedin['location']) && $loggedin['userid']){
$vbchat_users[$loggedin['userid']] = $loggedin;
}
}
// Configure Peeps In vBChat
$invBChat = "";
if(is_array($vbchat_users)){
foreach($vbchat_users as $invbc){
if($invBChat == ""){
$extra = "";
} else {
$extra = ", ";
}
// Get Username Style
$invbc['musername'] = fetch_musername($invbc);
$invBChat .= "{$extra}<a href='/yourforumdirectory/member.php?{$session['sessionurl']}&u={$invbc['userid']}'>{$invbc['musername']}</a>";
}
}
if($invBChat == ""){
$invBChat = "<i>No one is currently in the Chat Room</i>";
}
eval('$home[$onlineid][\'content\'] = "' . fetch_template('adv_portal_chatroom') . '";');
unset($forumusers);
}
?>
And adding the settings (add new module) to CMPS:
Quote:
Module Title: Chat Room
Module Identifier: none
File to Include: chat_portal.php
OR Template to Include: leave blank
Active: yes
Column: whatever
Display Order: whatever
Templates Used: adv_portal_chatroom
(Set other options)
|
Attached are three screenshots, before and after logging in to Chat, and of the module settings for my test News Page.
Zero, you may want to look at the coding in my chat_portal.php file. It works, but some of the coding may not be needed, or I may have some essential parts missing (any security problems). Warning to others, this does work, but if you want to experiment with it, go ahead. But it may not be 100% yet.
One odd thing. I set this up on one of my CMPS pages to experiment with,
http://shipmodeling.net/cmps_index.php?page=news
It was set up for the Chat Module to be on the right hand side, my News Module in the center and the Online Users to be on the left (see screenshot #3).
However as you can see, the Chat shows up on the left where the Online Users should be, the News is ok in the center, but there is a blank space on the right side. It's probally someting stupid that I missed. But I'll keep checking it out.
John
BTW Zero, great script. I invited some of my members to try out vBChat before releasing it to the whole forum. They loved it!
Add on:
Found the problem with the Module showing in the wrong side. The eval statement was wrong in my chat_portal.php file.
PHP Code:
eval('$home[$onlineid][\'content\'] = "' . fetch_template('adv_portal_chatroom') . '";');
Has to be:
PHP Code:
eval('$home[$mods[\'modid\']][\'content\'] = "' . fetch_template('adv_portal_chatroom') . '";');
The $onlineid referred to the onlineusers template. If you're using a custom module without a module identifier, you have to use the
$home[$mods[\'modid\'] in that part of the eval statement. See last screenshot.