Mambo bridge module - Who's Online2

Started by Kindred, July 07, 2005, 12:34:14 PM

Previous topic - Next topic

Kindred

I have released version 1.7 of the Who's Online2 module for the mambo-smf bridge.

Features and Fixes:
I have corrected some textual erros and re-titled some of the options in the mambo admin for clarity.
I have added the option to use icons to link to an online person's profile or send a PM.
I have added an option to include FlashChat "who's Chatting" within the module
The text strings for current chatters are currently defined in the module, because I didn't feel like doing a separate language file...

I have added the moduleclass_sfx function to allow you to use the mambo CSS to define your display.

the file can be downloaded from HERE

(orsito, please update mamboforge with this file!)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Aravot


Aravot

enabling the FlashChat option in Who's Online2 module result in database error, FlashChat is integrated with Mambo

Mambo 4.5.2
SMF 1.0.3
FlashChat 4.0.12

Link to the site FlashChat enabled
test/test

Kindred

hmmm..... I see the error...  but I have it working over on my site (not yet public, but you can take a look http://askawitchcommunity.org)

What normally appears in that space?  because I don't see the who's chatting section of the module shwoing at all.

(actually, I get blank white screens when I go to anywhere except the front page.)

Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Aravot

If I disable the chat everything works fine, if you want I can PM you user info with Admin privileges.

Kindred

Yes... send me the account info and I will take a look at it (probably tomorrow morning)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

probinson77

#6
It may be that you have Flashchat bridged with Mambo instead of SMF (that was my problem).  If that's the case, you need to find this query:

SELECT
userid
FROM {db_prefix}_fc_connections
WHERE userid IS NOT NULL", __FILE__, __LINE__);


and replace {db_prefix} with mos (or whatever your mambo database prefix is).  That fixed my database problems.  As a suggestion for future versions, it would be nice to have this a parameter so people can specify their database prefix.

I like the new PM icons, but they don't seem to work.  When you click the link, it takes you to a PM screen, but the userid isn't getting passed into the link, so you still have to fill in the "to" box to send the user a message.  Apparently, by the time the $row['ID_MEMBER'] variable is called to create the PM icon, the value has been lost and results in the blank id.  I'm trying to fix it now.  I'll post a fix if I find one.

Oh and a few suggestions for XHTML compliance.  All of the & characters in the module that are used in links should be coded as &amp; and toward the bottom where the alignment is called (left, center, right) instead of <left>...</left> (which will not validate) the code should read something like <div align="left">...</div> for proper validation.  Also, here in the code where the <ul> is closed:
if( ($smf_wio['list'] == 1) && ($smf_wio['proflink'] !== 2))
$wioOutputList .= '</ul>';


It should read smf_wio['proflink'] == 2.  Otherwise the </ul> tag is closed when it is not open, again causing the code to not validate.

Thanks for this great module.  It just keeps getting better!

probinson77

#7
OK,

I just spent 3 hours fiddling with the code and I think I got it working now.  Here is the modified code to allow the PM and profile icons to work properly.  This code will also produce Valid XHTML regardless of the options chosen:


<?php
// $Id: mod_smf_online2.php,v 1.1 2005.02.15 01:26:00 mic Exp $
/**
* @Who is online
* @package smf
* @Copyright (C) 2005 [email protected]
* @ All rights reserved
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
* @version $Revision: 1.6 $
*/

/*
 * This is taken directly form the SMF SSI. There are a few minor
 * tweaks, but it's not really my code!
 * in addition, I'm sure I have included some things in here that are not required at all...
 * edited by mic ([email protected]) 2005.02.15 
 * and further edited and corrected for hidden users by Kindred 2005.05.02
 */

/** ensure this file is being included by a parent file */
defined'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

if (!
defined('SMF')){
  global 
$mosConfig_absolute_path$smf_path;

  require(
$mosConfig_absolute_path."/administrator/components/com_smf/config.smf.php");
  require (
$smf_path."/SSI.php");
}

global 
$context$txt$scripturl$mosConfig_dbprefix$mosConfig_db$db_name;
mysql_select_db($mosConfig_db);
$sql "SELECT id FROM ".$mosConfig_dbprefix."menu WHERE link='index.php?option=com_smf'";

$result mysql_query ($sql);

$row mysql_fetch_array($result);

$myurl $_SERVER['PHP_SELF'] . "?option=com_smf&amp;Itemid=" $row[0]."&amp;";

$scripturl $myurl;

// parameter
$smf_wio['text'] = $params->get'smf_wio_text' ); // output text
$smf_wio['guests'] = $params->get'smf_wio_guests' );
$smf_wio['hidden'] = $params->get'smf_wio_hidden' );
$smf_wio['list'] = $params->get'smf_wio_list' );
$smf_wio['position'] = $params->get'smf_wio_position' );
$smf_wio['spacer'] = $params->get'smf_wio_spacer' );

$smf_wio['proflink'] = $params->get'smf_wio_proflink' );
$smf_wio['pmlink'] = $params->get'smf_wio_pmlink' );
$smf_wio['icontype'] = $params->get'smf_wio_icontype');
$smf_wio['proficon'] = $params->get'smf_wio_proficon' );
$smf_wio['pmicon'] = $params->get'smf_wio_pmicon' );

$smf_wio['show_fc'] = $params->get'smf_show_fc');
$smf_wio['nochatters'] = $params->get'nochatters' );
$smf_wio['onechatter'] = $params->get'onechatter' );
$smf_wio['manychatters'] = $params->get'manychatters' );
$smf_wio['justify'] = $params->get'justify' );

$moduleclass_sfx $params->get'moduleclass_sfx' );




// Shows a list of online users:  YY Guests, ZZ Users and then a list...
function show_whosOnline($output_method$smf_wio){
global $scripturl$db_prefix$txt$db_name$settings;

mysql_select_db($db_name);

// Load the users online right now.
$result db_query("
SELECT
lo.ID_MEMBER, lo.logTime, mem.realName, mem.memberName, mem.showOnline,
mg.onlineColor, mg.ID_GROUP
FROM 
{$db_prefix}log_online AS lo
LEFT JOIN 
{$db_prefix}members AS mem ON (mem.ID_MEMBER = lo.ID_MEMBER)
LEFT JOIN 
{$db_prefix}membergroups AS mg ON (mg.ID_GROUP = IF(mem.ID_GROUP = 0, mem.ID_POST_GROUP, mem.ID_GROUP))"__FILE____LINE__);

$return['users'] = array();
$return['guests'] = 0;
$return['hidden'] = 0;
while ($row mysql_fetch_assoc($result))
{
if (!isset($row['realName']))
$return['guests']++;
elseif (!empty($row['showOnline']) || allowedTo('moderate_forum'))
{
// Some basic color coding... and check if the name should link to profile
if (!empty($row['onlineColor'])) {
if ($smf_wio['proflink'] == 1) {
$link1 $scripturl 'action=profile;u=' $row['ID_MEMBER'];
$link2 '<a href="' $scripturl 'action=profile;u=' $row['ID_MEMBER'] . '" style="color: ' $row['onlineColor'] . ';">' $row['realName'] . '</a>';
} else {
$link2 $scripturl 'action=profile;u=' $row['ID_MEMBER'];
$link2 '<font style="color: ' $row['onlineColor'] . ';">' $row['realName'] . '</font>';
}
} else {
if ($smf_wio['proflink'] == 1) {
$link1 $scripturl 'action=profile;u=' $row['ID_MEMBER'];
$link2 '<a href="' $scripturl 'action=profile;u=' $row['ID_MEMBER'] . '">' $row['realName'] . '</a>';
} else {
$link1 $row['ID_MEMBER'];
$link2 $row['realName'];
}
}

if ($smf_wio['icontype'] == ) {
$prof_icon '<a href="'$scripturl 'action=profile;u=' $row['ID_MEMBER'] . '"><img src="modules/' $smf_wio['proficon'] . '" border="0" alt="' $txt[27] . '" /></a>';
$pm_icon '<a href="'$scripturl 'action=pm;sa=send;u=' $row['ID_MEMBER'] . '"><img src="modules/' $smf_wio['pmicon'] . '" border="0" alt="' $txt[159] . '" /></a>';
} else {
$prof_icon '<a href="'$scripturl 'action=profile;u=' $row['ID_MEMBER'] . '"><img src="' $settings['images_url'] . '/icons/profile_sm.gif" border="0" alt="' $txt[27] . '" /></a>';
$pm_icon '<a href="'$scripturl 'action=pm;sa=send;u=' $row['ID_MEMBER'] . '"><img src="' $settings['images_url'] . '/icons/im_newmsg.gif" border="0" alt="' $txt[159] . '" /></a>';
}


$return['users'][$row['logTime'] . $row['memberName']] = array(
'id' => $row['ID_MEMBER'],
'username' => $row['memberName'],
'name' => $row['realName'],
'group' => $row['ID_GROUP'],
'href' => $link1,
'link' => $link2,
'prof_icon' => $prof_icon,
'pm_icon' => $pm_icon,
'hidden' => empty($row['showOnline']),
'is_last' => false,
);
}
else
$return['hidden']++;
}
mysql_free_result($result);

krsort($return['users']);

if (!empty($return['users']))
$return['users'][array_pop(array_keys($return['users']))]['is_last'] = true;
$return['num_users'] = count($return['users']) + $return['hidden'];
$return['total_users'] = $return['num_users'] + $return['guests'];

if ($output_method != 'echo')
return $return;

//check if hidden users should be shown... if not, subtract the hidden users from the total online count.
if( $smf_wio['hidden'] )
$showallusers $return['num_users'];
else
$showallusers $return['num_users'] - $return['hidden'];

// construct the output
if( $smf_wio['guests'] ){
if( $return['guests'] == 
$wioOutputGuest $return['guests'] . ' ' $txt['guest'] . ' ' $txt['who_and']; 
else 
$wioOutputGuest $return['guests'] . ' ' $txt['guests'] . ' ' $txt['who_and'];
} else {
$wioOutputGuest '';
}

if( $showallusers == 
$wioOutputUsers $showallusers ' ' $txt['user']; 
else 
$wioOutputUsers $showallusers ' ' $txt['users'];

if( $smf_wio['hidden'] ){
if( $return['hidden'] > 
$wioOutputHidden ' (' $return['hidden'] . ' ' $txt['hidden'] . ')'
else 
$wioOutputHidden '';
} else {
$wioOutputHidden '';
}

// $wioOutput = ' '. $return['guests'] . ' ' . $wioOutputGuest . $txt['who_and'] .  $return['num_users'] . ' ' . $wioOutputUsers .  $wioOutputHidden;
// display the number of guests (if checked), the number of total users and the number of that total that are hidden (if checked)
if( $smf_wio['hidden'] == )
$wioOutput ' ' $wioOutputGuest ' ' $wioOutputUsers ' ' .  $wioOutputHidden;
else
$wioOutput ' ' $wioOutputGuest ' ' $wioOutputUsers;

if( count$return['users'] ) !== ) {
if( $smf_wio['list'] && (($smf_wio['proflink'] == 2) || $smf_wio['pmlink']) ) {
$wioOutputList '<br />';
$wioOutputListend '<br />';
} else if( $smf_wio['list'] ) {
$wioOutputList ' <ul>';
$wioOutputListbegin '<li>';
$wioOutputListend '</li>';
} else {
$wioOutputList '<br />';
$wioOutputListbegin ' ';
$wioOutputListend ' ';
}


foreach( $return['users'] as $user ){
if( $user['is_last'] || $smf_wio['list']) 
$list_spacer ''
else 
$list_spacer $smf_wio['spacer'] . ' ';
if( $user['link']) {
if( $user['hidden'] ) 
$wioOutputUserlink '<i>' $user['link'] . '</i>' $list_spacer
else
$wioOutputUserlink $user['link'] . $list_spacer
} else { 
$wioOutputUserlink '';
}

if (($smf_wio['proflink'] == 2) && $smf_wio['pmlink'])
$wioOutputListbegin $user['prof_icon'] . $user['pm_icon'] . '&nbsp;';
else if (($smf_wio['proflink'] == 2) && !$smf_wio['pmlink'])
$wioOutputListbegin $user['prof_icon'] . '&nbsp;';
else if (($smf_wio['proflink'] !== 2) && $smf_wio['pmlink'])
$wioOutputListbegin $user['pm_icon'] . '&nbsp;';

$wioOutputList .=  $wioOutputListbegin '<strong>'.  $wioOutputUserlink .  '</strong>' $wioOutputListend;
}
if($smf_wio['list'] == '1' && $smf_wio['proflink'] !== '2' && $smf_wio['pmlink'] !== '1') {
$wioOutputList .= '</ul>';
}
}
if( !$smf_wio['position'] ){
$wioOutput $wioOutputList;
$wioOutputList '';
}
if ($moduleclass_sfx)
echo '<div id="wio' $moduleclass_sfx .'">';

echo sprintf$smf_wio['text'], $wioOutput ) . '<br />' $wioOutputList;

if ($smf_wio['show_fc']){
$chatresult db_query("
SELECT
userid
FROM 
{$db_prefix}fc_connections 
WHERE userid IS NOT NULL"
__FILE____LINE__);
//$chatterlist = array();
while ($row mysql_fetch_assoc($chatresult))
if (isset($row['userid']))
$chatters++;

mysql_free_result($chatresult);



// $chatquery="SELECT count(userid) as count_users FROM {$GLOBALS['db_prefix']}fc_connections WHERE userid IS NOT NULL";
// $chatdatabase->setQuery($chatquery);
// $chatters = $chatdatabase->loadresult();

echo '<br /><br />';

if ($chatters == 0) {
  echo '<div style="text-align:' $smf_wio['justify'] . '">' $smf_wio['nochatters'] . '</div>';
} else {
  if ($chatters == 1)
$chat_string '<div style="text-align:' $smf_wio['justify'] . '">' $smf_wio['onechatter'] . '</div>';
else
     $chat_string '<div style="text-align:' $smf_wio['justify'] . '">' $smf_wio['manychatters'] . '</div>';
echo sprintf($chat_string$chatters);
}
}
if ($moduleclass_sfx)
echo '</div>';

mysql_select_db($mosConfig_db);
}

// Just like whosOnline except it also logs the online presence.
function doit_logOnline($output_method$smf_wio){
writeLog();

if ($output_method != 'echo')
return ssi_whosOnline($output_method);
else
show_whosOnline($output_method$smf_wio);
}
doit_logOnline'echo'$smf_wio);
?>


[edit: fixed a small error in the code]

Aravot

Quote from: probinson77 on July 09, 2005, 12:41:15 AM
It may be that you have Flashchat bridged with Mambo instead of SMF (that was my problem).  If that's the case, you need to find this query:

SELECT
userid
FROM {db_prefix}_fc_connections
WHERE userid IS NOT NULL", __FILE__, __LINE__);


and replace {db_prefix} with mos (or whatever your mambo database prefix is).  That fixed my database problems.  As a suggestion for future versions, it would be nice to have this a parameter so people can specify their database prefix.

My database prefix for flashchat is mos I guess have to change it to smf

Kindred

hmmm...   ok, well, you moved things around a little more than I would have, but it certainly looks like it will work.


Aravot...   I thought you had linked FlashChat with SMF, not mambo...  (as I inidcated in the other thread, it actually works better with the bridge.)
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Aravot

Quote from: Kindred on July 09, 2005, 09:20:21 AM
Aravot...   I thought you had linked FlashChat with SMF, not mambo...  (as I inidcated in the other thread, it actually works better with the bridge.)

Kindred I have it link with Mambo, I am going to try and link it to SMF.

Quote from: Aravot on July 08, 2005, 06:03:57 PM
enabling the FlashChat option in Who's Online2 module result in database error, FlashChat is integrated with Mambo

Aravot

Tried integrating FlashChat with smf but during installation of flashchat kept getting the following error

QuoteConfiguration Error!

FlashChat was unable to detect your MySQL login setting from the Simple Machines 1.0 configuration file. You must correct this before FlashChat can finish its installation. Please refer to the integration Instructions in the TUFaT.com Wiki to ensure that the FlashChat files were correctly uploaded to your server.

Possible Reasons for this error may include:

1) FlashChat was uploaded to an incorrect server location.
2) The CMS system that you are using is unsupported by FlashChat.
3) Your server has incompatible settings which may have been undetected in Step 1 of the FlashChat installer. For example, specific security restrictions which are not typical of most PHP/MySQL setups.

Mambo 4.5.2
SMF 1.0.3
FlashChat 4.0.12
Could it be flashchat is not compatible with SMF 1.0.3

Kindred

oh, it is compatible...  I've been using flashchat with the bridge since SMF 1.0.1 and flashchat 4.0.6 (it's up to 4.0.12 now)....   BUT!   (did you read me post over on the tufat forum?)
You have to change the smfCMS.php file slightly to suit this confiuguration.

Primarily, you need to change the first line to point to your absolute path to smf (rather than the relative path from flashchat, which is what it uses now, assuming flashchat is installed in a subdirectory of smf, bleh!) and you'll need ot change the line that links to the profile...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Aravot

I thought I had to change it after installation, I'll give it a try.

directory structure

subdomain (mambo)
--------------SMF
--------------chat

Aravot

No go even after changing the code, same as before, Kindred will you be willing to have a look if so I'll PM you the detail

Kindred

Aravot... I am indeed willing to look...
However, unfortunately, today I have been really busy and essentially only have time to read posts...   I'll take a look for you tomorrow, if that is OK.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Kindred

probinson77,

you made a minor error in your re-write of my mod...

SELECT
userid
FROM {db_prefix}_fc_connections
WHERE userid IS NOT NULL", __FILE__, __LINE__);

is improperly phrased:

you added an underscroe and missed a dollar sign.

it should read

SELECT
userid
FROM {$db_prefix}fc_connections
WHERE userid IS NOT NULL", __FILE__, __LINE__);



Aravot... this is what was causing the error on your site.

Chat is installed and working, and who's online2 is properly formatted.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

probinson77

Oops.  Sorry about that.  I had to add that variable back when I posted it here because I had to change mine to mos_fc_connections since my Flashchat is bridged with Mambo.

Oh, and I don't want anyone to think that I "rewrote" this mod.  It's essentially the same as the original mod.  All I did was cut and paste the existing code for the profile and PM icons to a different location, changed the "&" characters to "&amp;" and added about 4 lines of code.  I can't take too much credit for that.

Aravot

See pic as the users increase the wording 'There is currently x person in the chat room' get squeezed, instead of moving down

Kindred

hmmm...   interesting.

I'll check it on Monday.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Advertisement: