- md5
- a2d3d3ef718df8c8313f3601da1bf654
- sha1
- 9d314665cf73ec4cd6ac7164c3f4744bb92e0c00
- sha256
- 32648645f68f9f4044620d866c1f5c777b41245164a076d0dea36372f0f9d536
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
<?php
/**
* @package Joomla.Site
* @subpackage com_menus
*
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Menus\Site\Dispatcher;
use Joomla\CMS\Access\Exception\NotAllowed;
use Joomla\CMS\Dispatcher\ComponentDispatcher;
use Joomla\CMS\MVC\Controller\BaseController;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* ComponentDispatcher class for com_menus
*
* @since 4.0.0
*/
class Dispatcher extends ComponentDispatcher
{
/**
* Load the language
*
* @since 4.0.0
*
* @return void
*/
protected function loadLanguage()
{
$this->app->getLanguage()->load('com_menus', JPATH_ADMINISTRATOR);
}
/**
* Dispatch a controller task. Redirecting the user if appropriate.
*
* @return void
*
* @since 4.0.0
*/
public function checkAccess()
{
parent::checkAccess();
// The site only exposes the modal item selector (display). Any other task would be resolved
// against the administrator controllers, which are protected by the administrator-client
// core.manage check that does not apply to this request.
$task = $this->input->getCmd('task', 'display');
// The administrator main menu is a special menu type which the items model lists without a
// per menu core.manage check. It is not meant to be listed on the site.
$menuType = $this->input->get('menutype', '');
if (
$this->input->get('view') !== 'items'
|| $this->input->get('layout') !== 'modal'
|| !\in_array($task, ['', 'display'], true)
|| (\is_string($menuType) && strcasecmp(trim($menuType), 'main') === 0)
|| !$this->app->getIdentity()->authorise('core.create', 'com_menus')
) {
throw new NotAllowed($this->app->getLanguage()->_('JERROR_ALERTNOAUTHOR'), 403);
}
}
/**
* Get a controller from the component
*
* @param string $name Controller name
* @param string $client Optional client (like Administrator, Site etc.)
* @param array $config Optional controller config
*
* @return \Joomla\CMS\MVC\Controller\BaseController
*
* @since 4.0.0
*/
public function getController(string $name, string $client = '', array $config = []): BaseController
{
$config['base_path'] = JPATH_ADMINISTRATOR . '/components/com_menus';
$client = 'Administrator';
return parent::getController($name, $client, $config);
}
}
The same content is in 2 releases, Joomla 5.4.11 to 6.2.1. See them all, or every version of this file.