2022-04-25 02:17:01 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @package Octoleo CMS
|
|
|
|
*
|
|
|
|
* @created 9th April 2022
|
|
|
|
* @author Llewellyn van der Merwe <https://git.vdm.dev/Llewellyn>
|
|
|
|
* @git WEBD-325-45 <https://git.vdm.dev/Llewellyn/WEBD-325-45>
|
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Octoleo\CMS\Controller;
|
|
|
|
|
|
|
|
use Joomla\Application\AbstractApplication;
|
|
|
|
use Joomla\Controller\AbstractController;
|
|
|
|
use Joomla\Input\Input;
|
|
|
|
use Laminas\Diactoros\Response\HtmlResponse;
|
2022-04-25 02:19:51 +00:00
|
|
|
use Octoleo\CMS\Controller\Util\AccessInterface;
|
|
|
|
use Octoleo\CMS\Controller\Util\AccessTrait;
|
|
|
|
use Octoleo\CMS\Controller\Util\CheckTokenInterface;
|
|
|
|
use Octoleo\CMS\Controller\Util\CheckTokenTrait;
|
|
|
|
use Octoleo\CMS\Factory;
|
|
|
|
use Octoleo\CMS\User\User;
|
|
|
|
use Octoleo\CMS\User\UserFactoryInterface;
|
|
|
|
use Octoleo\CMS\View\Admin\MenusHtmlView;
|
2022-04-25 02:17:01 +00:00
|
|
|
|
|
|
|
/**
|
2022-04-25 02:19:51 +00:00
|
|
|
* Controller handling the requests
|
2022-04-25 02:17:01 +00:00
|
|
|
*
|
|
|
|
* @method \Octoleo\CMS\Application\AdminApplication getApplication() Get the application object.
|
2022-04-25 02:19:51 +00:00
|
|
|
* @property-read \Octoleo\CMS\Application\AdminApplication $app Application object
|
2022-04-25 02:17:01 +00:00
|
|
|
*/
|
|
|
|
class MenusController extends AbstractController implements AccessInterface, CheckTokenInterface
|
|
|
|
{
|
|
|
|
use AccessTrait, CheckTokenTrait;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The view object.
|
|
|
|
*
|
|
|
|
* @var MenusHtmlView
|
|
|
|
*/
|
|
|
|
private $view;
|
|
|
|
|
2022-04-25 02:19:51 +00:00
|
|
|
/**
|
|
|
|
* @var User
|
|
|
|
*/
|
|
|
|
private $user;
|
|
|
|
|
2022-04-25 02:17:01 +00:00
|
|
|
/**
|
|
|
|
* Constructor.
|
|
|
|
*
|
2022-04-25 02:19:51 +00:00
|
|
|
* @param MenusHtmlView $view The view object.
|
|
|
|
* @param Input|null $input The input object.
|
|
|
|
* @param AbstractApplication|null $app The application object.
|
|
|
|
* @param User|null $user The user object.
|
2022-04-25 02:17:01 +00:00
|
|
|
*/
|
2022-04-25 02:19:51 +00:00
|
|
|
public function __construct(
|
|
|
|
MenusHtmlView $view,
|
|
|
|
Input $input = null,
|
|
|
|
AbstractApplication $app = null,
|
|
|
|
User $user = null)
|
2022-04-25 02:17:01 +00:00
|
|
|
{
|
|
|
|
parent::__construct($input, $app);
|
|
|
|
|
|
|
|
$this->view = $view;
|
2022-04-25 02:19:51 +00:00
|
|
|
$this->user = ($user) ?: Factory::getContainer()->get(UserFactoryInterface::class)->getUser();
|
2022-04-25 02:17:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Execute the controller.
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
* @throws \Exception
|
|
|
|
*/
|
|
|
|
public function execute(): bool
|
|
|
|
{
|
|
|
|
// Do not Enable browser caching
|
|
|
|
$this->getApplication()->allowCache(false);
|
|
|
|
|
|
|
|
$this->view->setActiveView('menus');
|
|
|
|
|
|
|
|
// check if user is allowed to access
|
2022-04-25 02:19:51 +00:00
|
|
|
if ($this->allow('menus') && $this->user->get('access.menu.read', false))
|
2022-04-25 02:17:01 +00:00
|
|
|
{
|
|
|
|
$this->getApplication()->setResponse(new HtmlResponse($this->view->render()));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// go to set page
|
|
|
|
$this->_redirect();
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|