Your IP : 216.73.216.74


Current Path : /home/bonneesp/www/administrator/components/com_icagenda/controllers/
Upload File :
Current File : /home/bonneesp/www/administrator/components/com_icagenda/controllers/registration.php

<?php
/**
 *------------------------------------------------------------------------------
 *  iCagenda v3 by Jooml!C - Events Management Extension for Joomla! 2.5 / 3.x
 *------------------------------------------------------------------------------
 * @package     com_icagenda
 * @copyright   Copyright (c)2012-2021 Cyril Rezé, Jooml!C - All rights reserved
 *
 * @license     GNU General Public License version 3 or later; see LICENSE.txt
 * @author      Cyril Rezé (Lyr!C)
 * @link        http://www.joomlic.com
 *
 * @version     3.6.0 2016-03-01
 * @since       3.3.3
 *------------------------------------------------------------------------------
*/

// No direct access to this file
defined('_JEXEC') or die();

jimport('joomla.application.component.controllerform');

/**
 * Registration controller class.
 */
class iCagendaControllerRegistration extends JControllerForm
{
    function __construct()
    {
        $this->view_list = 'registrations';
        parent::__construct();
    }

	/**
	 * Return Ajax to load date select options
	 *
	 * @since 3.5.9
	 */
	function dates()
	{
		icagendaAjax::getOptionsEventDates('registration');

		// Cut the execution short
//		JFactory::getApplication()->close();
	}

	/**
	 * Return Full name/Username using Ajax (depending on Global Options)
	 *
	 * @since 3.6.0
	 */
	function registrationName()
	{
		$userId = JFactory::getApplication()->input->get('userid', '');

		icagendaAjax::getRegistrationName($userId);

//		$user = JFactory::getUser($userId);

//		return $user->name;
	}

	/**
	 * Method override to check if you can edit an existing record.
	 *
	 * @param   array   $data  An array of input data.
	 * @param   string  $key   The name of the key for the primary key.
	 *
	 * @return  boolean
	 *
	 * @since   3.3.3
	 */
	protected function allowEdit($data = array(), $key = 'id')
	{
		// Initialise variables.
		$recordId	= (int) isset($data[$key]) ? $data[$key] : 0;
		$user		= JFactory::getUser();
		$userId		= $user->get('id');

		// Check general edit permission first.
		if ($user->authorise('core.edit', 'com_icagenda.registration.' . $recordId))
		{
			return true;
		}

		// Fallback on edit.own.
		// First test if the permission is available.
		if ($user->authorise('core.edit.own', 'com_icagenda.registration.' . $recordId))
		{
			// Now test the owner is the user.
			$ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0;
			if (empty($ownerId) && $recordId)
			{
				// Need to do a lookup from the model.
				$record = $this->getModel()->getItem($recordId);

				if (empty($record))
				{
					return false;
				}

				$ownerId = $record->created_by;
			}

			// If the owner matches 'me' then do the test.
			if ($ownerId == $userId)
			{
				return true;
			}
		}

		// Since there is no asset tracking, revert to the component permissions.
		return parent::allowEdit($data, $key);
	}
}