Spade
Mini Shell
helper.php000064400000005213151166622450006545 0ustar00<?php
/**
* @package Joomla.Site
* @subpackage mod_whosonline
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Helper for mod_whosonline
*
* @since 1.5
*/
class ModWhosonlineHelper
{
/**
* Show online count
*
* @return array The number of Users and Guests online.
*
* @since 1.5
**/
public static function getOnlineCount()
{
$db = JFactory::getDbo();
// Calculate number of guests and users
$result = array();
$user_array = 0;
$guest_array = 0;
$whereCondition =
JFactory::getConfig()->get('shared_session', '0') ?
'IS NULL' : '= 0';
$query = $db->getQuery(true)
->select('guest, client_id')
->from('#__session')
->where('client_id ' . $whereCondition);
$db->setQuery($query);
try
{
$sessions = (array) $db->loadObjectList();
}
catch (RuntimeException $e)
{
$sessions = array();
}
if (count($sessions))
{
foreach ($sessions as $session)
{
// If guest increase guest count by 1
if ($session->guest == 1)
{
$guest_array ++;
}
// If member increase member count by 1
if ($session->guest == 0)
{
$user_array ++;
}
}
}
$result['user'] = $user_array;
$result['guest'] = $guest_array;
return $result;
}
/**
* Show online member names
*
* @param mixed $params The parameters
*
* @return array (array) $db->loadObjectList() The names of the
online users.
*
* @since 1.5
**/
public static function getOnlineUserNames($params)
{
$whereCondition =
JFactory::getConfig()->get('shared_session', '0') ?
'IS NULL' : '= 0';
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName(array('a.username',
'a.userid', 'a.client_id')))
->from('#__session AS a')
->where($db->quoteName('a.userid') . ' != 0')
->where($db->quoteName('a.client_id') . ' ' .
$whereCondition)
->group($db->quoteName(array('a.username',
'a.userid', 'a.client_id')));
$user = JFactory::getUser();
if (!$user->authorise('core.admin') &&
$params->get('filter_groups', 0) == 1)
{
$groups = $user->getAuthorisedGroups();
if (empty($groups))
{
return array();
}
$query->join('LEFT', '#__user_usergroup_map AS m ON
m.user_id = a.userid')
->join('LEFT', '#__usergroups AS ug ON ug.id =
m.group_id')
->where('ug.id in (' . implode(',', $groups) .
')')
->where('ug.id <> 1');
}
$db->setQuery($query);
try
{
return (array) $db->loadObjectList();
}
catch (RuntimeException $e)
{
return array();
}
}
}
mod_whosonline.php000064400000001423151166622450010311 0ustar00<?php
/**
* @package Joomla.Site
* @subpackage mod_whosonline
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
// Include the whosonline functions only once
JLoader::register('ModWhosonlineHelper', __DIR__ .
'/helper.php');
$showmode = $params->get('showmode', 0);
if ($showmode == 0 || $showmode == 2)
{
$count = ModWhosonlineHelper::getOnlineCount();
}
if ($showmode > 0)
{
$names = ModWhosonlineHelper::getOnlineUserNames($params);
}
$moduleclass_sfx =
htmlspecialchars($params->get('moduleclass_sfx'), ENT_COMPAT,
'UTF-8');
require JModuleHelper::getLayoutPath('mod_whosonline',
$params->get('layout', 'default'));
mod_whosonline.xml000064400000005065151166622450010330 0ustar00<?xml
version="1.0" encoding="utf-8"?>
<extension type="module" version="3.1"
client="site" method="upgrade">
<name>mod_whosonline</name>
<author>Joomla! Project</author>
<creationDate>July 2004</creationDate>
<copyright>Copyright (C) 2005 - 2020 Open Source Matters. All rights
reserved.</copyright>
<license>GNU General Public License version 2 or later; see
LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>MOD_WHOSONLINE_XML_DESCRIPTION</description>
<files>
<filename
module="mod_whosonline">mod_whosonline.php</filename>
<folder>tmpl</folder>
<filename>helper.php</filename>
</files>
<languages>
<language
tag="en-GB">en-GB.mod_whosonline.ini</language>
<language
tag="en-GB">en-GB.mod_whosonline.sys.ini</language>
</languages>
<help key="JHELP_EXTENSIONS_MODULE_MANAGER_WHO_ONLINE" />
<config>
<fields name="params">
<fieldset name="basic">
<field
name="showmode"
type="list"
label="MOD_WHOSONLINE_SHOWMODE_LABEL"
description="MOD_WHOSONLINE_SHOWMODE_DESC"
default="0"
filter="integer"
>
<option
value="0">MOD_WHOSONLINE_FIELD_VALUE_NUMBER</option>
<option
value="1">MOD_WHOSONLINE_FIELD_VALUE_NAMES</option>
<option
value="2">MOD_WHOSONLINE_FIELD_VALUE_BOTH</option>
</field>
<field
name="filter_groups"
type="radio"
label="MOD_WHOSONLINE_FIELD_FILTER_GROUPS_LABEL"
description="MOD_WHOSONLINE_FIELD_FILTER_GROUPS_DESC"
class="btn-group btn-group-yesno"
default="0"
filter="integer"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
</fieldset>
<fieldset name="advanced">
<field
name="layout"
type="modulelayout"
label="JFIELD_ALT_LAYOUT_LABEL"
description="JFIELD_ALT_MODULE_LAYOUT_DESC"
/>
<field
name="moduleclass_sfx"
type="textarea"
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
description="COM_MODULES_FIELD_MODULECLASS_SFX_DESC"
rows="3"
/>
<field
name="cache"
type="list"
label="COM_MODULES_FIELD_CACHING_LABEL"
description="COM_MODULES_FIELD_CACHING_DESC"
default="0"
filter="integer"
>
<option
value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
</field>
<field
name="cache_time"
type="number"
label="COM_MODULES_FIELD_CACHE_TIME_LABEL"
description="COM_MODULES_FIELD_CACHE_TIME_DESC"
default="900"
filter="integer"
/>
</fieldset>
</fields>
</config>
</extension>
tmpl/default.php000064400000001662151166622450007672 0ustar00<?php
/**
* @package Joomla.Site
* @subpackage mod_whosonline
*
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All
rights reserved.
* @license GNU General Public License version 2 or later; see
LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<?php if ($showmode == 0 || $showmode == 2) : ?>
<?php $guest = JText::plural('MOD_WHOSONLINE_GUESTS',
$count['guest']); ?>
<?php $member = JText::plural('MOD_WHOSONLINE_MEMBERS',
$count['user']); ?>
<p><?php echo JText::sprintf('MOD_WHOSONLINE_WE_HAVE',
$guest, $member); ?></p>
<?php endif; ?>
<?php if (($showmode > 0) && count($names)) : ?>
<?php if ($params->get('filter_groups', 0)) : ?>
<p><?php echo
JText::_('MOD_WHOSONLINE_SAME_GROUP_MESSAGE'); ?></p>
<?php endif; ?>
<ul class="whosonline<?php echo $moduleclass_sfx;
?>">
<?php foreach ($names as $name) : ?>
<li>
<?php echo $name->username; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif;