- md5
- 079be42178f0198d67116b528e8e8762
- sha1
- e4d1566a6770ecf1e52f92ab626d8122f0647dee
- sha256
- 4462b9fb07d0249fbf5362908d9bd31eba6099d7897c8ca362ab7d89e5620a93
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
<?php
/**
* @package Joomla.API
* @subpackage com_banners
*
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Banners\Api\Controller;
use Joomla\CMS\Categories\CategoryChangeTrait;
use Joomla\CMS\MVC\Controller\ApiController;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* The banners controller
*
* @since 4.0.0
*/
class BannersController extends ApiController
{
use CategoryChangeTrait;
/**
* The content type of the item.
*
* @var string
* @since 4.0.0
*/
protected $contentType = 'banners';
/**
* The default view for the display method.
*
* @var string
* @since 3.0
*/
protected $default_view = 'banners';
/**
* Method to check if you can add a new record.
*
* Like in the administrator, the create permission is checked in the target category.
*
* @param array $data An array of input data.
*
* @return boolean
*
* @since 5.4.11
*/
protected function allowAdd($data = [])
{
if (!$this->allowCategoryAdd($data)) {
return false;
}
return parent::allowAdd($data);
}
/**
* Method to check if you can edit an existing record.
*
* Like in the administrator, the edit permission is checked in the category of the record, because there is no
* asset tracking. Moving the record to another category requires the create permission in the target category.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key; default is id.
*
* @return boolean
*
* @since 5.4.11
*/
protected function allowEdit($data = [], $key = 'id')
{
if (!parent::allowEdit($data, $key)) {
return false;
}
$recordId = isset($data[$key]) ? (int) $data[$key] : 0;
if (!$recordId) {
return true;
}
$table = $this->getModel('banner')->getTable();
if (!$table->load($recordId)) {
return false;
}
$user = $this->app->getIdentity();
$category = $this->option . '.category.' . (int) $table->catid;
if (!$user->authorise('core.edit', $category)) {
return false;
}
return $this->allowCategoryChange(
$table,
$recordId,
$this->input->get('data', json_decode($this->input->json->getRaw(), true), 'array')
);
}
}
No other release has this exact content. See every version of this file.