[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/components/com_content/src/Dispatcher/ -> Dispatcher.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Site
   5   * @subpackage  com_content
   6   *
   7   * @copyright   (C) 2017 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\Content\Site\Dispatcher;
  12  
  13  use Joomla\CMS\Dispatcher\ComponentDispatcher;
  14  use Joomla\CMS\Language\Text;
  15  
  16  // phpcs:disable PSR1.Files.SideEffects
  17  \defined('JPATH_PLATFORM') or die;
  18  // phpcs:enable PSR1.Files.SideEffects
  19  
  20  /**
  21   * ComponentDispatcher class for com_content
  22   *
  23   * @since  4.0.0
  24   */
  25  class Dispatcher extends ComponentDispatcher
  26  {
  27      /**
  28       * Dispatch a controller task. Redirecting the user if appropriate.
  29       *
  30       * @return  void
  31       *
  32       * @since   4.0.0
  33       */
  34      public function dispatch()
  35      {
  36          $checkCreateEdit = ($this->input->get('view') === 'articles' && $this->input->get('layout') === 'modal')
  37              || ($this->input->get('view') === 'article' && $this->input->get('layout') === 'pagebreak');
  38  
  39          if ($checkCreateEdit) {
  40              // Can create in any category (component permission) or at least in one category
  41              $canCreateRecords = $this->app->getIdentity()->authorise('core.create', 'com_content')
  42                  || count($this->app->getIdentity()->getAuthorisedCategories('com_content', 'core.create')) > 0;
  43  
  44              // Instead of checking edit on all records, we can use **same** check as the form editing view
  45              $values = (array) $this->app->getUserState('com_content.edit.article.id');
  46              $isEditingRecords = count($values);
  47              $hasAccess = $canCreateRecords || $isEditingRecords;
  48  
  49              if (!$hasAccess) {
  50                  $this->app->enqueueMessage(Text::_('JERROR_ALERTNOAUTHOR'), 'warning');
  51  
  52                  return;
  53              }
  54          }
  55  
  56          parent::dispatch();
  57      }
  58  }


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer