[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_associations/src/Controller/ -> AssociationsController.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_associations
   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\Associations\Administrator\Controller;
  12  
  13  use Joomla\CMS\Language\Text;
  14  use Joomla\CMS\MVC\Controller\AdminController;
  15  use Joomla\CMS\Router\Route;
  16  use Joomla\Component\Associations\Administrator\Helper\AssociationsHelper;
  17  
  18  // phpcs:disable PSR1.Files.SideEffects
  19  \defined('_JEXEC') or die;
  20  // phpcs:enable PSR1.Files.SideEffects
  21  
  22  /**
  23   * Associations controller class.
  24   *
  25   * @since  3.7.0
  26   */
  27  class AssociationsController extends AdminController
  28  {
  29      /**
  30       * The URL view list variable.
  31       *
  32       * @var    string
  33       *
  34       * @since  3.7.0
  35       */
  36      protected $view_list = 'associations';
  37  
  38      /**
  39       * Proxy for getModel.
  40       *
  41       * @param   string  $name    The model name. Optional.
  42       * @param   string  $prefix  The class prefix. Optional.
  43       * @param   array   $config  The array of possible config values. Optional.
  44       *
  45       * @return  \Joomla\CMS\MVC\Model\BaseDatabaseModel|boolean
  46       *
  47       * @since  3.7.0
  48       */
  49      public function getModel($name = 'Associations', $prefix = 'Administrator', $config = array('ignore_request' => true))
  50      {
  51          return parent::getModel($name, $prefix, $config);
  52      }
  53  
  54      /**
  55       * Method to purge the associations table.
  56       *
  57       * @return  void
  58       *
  59       * @since  3.7.0
  60       */
  61      public function purge()
  62      {
  63          $this->checkToken();
  64  
  65          $this->getModel('associations')->purge();
  66          $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
  67      }
  68  
  69      /**
  70       * Method to delete the orphans from the associations table.
  71       *
  72       * @return  void
  73       *
  74       * @since  3.7.0
  75       */
  76      public function clean()
  77      {
  78          $this->checkToken();
  79  
  80          $this->getModel('associations')->clean();
  81          $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
  82      }
  83  
  84      /**
  85       * Method to check in an item from the association item overview.
  86       *
  87       * @return  void
  88       *
  89       * @since   3.7.1
  90       */
  91      public function checkin()
  92      {
  93          // Set the redirect so we can just stop processing when we find a condition we can't process
  94          $this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false));
  95  
  96          // Figure out if the item supports checking and check it in
  97          list($extensionName, $typeName) = explode('.', $this->input->get('itemtype'));
  98  
  99          $extension = AssociationsHelper::getSupportedExtension($extensionName);
 100          $types     = $extension->get('types');
 101  
 102          if (!\array_key_exists($typeName, $types)) {
 103              return;
 104          }
 105  
 106          if (AssociationsHelper::typeSupportsCheckout($extensionName, $typeName) === false) {
 107              // How on earth we came to that point, eject internet
 108              return;
 109          }
 110  
 111          $cid = (array) $this->input->get('cid', array(), 'int');
 112  
 113          if (empty($cid)) {
 114              // Seems we don't have an id to work with.
 115              return;
 116          }
 117  
 118          // We know the first element is the one we need because we don't allow multi selection of rows
 119          $id = $cid[0];
 120  
 121          if ($id === 0) {
 122              // Seems we don't have an id to work with.
 123              return;
 124          }
 125  
 126          if (AssociationsHelper::canCheckinItem($extensionName, $typeName, $id) === true) {
 127              $item = AssociationsHelper::getItem($extensionName, $typeName, $id);
 128  
 129              $item->checkIn($id);
 130  
 131              return;
 132          }
 133  
 134          $this->setRedirect(
 135              Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list),
 136              Text::_('COM_ASSOCIATIONS_YOU_ARE_NOT_ALLOWED_TO_CHECKIN_THIS_ITEM')
 137          );
 138      }
 139  }


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