- md5
- 9ee3681e61a77c6b20ada5272ba227b4
- sha1
- 0db855f6dc9414240fe1bcfd856486aab954856e
- sha256
- baa48f57a834964ab4f111365c4266255650137aba2c1a9dd1416998d4ccc4f1
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
<?php
/**
* @package Joomla.Administrator
* @subpackage com_config
*
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Config\Administrator\Dispatcher;
use Joomla\CMS\Access\Exception\NotAllowed;
use Joomla\CMS\Dispatcher\ComponentDispatcher;
use Joomla\Component\Config\Administrator\Helper\ConfigHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* ComponentDispatcher class for com_config
*
* @since 4.2.9
*/
class Dispatcher extends ComponentDispatcher
{
/**
* Check if the user have the right access to the component config
*
* @return void
*
* @since 4.2.9
*
* @throws \Exception
*/
protected function checkAccess(): void
{
// sendtestmail expects json response, so we leave the method to handle the permission and send response itself
if ($this->input->getCmd('task') === 'application.sendtestmail') {
return;
}
$task = $this->input->getCmd('task', 'display');
$view = $this->input->getCmd('view');
$component = $this->input->getCmd('component');
if ($component && (substr($task, 0, 10) === 'component.' || $view === 'component')) {
// User is changing component settings, check if he has permission to do that
$canAccess = ConfigHelper::canChangeComponentConfig($component);
} else {
// For everything else, user is required to have global core.admin permission to perform action
$canAccess = $this->app->getIdentity()->authorise('core.admin');
}
if (!$canAccess) {
throw new NotAllowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403);
}
}
}
The same content is in 18 releases, Joomla 4.2.9-rc1 to 5.0.0-alpha3. See them all, or every version of this file.