CoreFiles by mySites.guru
AutomatedUpdatesModel.php73 lines, 2,128 bytes, from Joomla_6.2.1-rc1-Release_Candidate-Full_Package.zip
Raw History Compare with 6.2.0-rc2
md5
acae9c2975833fad6e3e6adadd111b39
sha1
9147479e5ff3a492f1823e1b69a1641043615c7a
sha256
4ad43473a6701e1c05c75ef49cebc808a83901891a7d928450631cc0e2451c8c
<?php

/**
 * @package     Joomla.Installation
 * @subpackage  Model
 *
 * @copyright   (C) 2025 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

namespace Joomla\CMS\Installation\Model;

use Joomla\CMS\Factory;
use Joomla\Database\DatabaseAwareInterface;
use Joomla\Database\DatabaseAwareTrait;
use Joomla\Registry\Registry;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

/**
 * Automated Updates model for the Joomla Core Installer.
 *
 * @since  5.4.0
 */
class AutomatedUpdatesModel extends BaseInstallationModel implements DatabaseAwareInterface
{
    use DatabaseAwareTrait;

    /**
     * @since  5.4.0
     */
    public function __construct()
    {
        // Overrides application config and set the configuration.php file so tokens and database works.
        if (file_exists(JPATH_BASE . '/configuration.php')) {
            /** @phpstan-ignore class.notFound */
            Factory::getApplication()->setConfiguration(new Registry(new \JConfig()));
        }

        parent::__construct();
    }

    /**
     * Opt out from automated Updates
     *
     * @since  5.4.0
     */
    public function disable()
    {
        // Get the params of com_joomlaupdate
        $db        = $this->getDatabase();
        $query     = $db->createQuery();

        $query->select('params')
            ->from($db->quoteName('#__extensions'))
            ->where($db->quoteName('element') . ' = ' . $db->quote('com_joomlaupdate'));

        $params = new Registry($db->setQuery($query)->loadResult());
        $params->set('autoupdate', 0);
        $params->set('autoupdate_status', 0);

        // Update the language settings in the language manager.
        $query->clear()
            ->update($db->quoteName('#__extensions'))
            ->set($db->quoteName('params') . ' = ' . $db->quote($params->toString()))
            ->where($db->quoteName('element') . ' = ' . $db->quote('com_joomlaupdate'));
        $db->setQuery($query)->execute();

        return true;
    }
}

The same content is in 44 releases, Joomla 6.0.0-rc1 to 6.2.1-rc1. See them all, or every version of this file.