Joomla Community Builder - Who's online PDF Print E-mail
User Rating: / 1
PoorBest 
Written by Bart Dorlandt   
Saturday, 03 March 2007 11:38

I have adjusted the code a litte bit with the standard code of joomla. (of the "who's online module"). Now you can see if guest are online also. The CB - Who's online will only show you the online users. This is what you need to do.

This has been adjusted to work with CB 1.1 

  • cd $joomla/modules/
  • # as a user with enough rights
  • cp -p mod_comprofileronline.php mod_comprofileronline.php.old
  • cp -p mod_comprofileronline.xml mod_comprofileronline.xml.old

vi mod_comprofileronline.xml # after the <params> sign enter the following and save/close the file.

          <param name="showmode" type="radio" default="0" label="Display" description="Select what shall be shown">
                <option value="0"># of Guests/Members&lt;br&gt;</option>
                <option value="1">Member Names&lt;br&gt;</option>
                <option value="2">Both</option>
          </param>

vi mod_comprofileronline.php # after the line "defined( '_VALID_MOS' ) or die( '....." enter the following and close/save the file.

// insert from mod_whosonline.php //
$showmode       = $params->get( 'showmode', 0 );

$output         = '';

// show online count
if ($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) {
                $output .= _WE_HAVE;

                // guest count handling
                if ($guest_array == 1) {
                // 1 guest only
                        $output .= sprintf( _GUEST_COUNT, $guest_array );
                } else if ($guest_array > 1) {
                // more than 1 guest
                        $output .= sprintf( _GUESTS_COUNT, $guest_array );
                }

                // if there are guests and members online
                if ($guest_array != 0 && $user_array != 0) {
                        $output .= _AND;
                }

                // member count handling
                if ($user_array == 1) {
                // 1 member only
                        $output .= sprintf( _MEMBER_COUNT, $user_array );
                } else if ($user_array > 1) {
                // more than 1 member
                        $output .= sprintf( _MEMBERS_COUNT, $user_array );
                }

                $output .= _ONLINE;
        }
}

echo $output;

// end of the mod_whosonline.php

Now you're done. :)

Last Updated on Wednesday, 10 October 2007 23:02
 


Related items: