Skip to content

Commit b2978cd

Browse files
authored
Merge pull request joomla#44695 from softforge/upmerges/2025-01-08
[6.0] Upmerges - 2025-01-08
2 parents 250d8db + cae8a0d commit b2978cd

File tree

34 files changed

+266
-351
lines changed

34 files changed

+266
-351
lines changed

administrator/components/com_actionlogs/src/Model/ActionlogModel.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ protected function sendNotificationEmails($messages, $username, $context)
126126
$query = $db->getQuery(true);
127127

128128
$query
129-
->select($db->quoteName(['u.email', 'l.extensions']))
129+
->select($db->quoteName(['u.email', 'u.username', 'l.extensions', 'l.exclude_self']))
130130
->from($db->quoteName('#__users', 'u'))
131131
->where($db->quoteName('u.block') . ' = 0')
132132
->join(
@@ -142,6 +142,10 @@ protected function sendNotificationEmails($messages, $username, $context)
142142
$recipients = [];
143143

144144
foreach ($users as $user) {
145+
if ($user->username === $this->getCurrentUser()->username && $user->exclude_self) {
146+
continue;
147+
}
148+
145149
$extensions = json_decode($user->extensions, true);
146150

147151
if ($extensions && \in_array(strtok($context, '.'), $extensions)) {

administrator/components/com_config/src/Model/ApplicationModel.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,19 @@ public function save($data)
299299
'prefix' => $data['dbprefix'],
300300
];
301301

302+
// Validate database name
303+
if (\in_array($options['driver'], ['pgsql', 'postgresql']) && !preg_match('#^[a-zA-Z_][0-9a-zA-Z_$]*$#', $options['database'])) {
304+
$app->enqueueMessage(Text::_('COM_CONFIG_FIELD_DATABASE_NAME_INVALID_MSG_POSTGRES'), 'warning');
305+
306+
return false;
307+
}
308+
309+
if (\in_array($options['driver'], ['mysql', 'mysqli']) && preg_match('#[\\\\\/]#', $options['database'])) {
310+
$app->enqueueMessage(Text::_('COM_CONFIG_FIELD_DATABASE_NAME_INVALID_MSG_MYSQL'), 'warning');
311+
312+
return false;
313+
}
314+
302315
if ((int) $data['dbencryption'] !== 0) {
303316
$options['ssl'] = [
304317
'enable' => true,

administrator/components/com_contact/tmpl/contacts/default_batch_body.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,6 @@
4848
<?php echo LayoutHelper::render('joomla.html.batch.tag', []); ?>
4949
</div>
5050
</div>
51-
<div class="form-group col-md-6">
52-
<div class="controls">
53-
<?php echo LayoutHelper::render('joomla.html.batch.user', ['noUser' => $noUser]); ?>
54-
</div>
55-
</div>
5651
</div>
5752
</div>
5853
<div class="btn-toolbar p-3">

administrator/components/com_finder/src/View/Index/HtmlView.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ class HtmlView extends BaseHtmlView
112112
*/
113113
private $isEmptyState = false;
114114

115+
/**
116+
* The finder plugins status
117+
*
118+
* @var boolean
119+
*
120+
* @since __DEPLOY_VERSION__
121+
*/
122+
protected $finderPlugins = true;
123+
115124
/**
116125
* Method to display the view.
117126
*
@@ -157,6 +166,11 @@ public function display($tpl = null)
157166
$this->finderPluginId = FinderHelper::getFinderPluginId();
158167
}
159168

169+
// Check that the finder plugins are enabled
170+
if (!PluginHelper::getPlugin('finder')) {
171+
$this->finderPlugins = false;
172+
}
173+
160174
// Configure the toolbar.
161175
$this->addToolbar();
162176

administrator/components/com_finder/tmpl/index/default.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@
5252
Factory::getApplication()->enqueueMessage(Text::sprintf('COM_FINDER_INDEX_PLUGIN_CONTENT_NOT_ENABLED_LINK', $link), 'warning');
5353
}
5454

55+
// Show warning that the finder plugins are disabled
56+
if (!$this->finderPlugins) {
57+
$url = 'index.php?option=com_plugins&filter[folder]=finder';
58+
$link = HTMLHelper::_('link', Route::_($url), Text::_('COM_FINDER_FINDER_PLUGINS'), 'class="alert-link"');
59+
Factory::getApplication()->enqueueMessage(Text::sprintf('COM_FINDER_INDEX_PLUGIN_FINDER_NOT_ENABLED_LINK', $link), 'warning');
60+
}
61+
5562
?>
5663
<form action="<?php echo Route::_('index.php?option=com_finder&view=index'); ?>" method="post" name="adminForm" id="adminForm">
5764
<div class="row">

administrator/components/com_finder/tmpl/index/emptystate.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,10 @@
5555
);
5656
Factory::getApplication()->enqueueMessage(Text::sprintf('COM_FINDER_INDEX_PLUGIN_CONTENT_NOT_ENABLED_LINK', $link), 'warning');
5757
}
58+
59+
// Show warning that the finder plugins are disabled
60+
if (!$this->finderPlugins) {
61+
$url = 'index.php?option=com_plugins&filter[folder]=finder';
62+
$link = HTMLHelper::_('link', Route::_($url), Text::_('COM_FINDER_FINDER_PLUGINS'), 'class="alert-link"');
63+
Factory::getApplication()->enqueueMessage(Text::sprintf('COM_FINDER_INDEX_PLUGIN_FINDER_NOT_ENABLED_LINK', $link), 'warning');
64+
}

administrator/components/com_scheduler/forms/filter_logs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@
6161
class="js-select-submit-on-change"
6262
/>
6363
</fields>
64-
</form>
64+
</form>

administrator/components/com_scheduler/src/Controller/LogsController.php

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@
1010

1111
namespace Joomla\Component\Scheduler\Administrator\Controller;
1212

13-
use Joomla\CMS\Access\Exception\NotAllowed;
1413
use Joomla\CMS\Language\Text;
1514
use Joomla\CMS\MVC\Controller\AdminController;
16-
use Joomla\Utilities\ArrayHelper;
1715

1816
// phpcs:disable PSR1.Files.SideEffects
1917
\defined('_JEXEC') or die;
@@ -46,7 +44,7 @@ class LogsController extends AdminController
4644
*
4745
* @since 5.3.0
4846
*/
49-
public function getModel($name = 'Logs', $prefix = 'Administrator', $config = ['ignore_request' => true])
47+
public function getModel($name = 'Log', $prefix = 'Administrator', $config = ['ignore_request' => true])
5048
{
5149
return parent::getModel($name, $prefix, $config);
5250
}
@@ -73,39 +71,4 @@ public function purge()
7371

7472
$this->setRedirect('index.php?option=com_scheduler&view=logs', $message);
7573
}
76-
77-
/**
78-
* Removes an item.
79-
*
80-
* Overrides Joomla\CMS\MVC\Controller\FormController::delete to check the core.admin permission.
81-
*
82-
* @return void
83-
*
84-
* @since 5.3.0
85-
*/
86-
public function delete(): void
87-
{
88-
$ids = $this->input->get('cid', [], 'array');
89-
90-
if (!$this->app->getIdentity()->authorise('core.admin', $this->option)) {
91-
throw new NotAllowed(Text::_('JERROR_ALERTNOAUTHOR'), 403);
92-
}
93-
94-
if (empty($ids)) {
95-
$this->setMessage(Text::_('COM_SCHEDULER_NO_LOGS_SELECTED'), 'warning');
96-
$this->setRedirect('index.php?option=com_scheduler&view=logs');
97-
return;
98-
}
99-
100-
// Get the model.
101-
$model = $this->getModel();
102-
$ids = ArrayHelper::toInteger($ids);
103-
104-
// Remove the items.
105-
if ($model->delete($ids)) {
106-
$this->setMessage(Text::plural('COM_SCHEDULER_N_ITEMS_DELETED', \count($ids)));
107-
}
108-
109-
$this->setRedirect('index.php?option=com_scheduler&view=logs');
110-
}
11174
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
/**
4+
* @package Joomla.Administrator
5+
* @subpackage com_scheduler
6+
*
7+
* @copyright (C) 2024 Open Source Matters, Inc. <https://www.joomla.org>
8+
* @license GNU General Public License version 2 or later; see LICENSE.txt
9+
*/
10+
11+
namespace Joomla\Component\Scheduler\Administrator\Model;
12+
13+
use Joomla\CMS\Form\Form;
14+
use Joomla\CMS\MVC\Model\AdminModel;
15+
use Joomla\CMS\Table\Table;
16+
17+
// phpcs:disable PSR1.Files.SideEffects
18+
\defined('_JEXEC') or die;
19+
// phpcs:enable PSR1.Files.SideEffects
20+
21+
/**
22+
* MVC Model to interact with the Scheduler logs.
23+
*
24+
* @since __DPELOY_VERSION__
25+
*/
26+
class LogModel extends AdminModel
27+
{
28+
/**
29+
* There is no form for the log.
30+
*
31+
* @param array $data Data that needs to go into the form
32+
* @param bool $loadData Should the form load its data from the DB?
33+
*
34+
* @return Form|boolean A Form object on success, false on failure.
35+
*
36+
* @since __DEPLOY_VERSION__
37+
* @throws \Exception
38+
*/
39+
public function getForm($data = [], $loadData = true)
40+
{
41+
return false;
42+
}
43+
44+
/**
45+
* Method to get a table object, load it if necessary.
46+
*
47+
* @param string $name The table name. Optional.
48+
* @param string $prefix The class prefix. Optional.
49+
* @param array $options Configuration array for model. Optional.
50+
*
51+
* @return Table
52+
*
53+
* @since __DEPLOY_VERSION__
54+
* @throws \Exception
55+
*/
56+
public function getTable($name = 'Log', $prefix = 'Administrator', $options = []): Table
57+
{
58+
return parent::getTable($name, $prefix, $options);
59+
}
60+
}

administrator/components/com_scheduler/src/Model/LogsModel.php

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
// phpcs:enable PSR1.Files.SideEffects
1616

1717
use Joomla\CMS\Component\ComponentHelper;
18-
use Joomla\CMS\Factory;
1918
use Joomla\CMS\MVC\Factory\MVCFactoryInterface;
2019
use Joomla\CMS\MVC\Model\ListModel;
2120
use Joomla\Component\Scheduler\Administrator\Helper\SchedulerHelper;
@@ -185,91 +184,4 @@ protected function getListQuery()
185184

186185
return $query;
187186
}
188-
189-
/**
190-
* Delete rows.
191-
*
192-
* @param array $pks The ids of the items to delete.
193-
*
194-
* @return boolean Returns true on success, false on failure.
195-
*/
196-
public function delete($pks)
197-
{
198-
if ($this->canDelete($pks)) {
199-
// Delete logs from list
200-
$db = $this->getDatabase();
201-
$query = $db->getQuery(true)
202-
->delete($db->quoteName('#__scheduler_logs'))
203-
->whereIn($db->quoteName('id'), $pks);
204-
205-
$db->setQuery($query);
206-
$this->setError((string) $query);
207-
208-
try {
209-
$db->execute();
210-
} catch (\RuntimeException $e) {
211-
$this->setError($e->getMessage());
212-
213-
return false;
214-
}
215-
} else {
216-
Factory::getApplication()->enqueueMessage(Text::_('JERROR_CORE_DELETE_NOT_PERMITTED'), 'error');
217-
}
218-
219-
return true;
220-
}
221-
222-
/**
223-
* Determine whether a record may be deleted taking into consideration
224-
* the user's permissions over the record.
225-
*
226-
* @param object $record The database row/record in question
227-
*
228-
* @return boolean True if the record may be deleted
229-
*
230-
* @since 5.3.0
231-
* @throws \Exception
232-
*/
233-
protected function canDelete($record): bool
234-
{
235-
// Record doesn't exist, can't delete
236-
if (empty($record)) {
237-
return false;
238-
}
239-
240-
return Factory::getApplication()->getIdentity()->authorise('core.delete', 'com_scheduler');
241-
}
242-
243-
/**
244-
* @param array $data The task execution data.
245-
*
246-
* @return void
247-
*
248-
* @since 5.3.0
249-
* @throws Exception
250-
*/
251-
public function logTask(array $data): void
252-
{
253-
$model = Factory::getApplication()->bootComponent('com_scheduler')
254-
->getMVCFactory()->createModel('Task', 'Administrator', ['ignore_request' => true]);
255-
$taskInfo = $model->getItem($data['TASK_ID']);
256-
$taskOptions = SchedulerHelper::getTaskOptions();
257-
$safeTypeTitle = $taskOptions->findOption($taskInfo->type)->title ?? '';
258-
$duration = ($data['TASK_DURATION'] ?? 0);
259-
$created = Factory::getDate()->toSql();
260-
261-
/** @var \Joomla\Component\Schduler\Administrator\Table\LogsTable $table */
262-
$logsTable = $this->getTable();
263-
$logsTable->tasktype = $safeTypeTitle;
264-
$logsTable->taskname = $data['TASK_TITLE'];
265-
$logsTable->duration = $duration;
266-
$logsTable->jobid = $data['TASK_ID'];
267-
$logsTable->exitcode = $data['EXIT_CODE'];
268-
$logsTable->taskid = $data['TASK_TIMES'];
269-
$logsTable->lastdate = $created;
270-
$logsTable->nextdate = $taskInfo->next_execution;
271-
272-
// Log the execution of the task.
273-
$logsTable->store();
274-
}
275187
}

0 commit comments

Comments
 (0)