[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/plugins/system/updatenotification/postinstall/ -> updatecachetime.php (source)

   1  <?php
   2  
   3  /**
   4   * @package     Joomla.Plugin
   5   * @subpackage  System.updatenotification
   6   *
   7   * @copyright   (C) 2016 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\Component\ComponentHelper;
  12  use Joomla\CMS\Factory;
  13  use Joomla\CMS\Plugin\PluginHelper;
  14  use Joomla\CMS\Table\Table;
  15  
  16  // phpcs:disable PSR1.Files.SideEffects
  17  \defined('_JEXEC') or die;
  18  // phpcs:enable PSR1.Files.SideEffects
  19  
  20  /**
  21   * Checks if the com_installer config for the cache Hours are eq 0 and the updatenotification Plugin is enabled
  22   *
  23   * @return  boolean
  24   *
  25   * @since   3.6.3
  26   */
  27  function updatecachetime_postinstall_condition()
  28  {
  29      $cacheTimeout = (int) ComponentHelper::getComponent('com_installer')->params->get('cachetimeout', 6);
  30  
  31      // Check if cachetimeout is eq zero
  32      if ($cacheTimeout === 0 && PluginHelper::isEnabled('system', 'updatenotification')) {
  33          return true;
  34      }
  35  
  36      return false;
  37  }
  38  
  39  /**
  40   * Sets the cachetimeout back to the default (6 hours)
  41   *
  42   * @return  void
  43   *
  44   * @since   3.6.3
  45   */
  46  function updatecachetime_postinstall_action()
  47  {
  48      $installer = ComponentHelper::getComponent('com_installer');
  49  
  50      // Sets the cachetimeout back to the default (6 hours)
  51      $installer->params->set('cachetimeout', 6);
  52  
  53      // Save the new parameters back to com_installer
  54      $table = Table::getInstance('extension');
  55      $table->load($installer->id);
  56      $table->bind(array('params' => $installer->params->toString()));
  57  
  58      // Store the changes
  59      if (!$table->store()) {
  60          // If there is an error show it to the admin
  61          Factory::getApplication()->enqueueMessage($table->getError(), 'error');
  62      }
  63  }


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