- md5
- b64407609dc7bd4d5d69df0f67288b0f
- sha1
- c9aa260f92afa69073ea72fd68aa2f0793d88243
- sha256
- 36eb1b238473aa660cba8a0a18e071173e68674682261ae12267bd067df48462
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
<?php
/**
* @package Joomla.Administrator
* @subpackage com_associations
*
* @copyright (C) 2017 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Associations\Administrator\Controller;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\FormController;
use Joomla\CMS\Router\Route;
use Joomla\Component\Associations\Administrator\Helper\AssociationsHelper;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* 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 FormController|boolean True if access level check and checkout passes, false otherwise.
*
* @since 3.7.0
*/
public function edit($key = null, $urlVar = null)
{
[$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 $this->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)
{
$this->checkToken();
[$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 = [];
$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 94 releases, Joomla 5.3.0-beta1 to 6.2.1-rc1. See them all, or every version of this file.