Skip to content

Commit

Permalink
Merge branch '5.1-dev' into lazy
Browse files Browse the repository at this point in the history
  • Loading branch information
Quy committed Jan 12, 2024
2 parents 9e627d1 + 31659bb commit 1339f49
Show file tree
Hide file tree
Showing 143 changed files with 2,375 additions and 1,256 deletions.
31 changes: 26 additions & 5 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ clone:

steps:
- name: setup
image: joomlaprojects/docker-images:php8.2
image: joomlaprojects/docker-images:php8.3
volumes:
- name: certificates
path: /certificates
commands:
- cp -v tests/certs/* /certificates/

- name: composer
image: joomlaprojects/docker-images:php8.2
image: joomlaprojects/docker-images:php8.3
volumes:
- name: composer-cache
path: /tmp/composer-cache
Expand Down Expand Up @@ -63,6 +63,13 @@ steps:
- php -v
- ./libraries/vendor/bin/phpunit --testsuite Unit

- name: php83-unit
depends_on: [ phpcs ]
image: joomlaprojects/docker-images:php8.3
commands:
- php -v
- ./libraries/vendor/bin/phpunit --testsuite Unit

- name: php81-integration
depends_on: [ npm ]
image: joomlaprojects/docker-images:php8.1
Expand All @@ -77,6 +84,13 @@ steps:
- php -v
- ./libraries/vendor/bin/phpunit --testsuite Integration

- name: php83-integration
depends_on: [ npm ]
image: joomlaprojects/docker-images:php8.3
commands:
- php -v
- ./libraries/vendor/bin/phpunit --testsuite Integration

- name: php81-integration-pgsql
depends_on: [ npm ]
image: joomlaprojects/docker-images:php8.1
Expand All @@ -91,6 +105,13 @@ steps:
- php -v
- ./libraries/vendor/bin/phpunit --testsuite Integration --configuration phpunit-pgsql.xml.dist

- name: php83-integration-pgsql
depends_on: [ npm ]
image: joomlaprojects/docker-images:php8.3
commands:
- php -v
- ./libraries/vendor/bin/phpunit --testsuite Integration --configuration phpunit-pgsql.xml.dist

- name: scss-cs
depends_on: [ npm ]
image: node:current-alpine
Expand Down Expand Up @@ -145,7 +166,7 @@ steps:
- name: phpnext-system-mysql
depends_on:
- phpmax-system-mysql
image: joomlaprojects/docker-images:cypress8.2
image: joomlaprojects/docker-images:cypress8.3
volumes:
- name: cypress-cache
path: /root/.cache/Cypress
Expand Down Expand Up @@ -184,7 +205,7 @@ steps:
- name: phpnext-system-postgres
depends_on:
- phpmax-system-postgres
image: joomlaprojects/docker-images:cypress8.2
image: joomlaprojects/docker-images:cypress8.3
volumes:
- name: cypress-cache
path: /root/.cache/Cypress
Expand Down Expand Up @@ -382,6 +403,6 @@ trigger:

---
kind: signature
hmac: 5814cadc441b90eec51da0aa32cd29ff1014c4d759841cc70063b5e9245d2b08
hmac: e8ab45eb1d91c0b0b38c8d25a3a983d112c973dcba0153a982f2afd581dfa458

...
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php

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

namespace Joomla\Component\Actionlogs\Administrator\Field;

use Joomla\CMS\Application\ApplicationHelper;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\Component\Actionlogs\Administrator\Helper\ActionlogsHelper;
use Joomla\Database\ParameterType;

/**
* Field to load a list of all users that have logged actions
*
* @since 5.1.0
*/
class UserlogtypeField extends ListField
{
/**
* The form field type.
*
* @var string
* @since 5.1.0
*/
protected $type = 'UserLogType';

/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 5.1.0
*/
public function getOptions()
{
$db = $this->getDatabase();
$user = Factory::getApplication()->getIdentity();
$query = $db->getQuery(true)
->select($db->quoteName('extensions'))
->from($db->quoteName('#__action_logs_users'))
->where($db->quoteName('user_id') . ' = :userid')
->bind(':userid', $user->id, ParameterType::INTEGER);

$extensions = $db->setQuery($query)->loadColumn();
$userExt = [];
$params = ComponentHelper::getParams('com_actionlogs');
$globalExt = $params->get('loggable_extensions', []);

if (!empty($extensions)) {
$userExt = substr($extensions[0], 2);
$userExt = substr($userExt, 0, -2);
$userExt = explode('","', $userExt);
}

$common = array_merge($globalExt, array_intersect($globalExt, $userExt));
$options = [];

foreach ($common as $extension) {
ActionlogsHelper::loadTranslationFiles($extension);
$extensionName = Text::_($extension);
$options[ApplicationHelper::stringURLSafe($extensionName) . '_' . $extension] = HTMLHelper::_('select.option', $extension, $extensionName);
}

ksort($options);

return array_merge(parent::getOptions(), array_values($options));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ public static function getHumanReadableLogMessage($log, $generateLinks = true)
$messageData['type'] = Text::_($messageData['type']);
}

// Remove links from the message template, if we should not generate links.
if (!$generateLinks) {
$message = preg_replace('/<a href=["\'].+?["\']>/', '', $message);
$message = str_replace('</a>', '', $message);
}

$linkMode = Factory::getApplication()->get('force_ssl', 0) >= 1 ? Route::TLS_FORCE : Route::TLS_IGNORE;

foreach ($messageData as $key => $value) {
Expand Down Expand Up @@ -324,6 +330,12 @@ public static function loadActionLogPluginsLanguage()
// Load plg_system_actionlogs too
$lang->load('plg_system_actionlogs', JPATH_ADMINISTRATOR);

// Load plg_system_privacyconsent too
$lang->load('plg_system_privacyconsent', JPATH_ADMINISTRATOR);

// Load plg_user_terms too
$lang->load('plg_user_terms', JPATH_ADMINISTRATOR);

// Load com_privacy too.
$lang->load('com_privacy', JPATH_ADMINISTRATOR);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ protected function sendNotificationEmails($messages, $username, $context)
$lang->load('com_actionlogs', JPATH_ADMINISTRATOR);
ActionlogsHelper::loadTranslationFiles($extension);
$temp = [];
$tempPlain = [];

foreach ($messages as $message) {
$m = [];
Expand All @@ -159,14 +160,23 @@ protected function sendNotificationEmails($messages, $username, $context)
$m['date'] = HTMLHelper::_('date', $message->log_date, 'Y-m-d H:i:s T', 'UTC');
$m['username'] = $username;
$temp[] = $m;

// copy replacement tags array and set non-HTML message.
$mPlain = array_merge([], $m);
$mPlain['message'] = ActionlogsHelper::getHumanReadableLogMessage($message, false);
$tempPlain[] = $mPlain;
}

$templateData = [
'messages' => $temp,
];
$templateDataPlain = [
'messages' => $tempPlain,
];

$mailer = new MailTemplate('com_actionlogs.notification', $app->getLanguage()->getTag());
$mailer->addTemplateData($templateData);
$mailer->addTemplateData($templateDataPlain, true);

foreach ($recipients as $recipient) {
$mailer->addRecipient($recipient);
Expand Down
20 changes: 10 additions & 10 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,10 +387,10 @@ private function migrateLogRotationPlugin($data)
return;
}

/** @var SchedulerComponent $component */
/** @var \Joomla\Component\Scheduler\Administrator\Extension\SchedulerComponent $component */
$component = Factory::getApplication()->bootComponent('com_scheduler');

/** @var TaskModel $model */
/** @var \Joomla\Component\Scheduler\Administrator\Model\TaskModel $model */
$model = $component->getMVCFactory()->createModel('Task', 'Administrator', ['ignore_request' => true]);

// Get the timeout, as configured in plg_system_logrotation
Expand Down Expand Up @@ -433,10 +433,10 @@ private function migrateSessionGCPlugin($data)
// Get the plugin parameters
$params = new Registry($data->params);

/** @var SchedulerComponent $component */
/** @var \Joomla\Component\Scheduler\Administrator\Extension\SchedulerComponent $component */
$component = Factory::getApplication()->bootComponent('com_scheduler');

/** @var TaskModel $model */
/** @var \Joomla\Component\Scheduler\Administrator\Model\TaskModel $model */
$model = $component->getMVCFactory()->createModel('Task', 'Administrator', ['ignore_request' => true]);
$task = [
'title' => 'Session GC',
Expand Down Expand Up @@ -478,10 +478,10 @@ private function migrateUpdatenotificationPlugin($data)
$params = new Registry($data->params);
$lastrun = (int) $params->get('lastrun', time());

/** @var SchedulerComponent $component */
/** @var \Joomla\Component\Scheduler\Administrator\Extension\SchedulerComponent $component */
$component = Factory::getApplication()->bootComponent('com_scheduler');

/** @var TaskModel $model */
/** @var \Joomla\Component\Scheduler\Administrator\Model\TaskModel $model */
$model = $component->getMVCFactory()->createModel('Task', 'Administrator', ['ignore_request' => true]);
$task = [
'title' => 'Update Notification',
Expand Down Expand Up @@ -2632,10 +2632,10 @@ private function migrateDeleteActionlogsConfiguration(): bool
return true;
}

/** @var SchedulerComponent $component */
/** @var \Joomla\Component\Scheduler\Administrator\Extension\SchedulerComponent $component */
$component = Factory::getApplication()->bootComponent('com_scheduler');

/** @var TaskModel $model */
/** @var \Joomla\Component\Scheduler\Administrator\Model\TaskModel $model */
$model = $component->getMVCFactory()->createModel('Task', 'Administrator', ['ignore_request' => true]);
$task = [
'title' => 'Delete Action Logs',
Expand Down Expand Up @@ -2701,10 +2701,10 @@ private function migratePrivacyconsentConfiguration(): bool
return true;
}

/** @var SchedulerComponent $component */
/** @var \Joomla\Component\Scheduler\Administrator\Extension\SchedulerComponent $component */
$component = Factory::getApplication()->bootComponent('com_scheduler');

/** @var TaskModel $model */
/** @var \Joomla\Component\Scheduler\Administrator\Model\TaskModel $model */
$model = $component->getMVCFactory()->createModel('Task', 'Administrator', ['ignore_request' => true]);
$task = [
'title' => 'Privacy Consent',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `locked`, `manifest_cache`, `params`, `custom_data`, `ordering`, `state`) VALUES
(0, 'plg_schemaorg_article', 'plugin', 'article', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "locked", "manifest_cache", "params", "custom_data", "ordering", "state") VALUES
(0, 'plg_schemaorg_article', 'plugin', 'article', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0);
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ public function setup(\SimpleXMLElement $element, $value, $group = null)
return $result;
}

if ($this->element['extension']) {
$extension = (string) $this->element['extension'];
} else {
$extension = (string) Factory::getApplication()->getInput()->get('extension', 'com_content');
}

Factory::getApplication()->getLanguage()->load('com_categories', JPATH_ADMINISTRATOR);

$languages = LanguageHelper::getContentLanguages([0, 1], false);
Expand All @@ -79,6 +85,7 @@ public function setup(\SimpleXMLElement $element, $value, $group = null)
'view' => 'categories',
'layout' => 'modal',
'tmpl' => 'component',
'extension' => $extension,
Session::getFormToken() => 1,
]);
$linkItem = clone $linkItems;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
<?php endif; ?>
</td>
<td class="d-none d-md-table-cell">
<?php echo htmlspecialchars($item->editor); ?>
<?php echo empty($item->editor) ? $item->editor_user_id : htmlspecialchars($item->editor); ?>
</td>
<td class="text-end">
<?php echo number_format((int) $item->character_count, 0, Text::_('DECIMALS_SEPARATOR'), Text::_('THOUSANDS_SEPARATOR')); ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@

namespace Joomla\Component\Finder\Administrator\Controller;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Router\Route;
use Joomla\Component\Finder\Administrator\Helper\FinderHelper;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand Down Expand Up @@ -53,21 +50,6 @@ public function display($cachable = false, $urlparams = [])
$layout = $this->input->get('layout', 'index', 'word');
$filterId = $this->input->get('filter_id', null, 'int');

if ($view === 'index') {
$pluginEnabled = PluginHelper::isEnabled('content', 'finder');

if (!$pluginEnabled) {
$finderPluginId = FinderHelper::getFinderPluginId();
$link = HTMLHelper::_(
'link',
'#plugin' . $finderPluginId . 'Modal',
Text::_('COM_FINDER_CONTENT_PLUGIN'),
'class="alert-link" data-bs-toggle="modal" id="title-' . $finderPluginId . '"'
);
$this->app->enqueueMessage(Text::sprintf('COM_FINDER_INDEX_PLUGIN_CONTENT_NOT_ENABLED_LINK', $link), 'warning');
}
}

// Check for edit form.
if ($view === 'filter' && $layout === 'edit' && !$this->checkEditId('com_finder.edit.filter', $filterId)) {
// Somehow the person just went to the form - we don't allow that.
Expand Down

0 comments on commit 1339f49

Please sign in to comment.