<?php/* tabstop=4 tabreplace=space *//** * Joomla-SMF Who's Online * * This file is the Joomla-SMF who's online module which displays online users, * links to the SMF or pms chat system, flashchat users, and general user count * statistics. * * LICENSE: This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * @category Module * @package mod_joomla-smf_whos_online * @author Cowboy <ross@joomlahacks.com> * @author Wolverine <wolverine@themofoclan.com> * @copyright (C) JoomlaHacks.com. All rights reserved. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL * @version $Id: mod_joomla-smf_whos_online.php 6 2006-04-17 12:48:51Z joshualross $ * @revision $LastChangedRevision: 6 $ * @date $LastChangedDate: 2006-04-17 08:48:51 -0400 (Mon, 17 Apr 2006) $ * @file $HeadURL: http://scm.joomla.org/svn/repos/joomla-smf_whos_online/mod_joomla-smf_whos_online.php $ * @link http://www.JoomlaHacks.com * @since File available since Release 1.0 * * Visit JoomlaHacks.com for more Joomla Hacks! *//** ensure this file is being included by a parent file */defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );//mosConfig_live_site used for images//1.1.1 added mosConfig_live_site to the globals (-Wolverine)global $mosConfig_live_site, $mosConfig_absolute_path, $database;global $profilelink, $displayrealname, $displaygroupcolor, $liststyle, $pmlink, $smf_tprefix; //1.2 Set defaults for all parameters (-Wolverine)$showmode = $params->get( 'showmode', '' );$moduleclass_sfx = $params->get( 'moduleclass_sfx', '' );$displayrealname = $params->get( 'displayrealname', 0 );$displaygroupcolor = $params->get( 'displaygroupcolor', 0 );$liststyle = $params->get( 'liststyle', 0 );$showchatters = $params->get( 'showchatters', 0 );$profilelink = $params->get( 'profilelink', 0 );$pmlink = $params->get( 'pmlink', 0 );$flashchaturl = $params->get( 'flashchaturl', '' );$chatroomempty = $params->get( 'chatroomempty', '' );//1.3 Add smf_tprefix which is the smf table prefix (-Wolverine)$smf_tprefix = $params->get( 'smf_tprefix', '');// this is largely the default method used from the Joomla Who's Online module$content = '';// show online countif ($showmode==0 || $showmode==2) { $query = "SELECT guest, usertype" . "\n FROM #__session" ; $database->setQuery( $query ); $sessions = $database->loadObjectList(); // calculate number of guests and members $user_array = 0; $guest_array = 0; foreach( $sessions as $session ) { // if guest increase guest count by 1 if ( $session->guest == 1 && !$session->usertype ) { $guest_array++; } // if member increase member count by 1 if ( $session->guest == 0 ) { $user_array++; } } // check if any guest or member is on the site if ($guest_array != 0 || $user_array != 0) { $content .= _WE_HAVE; // guest count handling if ($guest_array == 1) { // 1 guest only $content .= sprintf( _GUEST_COUNT, $guest_array ); } else if ($guest_array > 1) { // more than 1 guest $content .= sprintf( _GUESTS_COUNT, $guest_array ); } // if there are guests and members online if ($guest_array != 0 && $user_array != 0) { $content .= _AND; } // member count handling if ($user_array == 1) { // 1 member only $content .= sprintf( _MEMBER_COUNT, $user_array ); } else if ($user_array > 1) { // more than 1 member $content .= sprintf( _MEMBERS_COUNT, $user_array ); } $content .= _ONLINE; }}// show online member namesif ($showmode > 0) { $query = "SELECT DISTINCT a.username, a.userid, b.name" . "\n FROM #__session AS a, #__users as b" . "\n WHERE a.guest = 0 " . "\n AND b.id = a.userid " . "\n GROUP by b.id"; $database->setQuery($query); $rows = $database->loadObjectList(); if (count($rows)) { foreach($rows as $row) { $content .= getListStyle(createOnlineLink($row->username, $row->name, $row->userid)); } }}if ($showchatters) { /* check if they put flashchat.php on the end or not */ $content .= "<br/><a href=\"#\" onclick=\"javascript: window.open('http://".$flashchaturl."/flashchat.php', '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=550'); return false\"><img src=\"".$mosConfig_live_site."/modules/mod_whosonline_ext.gif\" border=\"0\" alt=\"Live Joomla Chat\"/></a><br />"; $chatters = ''; $query = "SELECT #__users.username, #__users.id, #__users.name " . "\n FROM #__users, #__fc_connections " . "\n WHERE #__fc_connections.userid = #__users.id " . "\n ORDER BY updated desc"; $database->setQuery($query); if ($rows = $database->loadObjectList()) { //$rows = $database->loadObjectList(); foreach($rows as $row) { $chatters .= getListStyle(createOnlineLink($row->username, $row->name, $row->id)); } if (empty($chatters)) { $content .= "<img src=\"".$mosConfig_live_site."/images/M_images/arrow.png\" border=\"0\" alt=\"\" />".($chatroomempty != '' ? $chatroomempty : "The chatroom is quite..."); } else { $content .= $chatters; } }}//function ListStyle($item) {/** * Adds optional style to link * @param string $link username or url link * @global boolean $liststyle * @global string $mosConfig_live_site Site URL */function getListStyle($link){ global $liststyle, $mosConfig_live_site; if ($liststyle) { return '<br /><img src="'.$mosConfig_live_site.'/images/M_images/arrow.png" border="0" alt="" />'.$link; } return '<ul><li><strong>'.$link.'</strong></li></ul>';}//This function requires that JoomlaSMF Bridge be installed(depracated)//1.2 use $mosurl for links (-Wolverine)//1.3 don't use $mosurl for links to allow use of other bridges(-Wolverine)/** * Creates a link to given user * @param string $username * @param string $name * @param string $userid */function createOnlineLink($username, $name, $userid) { global $database, $mosConfig_absolute_path, $mosConfig_sef, $mosConfig_live_site; global $profilelink, $displayrealname, $displaygroupcolor, $pmlink, $smf_tprefix; if (!$displayrealname) { $name = $username; } $link = ''; //take the quick way out if ($profilelink == 0 && $pmlink == 0) { return $name; //$link = ($displayrealname ? $name : $username); } //CB profile link if ($profilelink == 2) { $link = '<a href="'. sefRelToAbs('index.php?option=com_comprofiler&task=userProfile&user='. $userid).'">'.$name.'</a>'; } //smf profile link or SMF private message link if ($profilelink == 1 || $pmlink == 1) { //1.3 Return if smf table prefix isn't set (-Wolverine) if(empty($smf_tprefix)){ return '<font color="red"><b>Please configure the SMF table prefix for this module!</b></font>'; } $query = "SELECT id" . "\n FROM #__menu" . "\n WHERE link = 'index.php?option=com_smf'"; $database->setQuery($query); $smfItemid = $database->loadResult(); if (empty($smfItemid)) { return '<font color="red"><b>t1'.$database->getErrorMsg().'</b></font>'; } $smfurl = "index.php?option=com_smf&Itemid=" . $smfItemid."&"; $query = "SELECT ID_MEMBER, ID_GROUP, ID_POST_GROUP" . "\n FROM {$smf_tprefix}members" . "\n WHERE memberName = '$username'"; $database->setQuery($query); $row = null; if ($database->loadObject($row)) { $memberid = $row->ID_MEMBER; $membergroup = empty($row->ID_GROUP) ? $row->ID_POST_GROUP : $row->ID_GROUP; if (empty($memberid)) { return '<font color="red"><b>'.$database->getErrorMsg().'</b></font>'; } } else { return '<font color="red"><b>'.$database->getErrorMsg().'</b></font>'; } if (isset($membergroup) && !empty($membergroup)) { $query = "SELECT onlineColor" . "\n FROM {$smf_tprefix}membergroups" . "\n WHERE ID_GROUP = '$membergroup'"; $database->setQuery($query); $membercolor = $database->loadResult(); } //smf profile link if ($profilelink == 1) { if ($displaygroupcolor && !empty($membercolor)) { //format a quick style= to add the membercolor(-Wolverine) $link .= '<a href="'.sefRelToAbs($smfurl.'action=profile&u='.$memberid ).'" style="color: '.$membercolor.';">'.$name.'</a>'; } else { $link .= '<a href="'.sefRelToAbs($smfurl.'action=profile&u='.$memberid).'">'.$name.'</a>'; } } //smf pm link if ($pmlink == 1) { $link .= '<a href="'.sefRelToAbs($smfurl.'action=pm&sa=send&u='.$memberid).'"><img src="'.$mosConfig_live_site.'/images/M_images/emailButton.png" border="0" height="10" /></a>'; } //$link = str_replace(";u,",";u=",$link); } //PMS private message link if ($pmlink == 2) { $link .= '<a href="'. sefRelToAbs('index.php?option=com_pms&page=new&id='. $username).'"><img src="'.$mosConfig_live_site.'/images/M_images/emailButton.png" border="0" height="10" /></a>'; } return $link;}?>