You've already forked joomla_test
first commit
This commit is contained in:
85
modules/mod_whosonline/helper.php
Normal file
85
modules/mod_whosonline/helper.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_whosonline
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 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
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_whosonline
|
||||
* @since 1.5
|
||||
*/
|
||||
class ModWhosonlineHelper
|
||||
{
|
||||
// show online count
|
||||
public static function getOnlineCount()
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
// calculate number of guests and users
|
||||
$result = array();
|
||||
$user_array = 0;
|
||||
$guest_array = 0;
|
||||
$query = $db->getQuery(true)
|
||||
->select('guest, client_id')
|
||||
->from('#__session')
|
||||
->where('client_id = 0');
|
||||
$db->setQuery($query);
|
||||
$sessions = (array) $db->loadObjectList();
|
||||
|
||||
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
|
||||
public static function getOnlineUserNames($params)
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName(array('a.username', 'a.time', 'a.userid', 'a.client_id')))
|
||||
->from('#__session AS a')
|
||||
->where($db->quoteName('a.userid') . ' != 0')
|
||||
->where($db->quoteName('a.client_id') . ' = 0')
|
||||
->group($db->quoteName(array('a.username', 'a.time', '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);
|
||||
return (array) $db->loadObjectList();
|
||||
}
|
||||
}
|
1
modules/mod_whosonline/index.html
Normal file
1
modules/mod_whosonline/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
30
modules/mod_whosonline/mod_whosonline.php
Normal file
30
modules/mod_whosonline/mod_whosonline.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_whosonline
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 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
|
||||
require_once __DIR__ . '/helper.php';
|
||||
|
||||
$showmode = $params->get('showmode', 0);
|
||||
|
||||
if ($showmode == 0 || $showmode == 2)
|
||||
{
|
||||
$count = ModWhosonlineHelper::getOnlineCount();
|
||||
}
|
||||
|
||||
if ($showmode > 0)
|
||||
{
|
||||
$names = ModWhosonlineHelper::getOnlineUserNames($params);
|
||||
}
|
||||
|
||||
$linknames = $params->get('linknames', 0);
|
||||
$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'));
|
||||
|
||||
require JModuleHelper::getLayoutPath('mod_whosonline', $params->get('layout', 'default'));
|
81
modules/mod_whosonline/mod_whosonline.xml
Normal file
81
modules/mod_whosonline/mod_whosonline.xml
Normal file
@ -0,0 +1,81 @@
|
||||
<?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 - 2013 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>
|
||||
<filename>index.html</filename>
|
||||
<filename>mod_whosonline.xml</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"
|
||||
default="0"
|
||||
label="MOD_WHOSONLINE_SHOWMODE_LABEL"
|
||||
description="MOD_WHOSONLINE_SHOWMODE_DESC">
|
||||
<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>
|
||||
</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" rows="3"
|
||||
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
|
||||
description="COM_MODULES_FIELD_MODULECLASS_SFX_DESC" />
|
||||
<field
|
||||
name="cache"
|
||||
type="list"
|
||||
default="0"
|
||||
label="COM_MODULES_FIELD_CACHING_LABEL"
|
||||
description="COM_MODULES_FIELD_CACHING_DESC">
|
||||
<option
|
||||
value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
|
||||
</field>
|
||||
<field
|
||||
name="filter_groups"
|
||||
type="radio"
|
||||
class="btn-group"
|
||||
default="0"
|
||||
label="MOD_WHOSONLINE_FIELD_FILTER_GROUPS_LABEL"
|
||||
description="MOD_WHOSONLINE_FIELD_FILTER_GROUPS_DESC">
|
||||
<option
|
||||
value="0">JNO</option>
|
||||
<option
|
||||
value="1">JYES</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
30
modules/mod_whosonline/tmpl/default.php
Normal file
30
modules/mod_whosonline/tmpl/default.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_whosonline
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 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)) : ?>
|
||||
<ul class="whosonline<?php echo $moduleclass_sfx ?>" >
|
||||
<?php if ($params->get('filter_groups')):?>
|
||||
<p><?php echo JText::_('MOD_WHOSONLINE_SAME_GROUP_MESSAGE'); ?></p>
|
||||
<?php endif;?>
|
||||
<?php foreach ($names as $name) : ?>
|
||||
<li>
|
||||
<?php echo $name->username; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif;
|
1
modules/mod_whosonline/tmpl/index.html
Normal file
1
modules/mod_whosonline/tmpl/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
Reference in New Issue
Block a user