[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/plugins/system/httpheaders/postinstall/ -> introduction.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Plugin
   5   * @subpackage  System.HttpHeaders
   6   *
   7   * @copyright   (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
   8   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   9   */
  10  
  11  use Joomla\CMS\Factory;
  12  
  13  // phpcs:disable PSR1.Files.SideEffects
  14  \defined('_JEXEC') or die;
  15  // phpcs:enable PSR1.Files.SideEffects
  16  
  17  /**
  18   * Checks if the plugin is enabled. If not it returns true, meaning that the
  19   * message concerning the HTTPHeaders Plugin should be displayed.
  20   *
  21   * @return  integer
  22   *
  23   * @since   4.0.0
  24   */
  25  function httpheaders_postinstall_condition()
  26  {
  27      return !Joomla\CMS\Plugin\PluginHelper::isEnabled('system', 'httpheaders');
  28  }
  29  
  30  /**
  31   * Enables the HTTPHeaders plugin
  32   *
  33   * @return  void
  34   *
  35   * @since   4.0.0
  36   */
  37  function httpheaders_postinstall_action()
  38  {
  39      // Enable the plugin
  40      $db = Factory::getDbo();
  41  
  42      $query = $db->getQuery(true)
  43          ->update($db->quoteName('#__extensions'))
  44          ->set($db->quoteName('enabled') . ' = 1')
  45          ->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
  46          ->where($db->quoteName('folder') . ' = ' . $db->quote('system'))
  47          ->where($db->quoteName('element') . ' = ' . $db->quote('httpheaders'));
  48      $db->setQuery($query);
  49      $db->execute();
  50  
  51      $query = $db->getQuery(true)
  52          ->select('extension_id')
  53          ->from($db->quoteName('#__extensions'))
  54          ->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
  55          ->where($db->quoteName('folder') . ' = ' . $db->quote('system'))
  56          ->where($db->quoteName('element') . ' = ' . $db->quote('httpheaders'));
  57      $db->setQuery($query);
  58      $extensionId = $db->loadResult();
  59  
  60      $url = 'index.php?option=com_plugins&task=plugin.edit&extension_id=' . $extensionId;
  61      Factory::getApplication()->redirect($url);
  62  }


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