- md5
- 24c90f572b1346f81b1ad6f02389b76a
- sha1
- ac754e635bf5275fc8a59df582e3619c5853705a
- sha256
- 72717f76590b0656db455df5e6ef8aece26561a892774b9f3e84330a48e23779
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
<?php
/**
* @package Joomla.Administrator
* @subpackage com_installer
*
* @copyright (C) 2011 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Installer\Administrator\Controller;
\defined('_JEXEC') or die;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Response\JsonResponse;
use Joomla\CMS\Router\Route;
use Joomla\Component\Installer\Administrator\Model\DatabaseModel;
/**
* Installer Database Controller
*
* @since 2.5
*/
class DatabaseController extends BaseController
{
/**
* Tries to fix missing database updates
*
* @return void
*
* @throws \Exception
*
* @since 2.5
* @todo Purge updates has to be replaced with an events system
*/
public function fix()
{
// Check for request forgeries.
$this->checkToken();
// Get items to fix the database.
$cid = $this->input->get('cid', array(), 'array');
if (!is_array($cid) || count($cid) < 1)
{
$this->app->getLogger()->warning(
Text::_(
'COM_INSTALLER_ERROR_NO_EXTENSIONS_SELECTED'
), array('category' => 'jerror')
);
}
else
{
/** @var DatabaseModel $model */
$model = $this->getModel('Database');
$model->fix($cid);
/** @var \Joomla\Component\Joomlaupdate\Administrator\Model\UpdateModel $updateModel */
$updateModel = $this->app->bootComponent('com_joomlaupdate')
->getMVCFactory()->createModel('Update', 'Administrator', ['ignore_request' => true]);
$updateModel->purge();
// Refresh versionable assets cache
$this->app->flushAssets();
}
$this->setRedirect(Route::_('index.php?option=com_installer&view=database', false));
}
/**
* Provide the data for a badge in a menu item via JSON
*
* @return void
*
* @since 4.0.0
* @throws \Exception
*/
public function getMenuBadgeData()
{
if (!$this->app->getIdentity()->authorise('core.manage', 'com_installer'))
{
throw new \Exception(Text::_('JGLOBAL_AUTH_ACCESS_DENIED'));
}
$model = $this->getModel('Database');
$changeSet = $model->getItems();
$changeSetCount = 0;
foreach ($changeSet as $item)
{
$changeSetCount += $item['errorsCount'];
}
echo new JsonResponse($changeSetCount);
}
}
The same content is in 37 releases, Joomla 4.0.0-beta6 to 4.1.1-rc2. See them all, or every version of this file.