[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/administrator/components/com_postinstall/src/Controller/ -> MessageController.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Administrator
   5   * @subpackage  com_postinstall
   6   *
   7   * @copyright   (C) 2013 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\Postinstall\Administrator\Controller;
  12  
  13  use Joomla\CMS\Filesystem\File;
  14  use Joomla\CMS\MVC\Controller\BaseController;
  15  use Joomla\Component\Postinstall\Administrator\Helper\PostinstallHelper;
  16  use Joomla\Component\Postinstall\Administrator\Model\MessagesModel;
  17  
  18  // phpcs:disable PSR1.Files.SideEffects
  19  \defined('_JEXEC') or die;
  20  // phpcs:enable PSR1.Files.SideEffects
  21  
  22  /**
  23   * Postinstall message controller.
  24   *
  25   * @since  3.2
  26   */
  27  class MessageController extends BaseController
  28  {
  29      /**
  30       * Resets all post-installation messages of the specified extension.
  31       *
  32       * @return  void
  33       *
  34       * @since   3.2
  35       */
  36      public function reset()
  37      {
  38          $this->checkToken('get');
  39  
  40          /** @var MessagesModel $model */
  41          $model = $this->getModel('Messages', '', ['ignore_request' => true]);
  42          $eid = $this->input->getInt('eid');
  43  
  44          if (empty($eid)) {
  45              $eid = $model->getJoomlaFilesExtensionId();
  46          }
  47  
  48          $model->resetMessages($eid);
  49  
  50          $this->setRedirect('index.php?option=com_postinstall&eid=' . $eid);
  51      }
  52  
  53      /**
  54       * Unpublishes post-installation message of the specified extension.
  55       *
  56       * @return   void
  57       *
  58       * @since   3.2
  59       */
  60      public function unpublish()
  61      {
  62          $model = $this->getModel('Messages', '', ['ignore_request' => true]);
  63  
  64          $id = $this->input->get('id');
  65  
  66          $eid = (int) $model->getState('eid', $model->getJoomlaFilesExtensionId());
  67  
  68          if (empty($eid)) {
  69              $eid = $model->getJoomlaFilesExtensionId();
  70          }
  71  
  72          $model->setState('published', 0);
  73          $model->unpublishMessage($id);
  74  
  75          $this->setRedirect('index.php?option=com_postinstall&eid=' . $eid);
  76      }
  77  
  78      /**
  79       * Re-Publishes an archived post-installation message of the specified extension.
  80       *
  81       * @return   void
  82       *
  83       * @since   4.2.0
  84       */
  85      public function republish()
  86      {
  87          $model = $this->getModel('Messages', '', ['ignore_request' => true]);
  88  
  89          $id = $this->input->get('id');
  90  
  91          $eid = (int) $model->getState('eid', $model->getJoomlaFilesExtensionId());
  92  
  93          if (empty($eid)) {
  94              $eid = $model->getJoomlaFilesExtensionId();
  95          }
  96  
  97          $model->setState('published', 1);
  98          $model->republishMessage($id);
  99  
 100          $this->setRedirect('index.php?option=com_postinstall&eid=' . $eid);
 101      }
 102  
 103      /**
 104       * Archives a published post-installation message of the specified extension.
 105       *
 106       * @return   void
 107       *
 108       * @since   4.2.0
 109       */
 110      public function archive()
 111      {
 112          $model = $this->getModel('Messages', '', ['ignore_request' => true]);
 113  
 114          $id = $this->input->get('id');
 115  
 116          $eid = (int) $model->getState('eid', $model->getJoomlaFilesExtensionId());
 117  
 118          if (empty($eid)) {
 119              $eid = $model->getJoomlaFilesExtensionId();
 120          }
 121  
 122          $model->setState('published', 2);
 123          $model->archiveMessage($id);
 124  
 125          $this->setRedirect('index.php?option=com_postinstall&eid=' . $eid);
 126      }
 127  
 128      /**
 129       * Executes the action associated with an item.
 130       *
 131       * @return  void
 132       *
 133       * @since   3.2
 134       */
 135      public function action()
 136      {
 137          $this->checkToken('get');
 138  
 139          $model = $this->getModel('Messages', '', ['ignore_request' => true]);
 140  
 141          $id = $this->input->get('id');
 142  
 143          $item = $model->getItem($id);
 144  
 145          switch ($item->type) {
 146              case 'link':
 147                  $this->setRedirect($item->action);
 148  
 149                  return;
 150  
 151              case 'action':
 152                  $helper = new PostinstallHelper();
 153                  $file = $helper->parsePath($item->action_file);
 154  
 155                  if (File::exists($file)) {
 156                      require_once $file;
 157  
 158                      call_user_func($item->action);
 159                  }
 160                  break;
 161          }
 162  
 163          $this->setRedirect('index.php?option=com_postinstall');
 164      }
 165  
 166      /**
 167       * Hides all post-installation messages of the specified extension.
 168       *
 169       * @return  void
 170       *
 171       * @since   3.8.7
 172       */
 173      public function hideAll()
 174      {
 175          $this->checkToken();
 176  
 177          /** @var MessagesModel $model */
 178          $model = $this->getModel('Messages', '', ['ignore_request' => true]);
 179          $eid = $this->input->getInt('eid');
 180  
 181          if (empty($eid)) {
 182              $eid = $model->getJoomlaFilesExtensionId();
 183          }
 184  
 185          $model->hideMessages($eid);
 186          $this->setRedirect('index.php?option=com_postinstall&eid=' . $eid);
 187      }
 188  }


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