Skip to content

Commit

Permalink
Ensure compatibilty with J3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
alve89 committed Nov 2, 2021
1 parent b023f29 commit 23cbc79
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 35 deletions.
38 changes: 10 additions & 28 deletions block_access.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,66 +13,48 @@
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Application\CMSApplication;

class plgSystemBlock_access extends JPlugin
{
class plgSystemBlock_access extends JPlugin {

function plgSystemBlock_access(& $subject, $config)
{
parent::__construct($subject, $config);
}


function onAfterInitialise() // onAfterDispatch()
{
function onAfterInitialise() { // onAfterDispatch()
$app = JFactory::getApplication();
$user = JFactory::getUser();
$session= JFactory::getSession();

if (!$this->params->get('securitykey') || $session->get('block_access'))
{
if (!$this->params->get('securitykey') || $session->get('block_access')) {
return;
}
// Check if security key has been entered
$logged = isset($_GET[$this->params->get('securitykey')]);

// Check the current area the user wants so enter (site / admin)
if ($app->isClient('site'))
{
if ($app->isClient('site')) {
$area = "site";
}

if ($app->isClient('administrator'))
{
if ($app->isClient('administrator')) {
$area = "admin";
}

$securedArea = strtolower($this->params->get('area'));

if($area == $securedArea || $securedArea == "both")
{
if ($logged)
{
if($area == $securedArea || $securedArea == "both") {
if ($logged) {
$session = JFactory::getSession();
$session->set('block_access', true);
// return true;
}
else {
$this->blockArea();
}

}

}

function blockArea()
{
if($this->params->get('typeOfBlock') == "message")
{
function blockArea() {
if($this->params->get('typeOfBlock') == "message") {
header('HTTP/1.0 403 Forbidden');
die($this->params->get('text'));
}
elseif($this->params->get('typeOfBlock') == "errorpage")
{
elseif($this->params->get('typeOfBlock') == "errorpage") {
$uri = Uri::getInstance();
$url = $uri->toString();
(CMSApplication::getInstance('site'))->redirect(JUri::root(), 301);
Expand Down
14 changes: 10 additions & 4 deletions block_access.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="plugin" group="system" method="upgrade" version="[34].[123456789]">
<extension version="3.6" type="plugin" group="system" method="upgrade">
<name>PLG_BLOCK_ACCESS_NAME</name>
<author>Stefan Herzog</author>
<creationDate>October 2021</creationDate>
<copyright>This plugin is released under the GNU/GPL License</copyright>
<license>GNU General Public License</license>
<authorEmail>joomla@devel.stefan-herzog.com</authorEmail>
<version>1.1.5</version>
<version>1.1.6</version>
<description>PLG_BLOCK_ACCESS_DESC</description>
<files>
<filename plugin="block_access">block_access.php</filename>
<filename>index.html</filename>
<folder>language</folder>
</files>
</files>
<config>
<fields name="params">
<fieldset name="basic">
Expand All @@ -30,7 +30,13 @@
</fieldset>
</fields>
</config>

<languages folder="language/de-DE">
<language tag="de-DE">de-DE.plg_system_block_access.ini</language>
<language tag="de-DE">de-DE.plg_system_block_access.sys.ini</language>
</languages>

<updateservers>
<server type="extension" name="PLG_BLOCK_ACCESS_NAME">https://raw.githubusercontent.com/alve89/plg_block_access/master/updates.xml</server>
<server type="extension" name="PLG_BLOCK_ACCESS">https://raw.githubusercontent.com/alve89/plg_block_access/master/updates.xml</server>
</updateservers>
</extension>
6 changes: 3 additions & 3 deletions updates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
<type>plugin</type>
<folder>system</folder>
<client>0</client>
<version>1.1.5</version>
<version>1.1.6</version>
<downloads>
<downloadurl type="full" format="zip">https://github.com/alve89/plg_block_access/archive/v1.1.5.zip</downloadurl>
<downloadurl type="full" format="zip">https://github.com/alve89/plg_block_access/archive/v1.1.6.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
</tags>
<maintainer>Stefan Herzog</maintainer>
<maintainerurl>https://github.com/alve89</maintainerurl>
<targetplatform name="joomla" version="[34].[123456789]"/>
<targetplatform name="joomla" version="3.10"/>
</update>
</updates>

0 comments on commit 23cbc79

Please sign in to comment.