- md5
- d0d9d01b8cdb70c4d9b0db963712d28e
- sha1
- c134557a2d6b3c78c12d2e56d48d3c731ac42831
- sha256
- 79afc3646c39408de69bd17d1b370851b878db073f10ff159c6380d5a0ec6580
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
<?php
/**
* @package Joomla.Administrator
* @subpackage com_associations
*
* @copyright Copyright (C) 2005 - 2018 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Associations\Administrator\Controller;
defined('_JEXEC') or die;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\FormController;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
use Joomla\Component\Associations\Administrator\Helper\AssociationsHelper;
/**
* Association edit controller class.
*
* @since 3.7.0
*/
class AssociationController extends FormController
{
/**
* Method to edit an existing record.
*
* @param string $key The name of the primary key of the URL variable.
* @param string $urlVar The name of the URL variable if different from the primary key
* (sometimes required to avoid router collisions).
*
* @return boolean True if access level check and checkout passes, false otherwise.
*
* @since 3.7.0
*/
public function edit($key = null, $urlVar = null)
{
list($extensionName, $typeName) = explode('.', $this->input->get('itemtype', '', 'string'), 2);
$id = $this->input->get('id', 0, 'int');
// Check if reference item can be edited.
if (!AssociationsHelper::allowEdit($extensionName, $typeName, $id))
{
$this->setMessage(Text::_('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED'), 'error');
$this->setRedirect(Route::_('index.php?option=com_associations&view=associations', false));
return false;
}
return parent::display();
}
/**
* Method for canceling the edit action
*
* @param string $key The name of the primary key of the URL variable.
*
* @return void
*
* @since 3.7.0
*/
public function cancel($key = null)
{
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
list($extensionName, $typeName) = explode('.', $this->input->get('itemtype', '', 'string'), 2);
// Only check in, if component item type allows to check out.
if (AssociationsHelper::typeSupportsCheckout($extensionName, $typeName))
{
$ids = array();
$targetId = $this->input->get('target-id', '', 'string');
if ($targetId !== '')
{
$ids = array_unique(explode(',', $targetId));
}
$ids[] = $this->input->get('id', 0, 'int');
foreach ($ids as $key => $id)
{
AssociationsHelper::getItem($extensionName, $typeName, $id)->checkin();
}
}
$this->setRedirect(Route::_('index.php?option=com_associations&view=associations', false));
}
}
The same content is in 2 releases, Joomla 4.0.0-alpha5 to 4.0.0-alpha6. See them all, or every version of this file.