| Current Path : /home/juvelize/www/plugins/icagenda/tickets/src/Extension/ |
| Current File : /home/juvelize/www/plugins/icagenda/tickets/src/Extension/Tickets.php |
<?php
/**
*----------------------------------------------------------------------------
* iCagenda Plugin iCagenda - Tickets
*----------------------------------------------------------------------------
* @version 2.0.0 2024-02-12
*
* @package iCagenda
* @subpackage Plugin.Icagenda.Tickets
* @link https://www.icagenda.com
*
* @author Cyril Rezé
* @copyright (c) 2013-2024 Cyril Rezé / iCagenda. All rights reserved.
* @license GNU General Public License version 3 or later; see LICENSE.txt
*
* @since iCagenda 3.8
*----------------------------------------------------------------------------
*/
namespace W3biC\Plugin\Icagenda\Tickets\Extension;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\Plugin\CMSPlugin;
use Joomla\Database\DatabaseAwareTrait;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* iCagenda Tickets Plugin.
*/
final class Tickets extends CMSPlugin
{
use DatabaseAwareTrait;
/**
* Load the language file on instantiation.
*
* @var boolean
*/
protected $autoloadLanguage = true;
/**
* Adds additional fields to iCagenda Options
*
* @param Form $form The form to be altered.
* @param mixed $data The associated data for the form.
*
* @return boolean
*/
function onContentPrepareForm(Form $form, $data)
{
$app = Factory::getApplication();
$input = $app->input;
$option = $input->get('option');
$view = $input->get('view');
$layout = $input->get('layout');
$iCparams = ComponentHelper::getParams('com_icagenda');
if ($iCparams->get('icsys') == 'core') {
return;
}
switch ($option) {
case 'com_icagenda':
if ($form->getName() == 'com_icagenda.event') {
FormHelper::addFormPath(JPATH_PLUGINS . '/' . $this->_type . '/' . $this->_name . '/forms');
$form->loadFile('event', true);
if ($iCparams->get('statutReg') == 1) {
$form->setFieldAttribute('maxReg', 'showon', 'statutReg!:0', 'params');
$form->setFieldAttribute('tickets', 'showon', 'statutReg!:0', 'params');
// Multiple tickets not enabled yet.
$form->setFieldAttribute('maxReg', 'type', 'text', 'params');
$form->setFieldAttribute('tickets', 'layout', ' ', 'params');
$form->setFieldAttribute('tickets', 'type', 'hidden', 'params');
} else {
// Multiple tickets not enabled yet.
$form->setFieldAttribute('maxReg', 'type', 'text', 'params');
$form->setFieldAttribute('tickets', 'layout', ' ', 'params');
$form->setFieldAttribute('tickets', 'type', 'hidden', 'params');
}
}
return true;
case 'com_config':
$component = $app->input->get('component');
if ($app->isClient('administrator')
&& $component == 'com_icagenda'
) {
FormHelper::addFormPath(JPATH_PLUGINS . '/' . $this->_type . '/' . $this->_name . '/forms');
$form->loadFile('config', false);
}
return true;
}
return true;
}
}