[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package Joomla.Administrator 5 * @subpackage com_banners 6 * 7 * @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org> 8 * @license GNU General Public License version 2 or later; see LICENSE.txt 9 */ 10 11 namespace Joomla\Component\Banners\Administrator\Controller; 12 13 use Joomla\CMS\MVC\Controller\FormController; 14 use Joomla\CMS\Router\Route; 15 use Joomla\CMS\Versioning\VersionableControllerTrait; 16 use Joomla\Utilities\ArrayHelper; 17 18 // phpcs:disable PSR1.Files.SideEffects 19 \defined('_JEXEC') or die; 20 // phpcs:enable PSR1.Files.SideEffects 21 22 /** 23 * Banner controller class. 24 * 25 * @since 1.6 26 */ 27 class BannerController extends FormController 28 { 29 use VersionableControllerTrait; 30 31 /** 32 * The prefix to use with controller messages. 33 * 34 * @var string 35 * @since 1.6 36 */ 37 protected $text_prefix = 'COM_BANNERS_BANNER'; 38 39 /** 40 * Method override to check if you can add a new record. 41 * 42 * @param array $data An array of input data. 43 * 44 * @return boolean 45 * 46 * @since 1.6 47 */ 48 protected function allowAdd($data = array()) 49 { 50 $filter = $this->input->getInt('filter_category_id'); 51 $categoryId = ArrayHelper::getValue($data, 'catid', $filter, 'int'); 52 53 if ($categoryId) { 54 // If the category has been passed in the URL check it. 55 return $this->app->getIdentity()->authorise('core.create', $this->option . '.category.' . $categoryId); 56 } 57 58 // In the absence of better information, revert to the component permissions. 59 return parent::allowAdd($data); 60 } 61 62 /** 63 * Method override to check if you can edit an existing record. 64 * 65 * @param array $data An array of input data. 66 * @param string $key The name of the key for the primary key. 67 * 68 * @return boolean 69 * 70 * @since 1.6 71 */ 72 protected function allowEdit($data = array(), $key = 'id') 73 { 74 $recordId = (int) isset($data[$key]) ? $data[$key] : 0; 75 $categoryId = 0; 76 77 if ($recordId) { 78 $categoryId = (int) $this->getModel()->getItem($recordId)->catid; 79 } 80 81 if ($categoryId) { 82 // The category has been set. Check the category permissions. 83 return $this->app->getIdentity()->authorise('core.edit', $this->option . '.category.' . $categoryId); 84 } 85 86 // Since there is no asset tracking, revert to the component permissions. 87 return parent::allowEdit($data, $key); 88 } 89 90 /** 91 * Method to run batch operations. 92 * 93 * @param string $model The model 94 * 95 * @return boolean True on success. 96 * 97 * @since 2.5 98 */ 99 public function batch($model = null) 100 { 101 $this->checkToken(); 102 103 // Set the model 104 $model = $this->getModel('Banner', '', array()); 105 106 // Preset the redirect 107 $this->setRedirect(Route::_('index.php?option=com_banners&view=banners' . $this->getRedirectToListAppend(), false)); 108 109 return parent::batch($model); 110 } 111 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |