Skip to content

Commit

Permalink
Merge branch '4.2-dev' into tag_menu_deny
Browse files Browse the repository at this point in the history
  • Loading branch information
roland-d committed Jun 20, 2022
2 parents 72b8d08 + 6860ffc commit 1a70d63
Show file tree
Hide file tree
Showing 136 changed files with 1,728 additions and 686 deletions.
Expand Up @@ -1372,7 +1372,7 @@ public function getAssoc()
return $this->hasAssociation;
}

$extension = $this->getState('category.extension');
$extension = $this->getState('category.extension', '');

$this->hasAssociation = Associations::isEnabled();
$extension = explode('.', $extension);
Expand Down
Expand Up @@ -85,7 +85,7 @@
&nbsp;<span class="icon-lock" aria-hidden="true"></span>
</button>
<?php else : ?>
<button type="buttton" class="btn btn-secondary btn-sm" onclick="return Joomla.listItemTask('cb<?php echo $i; ?>','history.keep')">
<button type="button" class="btn btn-secondary btn-sm" onclick="return Joomla.listItemTask('cb<?php echo $i; ?>','history.keep')">
<?php echo Text::_('JNO'); ?>
</button>
<?php endif; ?>
Expand Down
Expand Up @@ -19,6 +19,7 @@
use Joomla\Component\Finder\Administrator\Service\HTML\Filter;
use Joomla\Component\Finder\Administrator\Service\HTML\Finder;
use Joomla\Component\Finder\Administrator\Service\HTML\Query;
use Joomla\Database\DatabaseInterface;
use Psr\Container\ContainerInterface;

/**
Expand Down Expand Up @@ -46,8 +47,16 @@ class FinderComponent extends MVCComponent implements BootableExtensionInterface
*/
public function boot(ContainerInterface $container)
{
$this->getRegistry()->register('finder', new Finder);
$this->getRegistry()->register('filter', new Filter);
$finder = new Finder;
$finder->setDatabase($container->get(DatabaseInterface::class));

$this->getRegistry()->register('finder', $finder);

$filter = new Filter;
$filter->setDatabase($container->get(DatabaseInterface::class));

$this->getRegistry()->register('filter', $filter);

$this->getRegistry()->register('query', new Query);
}
}
5 changes: 1 addition & 4 deletions administrator/components/com_finder/src/Indexer/Adapter.php
Expand Up @@ -135,9 +135,6 @@ abstract class Adapter extends CMSPlugin
*/
public function __construct(&$subject, $config)
{
// Get the database object.
$this->db = Factory::getDbo();

// Call the parent constructor.
parent::__construct($subject, $config);

Expand All @@ -157,7 +154,7 @@ public function __construct(&$subject, $config)
}

// Get the indexer object
$this->indexer = new Indexer;
$this->indexer = new Indexer($this->db);
}

/**
Expand Down
15 changes: 11 additions & 4 deletions administrator/components/com_finder/src/Indexer/Indexer.php
Expand Up @@ -18,6 +18,7 @@
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Profiler\Profiler;
use Joomla\Database\DatabaseInterface;
use Joomla\Database\ParameterType;
use Joomla\Database\QueryInterface;
use Joomla\String\StringHelper;
Expand Down Expand Up @@ -112,13 +113,19 @@ class Indexer
/**
* Indexer constructor.
*
* @param DatabaseInterface $db The database
*
* @since 3.8.0
*/
public function __construct()
public function __construct(DatabaseInterface $db = null)
{
$this->db = Factory::getDbo();
if ($db === null)
{
@trigger_error(sprintf('Database will be mandatory in 5.0.'), E_USER_DEPRECATED);
$db = Factory::getContainer()->get(DatabaseInterface::class);
}

$db = $this->db;
$this->db = $db;

// Set up query template for addTokensToDb
$this->addTokensToDbQueryTemplate = $db->getQuery(true)->insert($db->quoteName('#__finder_tokens'))
Expand Down Expand Up @@ -1020,7 +1027,7 @@ protected function addTokensToDb($tokens, $context = '')
*/
protected function toggleTables($memory)
{
if (strtolower(Factory::getDbo()->getServerType()) != 'mysql')
if (strtolower($this->db->getServerType()) != 'mysql')
{
return true;
}
Expand Down
20 changes: 16 additions & 4 deletions administrator/components/com_finder/src/Indexer/Query.php
Expand Up @@ -17,6 +17,8 @@
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;
use Joomla\Component\Finder\Administrator\Helper\LanguageHelper;
use Joomla\Database\DatabaseAwareTrait;
use Joomla\Database\DatabaseInterface;
use Joomla\Database\ParameterType;
use Joomla\Registry\Registry;
use Joomla\String\StringHelper;
Expand All @@ -31,6 +33,8 @@
*/
class Query
{
use DatabaseAwareTrait;

/**
* Flag to show whether the query can return results.
*
Expand Down Expand Up @@ -191,8 +195,16 @@ class Query
* @since 2.5
* @throws Exception on database error.
*/
public function __construct($options)
public function __construct($options, DatabaseInterface $db = null)
{
if ($db === null)
{
@trigger_error(sprintf('Database will be mandatory in 5.0.'), E_USER_DEPRECATED);
$db = Factory::getContainer()->get(DatabaseInterface::class);
}

$this->setDatabase($db);

// Get the input string.
$this->input = $options['input'] ?? '';

Expand Down Expand Up @@ -516,7 +528,7 @@ public function getRequiredTermIds()
protected function processStaticTaxonomy($filterId)
{
// Get the database object.
$db = Factory::getDbo();
$db = $this->getDatabase();

// Initialize user variables
$groups = implode(',', Factory::getUser()->getAuthorisedViewLevels());
Expand Down Expand Up @@ -630,7 +642,7 @@ protected function processDynamicTaxonomy($filters)
}

// Get the database object.
$db = Factory::getDbo();
$db = $this->getDatabase();

$query = $db->getQuery(true);

Expand Down Expand Up @@ -1339,7 +1351,7 @@ protected function processString($input, $lang, $mode)
protected function getTokenData($token)
{
// Get the database object.
$db = Factory::getDbo();
$db = $this->getDatabase();

// Create a database query to build match the token.
$query = $db->getQuery(true)
Expand Down
Expand Up @@ -18,6 +18,7 @@
use Joomla\CMS\Language\Text;
use Joomla\Component\Finder\Administrator\Helper\LanguageHelper;
use Joomla\Component\Finder\Administrator\Indexer\Query;
use Joomla\Database\DatabaseAwareTrait;
use Joomla\Registry\Registry;

/**
Expand All @@ -27,6 +28,8 @@
*/
class Filter
{
use DatabaseAwareTrait;

/**
* Method to generate filters using the slider widget and decorated
* with the FinderFilter JavaScript behaviors.
Expand All @@ -39,7 +42,7 @@ class Filter
*/
public function slider($options = array())
{
$db = Factory::getDbo();
$db = $this->getDatabase();
$query = $db->getQuery(true);
$user = Factory::getUser();
$groups = implode(',', $user->getAuthorisedViewLevels());
Expand Down Expand Up @@ -239,7 +242,7 @@ public function select($idxQuery, $options)
}
else
{
$db = Factory::getDbo();
$db = $this->getDatabase();
$query = $db->getQuery(true);

// Load the predefined filter if specified.
Expand Down
Expand Up @@ -15,6 +15,7 @@
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\Component\Finder\Administrator\Helper\LanguageHelper;
use Joomla\Database\DatabaseAwareTrait;
use Joomla\Utilities\ArrayHelper;

/**
Expand All @@ -24,6 +25,8 @@
*/
class Finder
{
use DatabaseAwareTrait;

/**
* Creates a list of types to filter on.
*
Expand All @@ -34,7 +37,7 @@ class Finder
public function typeslist()
{
// Load the finder types.
$db = Factory::getDbo();
$db = $this->getDatabase();
$query = $db->getQuery(true)
->select('DISTINCT t.title AS text, t.id AS value')
->from($db->quoteName('#__finder_types') . ' AS t')
Expand Down Expand Up @@ -75,7 +78,7 @@ public function typeslist()
public function mapslist()
{
// Load the finder types.
$db = Factory::getDbo();
$db = $this->getDatabase();
$query = $db->getQuery(true)
->select($db->quoteName('title', 'text'))
->select($db->quoteName('id', 'value'))
Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_menus/presets/alternate.xml
Expand Up @@ -5,10 +5,10 @@
xsi:schemaLocation="urn:joomla.org menu.xsd"
>
<menuitem
type="component"
title="MOD_MENU_CONTROL_PANEL"
link="index.php"
type="component"
element="com_cpanel"
link="index.php?option=com_cpanel&amp;view=cpanel"
class="class:home"
/>
<menuitem
Expand Down
57 changes: 57 additions & 0 deletions administrator/components/com_messages/src/Model/MessagesModel.php
Expand Up @@ -166,4 +166,61 @@ protected function getListQuery()

return $query;
}

/**
* Purge the messages table of old messages for the given user ID.
*
* @param int $userId The user id
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function purge(int $userId): void
{
$db = $this->getDatabase();
$query = $db->getQuery(true)
->select($db->quoteName(['cfg_name', 'cfg_value']))
->from($db->quoteName('#__messages_cfg'))
->where(
[
$db->quoteName('user_id') . ' = :userId',
$db->quoteName('cfg_name') . ' = ' . $db->quote('auto_purge'),
]
)
->bind(':userId', $userId, ParameterType::INTEGER);

$db->setQuery($query);
$config = $db->loadObject();

// Default is 7 days
$purge = 7;

// Check if auto_purge value set
if (\is_object($config) && $config->cfg_name === 'auto_purge')
{
$purge = $config->cfg_value;
}

// If purge value is not 0, then allow purging of old messages
if ($purge > 0)
{
// Purge old messages at day set in message configuration
$past = Factory::getDate(time() - $purge * 86400)->toSql();

$query = $db->getQuery(true)
->delete($db->quoteName('#__messages'))
->where(
[
$db->quoteName('date_time') . ' < :past',
$db->quoteName('user_id_to') . ' = :userId',
]
)
->bind(':past', $past)
->bind(':userId', $userId, ParameterType::INTEGER);

$db->setQuery($query);
$db->execute();
}
}
}
4 changes: 2 additions & 2 deletions administrator/components/com_modules/forms/module.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<config>
<inlinehelp button="show"/>
<config>
<inlinehelp button="show"/>
</config>
<fieldset addfieldprefix="Joomla\Component\Modules\Administrator\Field">
<field
Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_modules/forms/moduleadmin.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<config>
<inlinehelp button="show"/>
<config>
<inlinehelp button="show"/>
</config>
<fieldset addfieldprefix="Joomla\Component\Modules\Administrator\Field">
<field
Expand Down
4 changes: 2 additions & 2 deletions administrator/components/com_plugins/forms/plugin.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<form addfieldprefix="Joomla\Component\Plugins\Administrator\Field">
<config>
<inlinehelp button="show"/>
<config>
<inlinehelp button="show"/>
</config>
<fieldset>
<field
Expand Down
Expand Up @@ -215,7 +215,7 @@ protected function getRoutineId(Form $form, $data): string
// If we're unable to find a routineId, it might be in the form input.
if (empty($routineId))
{
$app = $this->app ?? Factory::getApplication();
$app = $this->getApplication() ?? ($this->app ?? Factory::getApplication());
$form = $app->getInput()->get('jform', []);
$routineId = ArrayHelper::getValue($form, 'type', '', 'STRING');
}
Expand Down Expand Up @@ -248,7 +248,7 @@ protected function logTask(string $message, string $priority = 'info'): void

if (!$langLoaded)
{
$app = $this->app ?? Factory::getApplication();
$app = $this->getApplication() ?? ($this->app ?? Factory::getApplication());
$app->getLanguage()->load('com_scheduler', JPATH_ADMINISTRATOR);
$langLoaded = true;
}
Expand Down

0 comments on commit 1a70d63

Please sign in to comment.