first commit

This commit is contained in:
2025-06-17 11:53:18 +02:00
commit 9f0f7ba12b
8804 changed files with 1369176 additions and 0 deletions

View File

@ -0,0 +1,41 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage mod_privacy_status
*
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
\defined('_JEXEC') or die;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\Component\Privacy\Administrator\Helper\PrivacyHelper;
use Joomla\Database\DatabaseInterface;
use Joomla\Module\PrivacyStatus\Administrator\Helper\PrivacyStatusHelper;
// Only super user can view this data
if (!$app->getIdentity()->authorise('core.admin')) {
return;
}
// Boot component to ensure HTML helpers are loaded
$app->bootComponent('com_privacy');
// Load the privacy component language file.
$lang = $app->getLanguage();
$lang->load('com_privacy', JPATH_ADMINISTRATOR)
|| $lang->load('com_privacy', JPATH_ADMINISTRATOR . '/components/com_privacy');
$privacyPolicyInfo = PrivacyStatusHelper::getPrivacyPolicyInfo();
$requestFormPublished = PrivacyStatusHelper::getRequestFormPublished();
$privacyConsentPluginId = PrivacyHelper::getPrivacyConsentPluginId();
$sendMailEnabled = (bool) $app->get('mailonline', 1);
$numberOfUrgentRequests = PrivacyStatusHelper::getNumberUrgentRequests();
$urgentRequestDays = (int) ComponentHelper::getParams('com_privacy')->get('notify', 14);
$databaseConnectionEncryption = Factory::getContainer()->get(DatabaseInterface::class)->getConnectionEncryption();
require ModuleHelper::getLayoutPath('mod_privacy_status', $params->get('layout', 'default'));

View File

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension type="module" client="administrator" method="upgrade">
<name>mod_privacy_status</name>
<author>Joomla! Project</author>
<creationDate>2019-07</creationDate>
<copyright>(C) 2019 Open Source Matters, Inc.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>4.0.0</version>
<description>MOD_PRIVACY_STATUS_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Module\PrivacyStatus</namespace>
<files>
<filename module="mod_privacy_status">mod_privacy_status.php</filename>
<folder>src</folder>
<folder>tmpl</folder>
</files>
<languages>
<language tag="en-GB">language/en-GB/mod_privacy_status.ini</language>
<language tag="en-GB">language/en-GB/mod_privacy_status.sys.ini</language>
</languages>
<help key="Admin_Modules:_Privacy_Status_Check" />
<config>
<fields name="params">
<fieldset name="advanced">
<field
name="layout"
type="modulelayout"
label="JFIELD_ALT_LAYOUT_LABEL"
class="form-select"
/>
<field
name="moduleclass_sfx"
type="textarea"
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
rows="3"
validate="CssIdentifier"
/>
<field
name="cache"
type="list"
label="COM_MODULES_FIELD_CACHING_LABEL"
default="1"
filter="integer"
validate="options"
>
<option value="1">JGLOBAL_USE_GLOBAL</option>
<option value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
</field>
<field
name="cache_time"
type="number"
label="COM_MODULES_FIELD_CACHE_TIME_LABEL"
default="900"
filter="integer"
min="1"
validate="number"
/>
<field
name="cachemode"
type="hidden"
default="static"
>
<option value="static"></option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,180 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage mod_privacy_status
*
* @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Module\PrivacyStatus\Administrator\Helper;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Event\Privacy\CheckPrivacyPolicyPublishedEvent;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Router\Route;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Helper class for admin privacy status module
*
* @since 4.0.0
*/
class PrivacyStatusHelper
{
/**
* Get the information about the published privacy policy
*
* @return array Array containing a status of whether a privacy policy is set and a link to the policy document for editing
*
* @since 4.0.0
*/
public static function getPrivacyPolicyInfo()
{
$dispatcher = Factory::getApplication()->getDispatcher();
$policy = [
'published' => false,
'articlePublished' => false,
'editLink' => '',
];
/*
* Prior to 3.9.0 it was common for a plugin such as the User - Profile plugin to define a privacy policy or
* terms of service article, therefore we will also import the user plugin group to process this event.
*/
PluginHelper::importPlugin('privacy', null, true, $dispatcher);
PluginHelper::importPlugin('user', null, true, $dispatcher);
return $dispatcher->dispatch(
'onPrivacyCheckPrivacyPolicyPublished',
new CheckPrivacyPolicyPublishedEvent('onPrivacyCheckPrivacyPolicyPublished', [
'subject' => &$policy, // @todo: Remove reference in Joomla 6, see CheckPrivacyPolicyPublishedEvent::__constructor()
])
)->getArgument('subject', $policy);
}
/**
* Check whether there is a menu item for the request form
*
* @return array Array containing a status of whether a menu is published for the request form and its current link
*
* @since 4.0.0
*/
public static function getRequestFormPublished()
{
$status = [
'exists' => false,
'published' => false,
'link' => '',
];
$lang = '';
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select(
[
$db->quoteName('id'),
$db->quoteName('published'),
$db->quoteName('language'),
]
)
->from($db->quoteName('#__menu'))
->where(
[
$db->quoteName('client_id') . ' = 0',
$db->quoteName('link') . ' = ' . $db->quote('index.php?option=com_privacy&view=request'),
]
)
->setLimit(1);
$db->setQuery($query);
$menuItem = $db->loadObject();
// Check if the menu item exists in database
if ($menuItem) {
$status['exists'] = true;
// Check if the menu item is published
if ($menuItem->published == 1) {
$status['published'] = true;
}
// Add language to the url if the site is multilingual
if (Multilanguage::isEnabled() && $menuItem->language && $menuItem->language !== '*') {
$lang = '&lang=' . $menuItem->language;
}
}
$linkMode = Factory::getApplication()->get('force_ssl', 0) == 2 ? Route::TLS_FORCE : Route::TLS_IGNORE;
if (!$menuItem) {
if (Multilanguage::isEnabled()) {
// Find the Itemid of the home menu item tagged to the site default language
$params = ComponentHelper::getParams('com_languages');
$defaultSiteLanguage = $params->get('site');
$db = Factory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__menu'))
->where(
[
$db->quoteName('client_id') . ' = 0',
$db->quoteName('home') . ' = 1',
$db->quoteName('language') . ' = :language',
]
)
->bind(':language', $defaultSiteLanguage)
->setLimit(1);
$db->setQuery($query);
$homeId = (int) $db->loadResult();
$itemId = $homeId ? '&Itemid=' . $homeId : '';
} else {
$itemId = '';
}
$status['link'] = Route::link('site', 'index.php?option=com_privacy&view=request' . $itemId, true, $linkMode);
} else {
$status['link'] = Route::link('site', 'index.php?Itemid=' . $menuItem->id . $lang, true, $linkMode);
}
return $status;
}
/**
* Method to return number privacy requests older than X days.
*
* @return integer
*
* @since 4.0.0
*/
public static function getNumberUrgentRequests()
{
// Load the parameters.
$params = ComponentHelper::getComponent('com_privacy')->getParams();
$notify = (int) $params->get('notify', 14);
$now = Factory::getDate()->toSql();
$period = '-' . $notify;
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query->select('COUNT(*)')
->from($db->quoteName('#__privacy_requests'))
->where(
[
$db->quoteName('status') . ' = 1',
$query->dateAdd($db->quote($now), $period, 'DAY') . ' > ' . $db->quoteName('requested_at'),
]
);
$db->setQuery($query);
return (int) $db->loadResult();
}
}

View File

@ -0,0 +1,151 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage mod_privacy_status
*
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;
?>
<table class="table">
<caption class="visually-hidden">
<?php echo Text::_('MOD_PRIVACY_STATUS'); ?>
</caption>
<thead>
<tr>
<th scope="col" class="w-20"><?php echo Text::_('COM_PRIVACY_DASHBOARD_HEADING_STATUS'); ?></th>
<th scope="col"><?php echo Text::_('COM_PRIVACY_DASHBOARD_HEADING_CHECK'); ?></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<?php if ($privacyPolicyInfo['published'] && $privacyPolicyInfo['articlePublished']) : ?>
<span class="badge bg-success">
<span class="icon-check-square" aria-hidden="true"></span>
<?php echo Text::_('JPUBLISHED'); ?>
</span>
<?php elseif ($privacyPolicyInfo['published'] && !$privacyPolicyInfo['articlePublished']) : ?>
<span class="badge bg-warning text-dark">
<span class="icon-exclamation-triangle" aria-hidden="true"></span>
<?php echo Text::_('JUNPUBLISHED'); ?>
</span>
<?php else : ?>
<span class="badge bg-warning text-dark">
<span class="icon-exclamation-triangle" aria-hidden="true"></span>
<?php echo Text::_('COM_PRIVACY_STATUS_CHECK_NOT_AVAILABLE'); ?>
</span>
<?php endif; ?>
</td>
<td>
<div><?php echo Text::_('COM_PRIVACY_STATUS_CHECK_PRIVACY_POLICY_PUBLISHED'); ?></div>
<?php if ($privacyPolicyInfo['editLink'] !== '') : ?>
<small><a href="<?php echo $privacyPolicyInfo['editLink']; ?>"><?php echo Text::_('COM_PRIVACY_EDIT_PRIVACY_POLICY'); ?></a></small>
<?php else : ?>
<?php $link = Route::_('index.php?option=com_plugins&task=plugin.edit&extension_id=' . $privacyConsentPluginId); ?>
<small><a href="<?php echo $link; ?>"><?php echo Text::_('COM_PRIVACY_EDIT_PRIVACY_CONSENT_PLUGIN'); ?></a></small>
<?php endif; ?>
</td>
</tr>
<tr>
<td>
<?php if ($requestFormPublished['published'] && $requestFormPublished['exists']) : ?>
<span class="badge bg-success">
<span class="icon-check-square" aria-hidden="true"></span>
<?php echo Text::_('JPUBLISHED'); ?>
</span>
<?php elseif (!$requestFormPublished['published'] && $requestFormPublished['exists']) : ?>
<span class="badge bg-warning text-dark">
<span class="icon-exclamation-triangle" aria-hidden="true"></span>
<?php echo Text::_('JUNPUBLISHED'); ?>
</span>
<?php else : ?>
<span class="badge bg-warning text-dark">
<span class="icon-exclamation-triangle" aria-hidden="true"></span>
<?php echo Text::_('COM_PRIVACY_STATUS_CHECK_NOT_AVAILABLE'); ?>
</span>
<?php endif; ?>
</td>
<td>
<div><?php echo Text::_('COM_PRIVACY_STATUS_CHECK_REQUEST_FORM_MENU_ITEM_PUBLISHED'); ?></div>
<?php if ($requestFormPublished['link'] !== '') : ?>
<small><a href="<?php echo $requestFormPublished['link']; ?>" class="break-word"><?php echo $requestFormPublished['link']; ?></a></small>
<?php endif; ?>
</td>
</tr>
<tr>
<td>
<?php if ($numberOfUrgentRequests === 0) : ?>
<span class="badge bg-success">
<span class="icon-check-square" aria-hidden="true"></span>
<?php echo Text::_('JNONE'); ?>
</span>
<?php else : ?>
<span class="badge bg-danger">
<span class="icon-exclamation-triangle" aria-hidden="true"></span>
<?php echo Text::_('WARNING'); ?>
</span>
<?php endif; ?>
</td>
<td>
<div><?php echo Text::_('COM_PRIVACY_STATUS_CHECK_OUTSTANDING_URGENT_REQUESTS'); ?></div>
<small><?php echo Text::plural('COM_PRIVACY_STATUS_CHECK_OUTSTANDING_URGENT_REQUESTS_DESCRIPTION', $urgentRequestDays); ?></small>
<?php if ($numberOfUrgentRequests > 0) : ?>
<small><a href="<?php echo Route::_('index.php?option=com_privacy&view=requests&filter[status]=1&list[fullordering]=a.requested_at ASC'); ?>"><?php echo Text::_('COM_PRIVACY_SHOW_URGENT_REQUESTS'); ?></a></small>
<?php endif; ?>
</td>
</tr>
<tr>
<td>
<?php if ($sendMailEnabled) : ?>
<span class="badge bg-success">
<span class="icon-check-square" aria-hidden="true"></span>
<?php echo Text::_('JENABLED'); ?>
</span>
<?php else : ?>
<span class="badge bg-danger">
<span class="icon-exclamation-triangle" aria-hidden="true"></span>
<?php echo Text::_('JDISABLED'); ?>
</span>
<?php endif; ?>
</td>
<td>
<?php if (!$sendMailEnabled) : ?>
<div><?php echo Text::_('COM_PRIVACY_STATUS_CHECK_SENDMAIL_DISABLED'); ?></div>
<small><?php echo Text::_('COM_PRIVACY_STATUS_CHECK_SENDMAIL_DISABLED_DESCRIPTION'); ?></small>
<?php else : ?>
<div><?php echo Text::_('COM_PRIVACY_STATUS_CHECK_SENDMAIL_ENABLED'); ?></div>
<?php endif; ?>
</td>
</tr>
<tr>
<td>
<?php if ($databaseConnectionEncryption !== '') : ?>
<span class="badge bg-success">
<span class="icon-check-square" aria-hidden="true"></span>
<?php echo Text::_('JENABLED'); ?>
</span>
<?php else : ?>
<span class="badge bg-warning text-dark">
<span class="icon-exclamation-triangle" aria-hidden="true"></span>
<?php echo Text::_('COM_PRIVACY_STATUS_CHECK_NOT_AVAILABLE'); ?>
</span>
<?php endif; ?>
</td>
<td>
<?php if ($databaseConnectionEncryption === '') : ?>
<?php echo Text::_('MOD_PRIVACY_STATUS_CHECK_DATABASE_CONNECTION_ENCRYPTION_DISABLED'); ?>
<?php else : ?>
<?php echo Text::sprintf('MOD_PRIVACY_STATUS_CHECK_DATABASE_CONNECTION_ENCRYPTION_ENABLED', $databaseConnectionEncryption); ?>
<?php endif; ?>
</td>
</tr>
</tbody>
</table>