first commit
This commit is contained in:
21
plugins/system/logout/logout.xml
Normal file
21
plugins/system/logout/logout.xml
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extension type="plugin" group="system" method="upgrade">
|
||||
<name>plg_system_logout</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>2009-04</creationDate>
|
||||
<copyright>(C) 2009 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>PLG_SYSTEM_LOGOUT_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\System\Logout</namespace>
|
||||
<files>
|
||||
<folder plugin="logout">services</folder>
|
||||
<folder>src</folder>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">language/en-GB/plg_system_logout.ini</language>
|
||||
<language tag="en-GB">language/en-GB/plg_system_logout.sys.ini</language>
|
||||
</languages>
|
||||
</extension>
|
||||
44
plugins/system/logout/services/provider.php
Normal file
44
plugins/system/logout/services/provider.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage System.logout
|
||||
*
|
||||
* @copyright (C) 2023 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\Extension\PluginInterface;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\Plugin\System\Logout\Extension\Logout;
|
||||
|
||||
return new class () implements ServiceProviderInterface {
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.4.0
|
||||
*/
|
||||
public function register(Container $container): void
|
||||
{
|
||||
$container->set(
|
||||
PluginInterface::class,
|
||||
function (Container $container) {
|
||||
return new Logout(
|
||||
$container->get(DispatcherInterface::class),
|
||||
(array) PluginHelper::getPlugin('system', 'logout'),
|
||||
Factory::getApplication()
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
88
plugins/system/logout/src/Extension/Logout.php
Normal file
88
plugins/system/logout/src/Extension/Logout.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Joomla.Plugin
|
||||
* @subpackage System.logout
|
||||
*
|
||||
* @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\Plugin\System\Logout\Extension;
|
||||
|
||||
use Joomla\CMS\Application\ApplicationHelper;
|
||||
use Joomla\CMS\Application\CMSApplicationInterface;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
|
||||
// phpcs:disable PSR1.Files.SideEffects
|
||||
\defined('_JEXEC') or die;
|
||||
// phpcs:enable PSR1.Files.SideEffects
|
||||
|
||||
/**
|
||||
* Plugin class for logout redirect handling.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
final class Logout extends CMSPlugin
|
||||
{
|
||||
/**
|
||||
* @param DispatcherInterface $dispatcher The object to observe -- event dispatcher.
|
||||
* @param array $config An optional associative array of configuration settings.
|
||||
* @param CMSApplicationInterface $app The object to observe -- event dispatcher.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function __construct(DispatcherInterface $dispatcher, array $config, CMSApplicationInterface $app)
|
||||
{
|
||||
parent::__construct($dispatcher, $config);
|
||||
|
||||
$this->setApplication($app);
|
||||
|
||||
// If we are on admin don't process.
|
||||
if (!$this->getApplication()->isClient('site')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$hash = ApplicationHelper::getHash('PlgSystemLogout');
|
||||
|
||||
if ($this->getApplication()->getInput()->cookie->getString($hash)) {
|
||||
// Destroy the cookie.
|
||||
$this->getApplication()->getInput()->cookie->set(
|
||||
$hash,
|
||||
'',
|
||||
1,
|
||||
$this->getApplication()->get('cookie_path', '/'),
|
||||
$this->getApplication()->get('cookie_domain', '')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to handle any logout logic and report back to the subject.
|
||||
*
|
||||
* @param array $user Holds the user data.
|
||||
* @param array $options Array holding options (client, ...).
|
||||
*
|
||||
* @return boolean Always returns true.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
public function onUserLogout($user, $options = [])
|
||||
{
|
||||
if ($this->getApplication()->isClient('site')) {
|
||||
// Create the cookie.
|
||||
$this->getApplication()->getInput()->cookie->set(
|
||||
ApplicationHelper::getHash('PlgSystemLogout'),
|
||||
true,
|
||||
time() + 86400,
|
||||
$this->getApplication()->get('cookie_path', '/'),
|
||||
$this->getApplication()->get('cookie_domain', ''),
|
||||
$this->getApplication()->isHttpsForced(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user