first commit
This commit is contained in:
29
administrator/modules/mod_logged/mod_logged.php
Normal file
29
administrator/modules/mod_logged/mod_logged.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage mod_logged
|
||||
*
|
||||
* @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Helper\ModuleHelper;
|
||||
use Joomla\Database\DatabaseInterface;
|
||||
use Joomla\Module\Logged\Administrator\Helper\LoggedHelper;
|
||||
|
||||
if ($params->get('automatic_title', 0)) {
|
||||
$module->title = LoggedHelper::getTitle($params);
|
||||
}
|
||||
|
||||
// Check if session metadata tracking is enabled
|
||||
if ($app->get('session_metadata', true)) {
|
||||
$users = LoggedHelper::getList($params, $app, Factory::getContainer()->get(DatabaseInterface::class));
|
||||
|
||||
require ModuleHelper::getLayoutPath('mod_logged', $params->get('layout', 'default'));
|
||||
} else {
|
||||
require ModuleHelper::getLayoutPath('mod_logged', 'disabled');
|
||||
}
|
||||
79
administrator/modules/mod_logged/mod_logged.xml
Normal file
79
administrator/modules/mod_logged/mod_logged.xml
Normal file
@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="module" client="administrator" method="upgrade">
|
||||
<name>mod_logged</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2005-01</creationDate>
|
||||
<copyright>(C) 2005 Open Source Matters, Inc.</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_LOGGED_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Module\Logged</namespace>
|
||||
<files>
|
||||
<filename module="mod_logged">mod_logged.php</filename>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/mod_logged.ini</language>
|
||||
<language tag="en-GB">language/en-GB/mod_logged.sys.ini</language>
|
||||
</languages>
|
||||
<help key="Admin_Modules:_Logged-in_Users" />
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="count"
|
||||
type="number"
|
||||
label="MOD_LOGGED_FIELD_COUNT_LABEL"
|
||||
default="5"
|
||||
filter="integer"
|
||||
min="1"
|
||||
validate="number"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="name"
|
||||
type="list"
|
||||
label="MOD_LOGGED_NAME"
|
||||
default="1"
|
||||
filter="integer"
|
||||
validate="options"
|
||||
>
|
||||
<option value="1">MOD_LOGGED_NAME</option>
|
||||
<option value="0">JGLOBAL_USERNAME</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="advanced">
|
||||
<field
|
||||
name="layout"
|
||||
type="modulelayout"
|
||||
label="JFIELD_ALT_LAYOUT_LABEL"
|
||||
class="form-select"
|
||||
validate="moduleLayout"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="moduleclass_sfx"
|
||||
type="textarea"
|
||||
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
|
||||
rows="3"
|
||||
validate="CssIdentifier"
|
||||
/>
|
||||
|
||||
<field
|
||||
name="automatic_title"
|
||||
type="radio"
|
||||
label="COM_MODULES_FIELD_AUTOMATIC_TITLE_LABEL"
|
||||
layout="joomla.form.field.radio.switcher"
|
||||
default="0"
|
||||
filter="integer"
|
||||
>
|
||||
<option value="0">JNO</option>
|
||||
<option value="1">JYES</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
||||
89
administrator/modules/mod_logged/src/Helper/LoggedHelper.php
Normal file
89
administrator/modules/mod_logged/src/Helper/LoggedHelper.php
Normal file
@ -0,0 +1,89 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage mod_logged
|
||||
*
|
||||
* @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Module\Logged\Administrator\Helper;
|
||||
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Session\Session;
|
||||
use Joomla\Database\DatabaseInterface;
|
||||
use Joomla\Registry\Registry;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Helper for mod_logged
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
abstract class LoggedHelper
|
||||
{
|
||||
/**
|
||||
* Get a list of logged users.
|
||||
*
|
||||
* @param Registry $params The module parameters
|
||||
* @param CMSApplication $app The application
|
||||
* @param DatabaseInterface $db The database
|
||||
*
|
||||
* @return mixed An array of users, or false on error.
|
||||
*
|
||||
* @throws \RuntimeException
|
||||
*/
|
||||
public static function getList(Registry $params, CMSApplication $app, DatabaseInterface $db)
|
||||
{
|
||||
$user = $app->getIdentity();
|
||||
$query = $db->getQuery(true)
|
||||
->select('s.time, s.client_id, u.id, u.name, u.username')
|
||||
->from('#__session AS s')
|
||||
->join('LEFT', '#__users AS u ON s.userid = u.id')
|
||||
->where('s.guest = 0')
|
||||
->setLimit($params->get('count', 5), 0);
|
||||
|
||||
$db->setQuery($query);
|
||||
|
||||
try {
|
||||
$results = $db->loadObjectList();
|
||||
} catch (\RuntimeException $e) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
foreach ($results as $k => $result) {
|
||||
$results[$k]->logoutLink = '';
|
||||
|
||||
if ($user->authorise('core.manage', 'com_users')) {
|
||||
$results[$k]->editLink = Route::_('index.php?option=com_users&task=user.edit&id=' . $result->id);
|
||||
$results[$k]->logoutLink = Route::_(
|
||||
'index.php?option=com_login&task=logout&uid=' . $result->id . '&' . Session::getFormToken() . '=1'
|
||||
);
|
||||
}
|
||||
|
||||
if ($params->get('name', 1) == 0) {
|
||||
$results[$k]->name = $results[$k]->username;
|
||||
}
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the alternate title for the module
|
||||
*
|
||||
* @param \Joomla\Registry\Registry $params The module parameters.
|
||||
*
|
||||
* @return string The alternate title for the module.
|
||||
*/
|
||||
public static function getTitle($params)
|
||||
{
|
||||
return Text::plural('MOD_LOGGED_TITLE', $params->get('count', 5));
|
||||
}
|
||||
}
|
||||
64
administrator/modules/mod_logged/tmpl/default.php
Normal file
64
administrator/modules/mod_logged/tmpl/default.php
Normal file
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage mod_logged
|
||||
*
|
||||
* @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Language\Text;
|
||||
?>
|
||||
<table class="table" id="<?php echo str_replace(' ', '', $module->title) . $module->id; ?>">
|
||||
<caption class="visually-hidden"><?php echo $module->title; ?></caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="w-50">
|
||||
<?php if ($params->get('name', 1) == 0) : ?>
|
||||
<?php echo Text::_('JGLOBAL_USERNAME'); ?>
|
||||
<?php else : ?>
|
||||
<?php echo Text::_('MOD_LOGGED_NAME'); ?>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<th scope="col" class="w-30"><?php echo Text::_('JCLIENT'); ?></th>
|
||||
<th scope="col" class="w-20"><?php echo Text::_('JDATE'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($users as $user) : ?>
|
||||
<tr>
|
||||
<th scope="row">
|
||||
<?php if (isset($user->editLink)) : ?>
|
||||
<a href="<?php echo $user->editLink; ?>" title="<?php echo Text::_('JACTION_EDIT'); ?> <?php echo htmlspecialchars($user->name, ENT_QUOTES, 'UTF-8'); ?>">
|
||||
<?php echo htmlspecialchars($user->name, ENT_QUOTES, 'UTF-8'); ?>
|
||||
</a>
|
||||
<?php else : ?>
|
||||
<?php echo htmlspecialchars($user->name, ENT_QUOTES, 'UTF-8'); ?>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<td>
|
||||
<?php if ($user->client_id === null) : ?>
|
||||
<?php // This is a shared session so we do not know the client ?>
|
||||
<?php echo Text::_('JGLOBAL_NONAPPLICABLE'); ?>
|
||||
<?php elseif ($user->client_id) : ?>
|
||||
<?php echo Text::_('JADMINISTRATION'); ?>
|
||||
<?php else : ?>
|
||||
<form action="<?php echo $user->logoutLink; ?>" method="post" name="adminForm">
|
||||
<?php echo Text::_('JSITE'); ?>
|
||||
<button type="submit" class="me-2 btn btn-danger btn-sm">
|
||||
<?php echo Text::_('JLOGOUT'); ?>
|
||||
</button>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php echo HTMLHelper::_('date', $user->time, Text::_('DATE_FORMAT_LC5')); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
21
administrator/modules/mod_logged/tmpl/disabled.php
Normal file
21
administrator/modules/mod_logged/tmpl/disabled.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage mod_logged
|
||||
*
|
||||
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
|
||||
?>
|
||||
<div class="mb-4">
|
||||
<p class="fw-bold text-center text-muted">
|
||||
<span class="icon-users" aria-hidden="true"></span>
|
||||
<?php echo Text::_('MOD_LOGGED_NO_SESSION_METADATA'); ?>
|
||||
</p>
|
||||
</div>
|
||||
Reference in New Issue
Block a user