Your IP : 216.73.216.240


Current Path : /home/juvelize/www/plugins/icagenda/tickets/
Upload File :
Current File : /home/juvelize/www/plugins/icagenda/tickets/tickets.php

<?php
/**
 *----------------------------------------------------------------------------
 * iCagenda     Plugin Tickets
 *----------------------------------------------------------------------------
 * @version     1.0.0 2021-11-19
 *
 * @package     iCagenda.Plugin
 * @subpackage  icagenda.tickets
 * @link        https://www.icagenda.com
 *
 * @author      Cyril Rezé
 * @copyright   (c) 2012-2024 Cyril Rezé / iCagenda. All rights reserved.
 * @license     GNU General Public License version 3 or later; see LICENSE.txt
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @since       iCagenda 3.8
 *----------------------------------------------------------------------------
*/

defined('_JEXEC') or die;

jimport('joomla.plugin.plugin');

/**
 * plgIcagendaTickets
 */
class plgIcagendaTickets extends JPlugin
{
	/**
	 * Load the language file on instantiation.
	 */
	protected $autoloadLanguage = true;

	function onContentPrepareForm($form, $data)
	{
		$app    = JFactory::getApplication();
		$input  = $app->input;
		$option = $input->get('option');
		$view   = $input->get('view');
		$layout = $input->get('layout');

		$iCparams = JComponentHelper::getParams('com_icagenda');

		if ($iCparams->get('icsys') == 'core')
		{
			return;
		}

		switch ($option)
		{
			case 'com_icagenda':
				if ($form->getName() == 'com_icagenda.event')
				{
					JForm::addFormPath(__DIR__ . '/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')
				{
					JForm::addFormPath(__DIR__ . '/forms');
					$form->loadFile('config', false);
				}

				return true;
		}

		return true;
	}
}