primo commit

This commit is contained in:
2024-12-17 17:34:10 +01:00
commit e650f8df99
16435 changed files with 2451012 additions and 0 deletions

View File

@ -0,0 +1,69 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage mod_guidedtours
*
* @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\Module\GuidedTours\Administrator\Dispatcher;
use Joomla\CMS\Dispatcher\AbstractModuleDispatcher;
use Joomla\CMS\Helper\HelperFactoryAwareInterface;
use Joomla\CMS\Helper\HelperFactoryAwareTrait;
use Joomla\CMS\Plugin\PluginHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Dispatcher class for mod_guidedtours
*
* @since 4.3.0
*/
class Dispatcher extends AbstractModuleDispatcher implements HelperFactoryAwareInterface
{
use HelperFactoryAwareTrait;
/**
* Runs the dispatcher.
*
* @return void
*
* @since 4.3.0
*/
public function dispatch()
{
// The guided tour will not show if no user is logged in.
$user = $this->getApplication()->getIdentity();
if ($user === null || $user->id === 0) {
return;
}
// The module can't show if the plugin is not enabled.
if (!PluginHelper::isEnabled('system', 'guidedtours')) {
return;
}
parent::dispatch();
}
/**
* Returns the layout data.
*
* @return array
*
* @since 4.3.0
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
$data['tours'] = $this->getHelperFactory()->getHelper('GuidedToursHelper')->getTours($data['params'], $this->getApplication());
return $data;
}
}

View File

@ -0,0 +1,73 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage mod_guidedtours
*
* @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\Module\GuidedTours\Administrator\Helper;
use Joomla\CMS\Application\AdministratorApplication;
use Joomla\CMS\Language\Multilanguage;
use Joomla\Registry\Registry;
use Joomla\Uri\Uri;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Helper for mod_guidedtours
*
* @since 4.3.0
*/
class GuidedToursHelper
{
/**
* Get a list of tours from a specific context.
*
* @param Registry $params Object holding the module parameters
* @param AdministratorApplication $app The application
*
* @return mixed
*
* @since 4.3.0
*/
public function getTours(Registry $params, AdministratorApplication $app)
{
$factory = $app->bootComponent('com_guidedtours')->getMVCFactory();
$user = $app->getIdentity();
// Get an instance of the guided tour model
$tourModel = $factory->createModel('Tours', 'Administrator', ['ignore_request' => true]);
$tourModel->setState('filter.published', 1);
$tourModel->setState('filter.access', $app->getIdentity()->getAuthorisedViewLevels());
if (Multilanguage::isEnabled()) {
$tourModel->setState('filter.language', ['*', $app->getLanguage()->getTag()]);
}
$items = $tourModel->getItems();
foreach ($items as $key => $item) {
// The user can only see the tours of extensions that are allowed.
$uri = new Uri($item->url);
if ($extension = $uri->getVar('option')) {
if ($extension === 'com_categories') {
$extension = $uri->getVar('extension');
}
if (!$user->authorise('core.manage', $extension)) {
unset($items[$key]);
}
}
}
return $items;
}
}