| Current Path : /home/juvelize/www/administrator/components/com_icagenda/controllers/ |
| Current File : /home/juvelize/www/administrator/components/com_icagenda/controllers/registration.php |
<?php
/**
*----------------------------------------------------------------------------
* iCagenda Events Management Extension for Joomla!
*----------------------------------------------------------------------------
* @version 3.8.0 2019-07-19
*
* @package iCagenda.Admin
* @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
*
* @since 3.3.3
*----------------------------------------------------------------------------
*/
defined('_JEXEC') or die;
/**
* Registration controller class.
*/
class iCagendaControllerRegistration extends JControllerForm
{
/**
* Class constructor.
*
* @param array $config A named array of configuration variables.
*
* @since 3.3.3
*/
public function __construct($config = array())
{
parent::__construct($config);
}
/**
* 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);
}
}