mirror of
https://github.com/joomla/joomla-cms.git
synced 2024-06-25 23:02:55 +00:00
[4.0] Remove mod_multilangstatus tampering from mod_user (#30113)
* Remove mod_multilangstatus tampering * Remove namespace * Publish multilingual status module on new installations * Show only when multilanguage is enabled * Remove switcher check * Variable typo
This commit is contained in:
commit
994c9d0416
|
@ -9,6 +9,11 @@
|
|||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Helper\ModuleHelper;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\Database\DatabaseInterface;
|
||||
|
||||
$multilanguageEnabled = Multilanguage::isEnabled($app, Factory::getContainer()->get(DatabaseInterface::class));
|
||||
|
||||
require ModuleHelper::getLayoutPath('mod_multilangstatus', $params->get('layout', 'default'));
|
||||
|
|
|
@ -9,10 +9,8 @@
|
|||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.0.0</version>
|
||||
<description>MOD_MULTILANGSTATUS_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Module\Multilangstatus</namespace>
|
||||
<files>
|
||||
<filename module="mod_multilangstatus">mod_multilangstatus.php</filename>
|
||||
<folder>src</folder>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
|
||||
|
|
|
@ -1,141 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage mod_multilangstatus
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Module\Multilangstatus\Administrator\Helper;
|
||||
|
||||
\defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\Database\DatabaseInterface;
|
||||
|
||||
/**
|
||||
* Helper class for the multilangstatus module
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
class MultilangstatusAdminHelper
|
||||
{
|
||||
/**
|
||||
* Method to check if the module exists and is enabled as extension
|
||||
*
|
||||
* @param CMSApplication $app The application
|
||||
* @param DatabaseInterface $db The database
|
||||
*
|
||||
* @return boolean
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public static function isEnabled(CMSApplication $app, DatabaseInterface $db)
|
||||
{
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('enabled'))
|
||||
->from($db->quoteName('#__extensions'))
|
||||
->where($db->quoteName('type') . ' = ' . $db->quote('module'))
|
||||
->where($db->quoteName('element') . ' = ' . $db->quote('mod_multilangstatus'));
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$result = (int) $db->loadResult();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
$app->enqueueMessage($e->getMessage(), 'error');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to check the state of the module
|
||||
*
|
||||
* @param CMSApplication $app The application
|
||||
* @param DatabaseInterface $db The database
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public static function getState(CMSApplication $app, DatabaseInterface $db)
|
||||
{
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('published'))
|
||||
->from($db->quoteName('#__modules'))
|
||||
->where($db->quoteName('module') . ' = ' . $db->quote('mod_multilangstatus'));
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$result = (int) $db->loadResult();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
$app->enqueueMessage($e->getMessage(), 'error');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to publish/unpublish the module depending on the languagefilter state
|
||||
*
|
||||
* @param CMSApplication $app The application
|
||||
* @param DatabaseInterface $db The database
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 4.0.0
|
||||
*/
|
||||
public static function publish(CMSApplication $app, DatabaseInterface $db)
|
||||
{
|
||||
// If the module is trashed do not change its status
|
||||
if (self::getState($app, $db) != -2)
|
||||
{
|
||||
// Publish the module when the languagefilter is enabled
|
||||
if (Multilanguage::isEnabled())
|
||||
{
|
||||
$query = $db->getQuery(true)
|
||||
->update($db->quoteName('#__modules'))
|
||||
->set($db->quoteName('published') . ' = 1')
|
||||
->where($db->quoteName('module') . ' = ' . $db->quote('mod_multilangstatus'));
|
||||
|
||||
try
|
||||
{
|
||||
$db->setQuery($query)->execute();
|
||||
}
|
||||
catch (\RuntimeException $e)
|
||||
{
|
||||
$app->enqueueMessage($e->getMessage(), 'error');
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Unpublish the module when the languagefilter is disabled
|
||||
$query = $db->getQuery(true)
|
||||
->update($db->quoteName('#__modules'))
|
||||
->set($db->quoteName('published') . ' = 0')
|
||||
->where($db->quoteName('module') . ' = ' . $db->quote('mod_multilangstatus'));
|
||||
|
||||
try
|
||||
{
|
||||
$db->setQuery($query)->execute();
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$app->enqueueMessage($e->getMessage(), 'error');
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -13,11 +13,15 @@ use Joomla\CMS\HTML\HTMLHelper;
|
|||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
|
||||
if (!$multilanguageEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$app->getDocument()->getWebAssetManager()
|
||||
->registerAndUseScript('mod_multilangstatus.admin', 'mod_multilangstatus/admin-multilangstatus.min.js', [], ['defer' => true]);
|
||||
|
||||
?>
|
||||
|
||||
<div class="header-item-content multilanguage">
|
||||
<a class="d-flex align-items-stretch" href="#multiLangModal" title="<?php echo Text::_('MOD_MULTILANGSTATUS'); ?>" data-toggle="modal" role="button">
|
||||
<div class="d-flex align-items-end mx-auto">
|
||||
|
|
|
@ -9,27 +9,8 @@
|
|||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Helper\ModuleHelper;
|
||||
use Joomla\CMS\Language\Multilanguage;
|
||||
use Joomla\Database\DatabaseInterface;
|
||||
use Joomla\Module\Multilangstatus\Administrator\Helper\MultilangstatusAdminHelper;
|
||||
|
||||
$db = Factory::getContainer()->get(DatabaseInterface::class);
|
||||
$user = $app->getIdentity();
|
||||
$sitename = htmlspecialchars($app->get('sitename', ''), ENT_QUOTES, 'UTF-8');
|
||||
|
||||
// Check if the multilangstatus module is present and enabled in the site
|
||||
if (class_exists(MultilangstatusAdminHelper::class) && MultilangstatusAdminHelper::isEnabled($app, $db))
|
||||
{
|
||||
// Publish and display the module
|
||||
MultilangstatusAdminHelper::publish($app, $db);
|
||||
|
||||
if (Multilanguage::isEnabled($app, $db))
|
||||
{
|
||||
$module = ModuleHelper::getModule('mod_multilangstatus');
|
||||
$multilanguageStatusModuleOutput = ModuleHelper::renderModule($module);
|
||||
}
|
||||
}
|
||||
$user = $app->getIdentity();
|
||||
|
||||
require ModuleHelper::getLayoutPath('mod_user', $params->get('layout', 'default'));
|
||||
|
|
|
@ -582,7 +582,7 @@ INSERT INTO `#__modules` (`id`, `asset_id`, `title`, `note`, `content`, `orderin
|
|||
(15, 49, 'Title', '', '', 1, 'title', NULL, NULL, 1, 'mod_title', 3, 1, '', 1, '*'),
|
||||
(16, 50, 'Login Form', '', '', 7, 'sidebar-right', NULL, NULL, 1, 'mod_login', 1, 1, '{"greeting":"1","name":"0"}', 0, '*'),
|
||||
(17, 51, 'Breadcrumbs', '', '', 1, 'breadcrumbs', NULL, NULL, 1, 'mod_breadcrumbs', 1, 1, '{"moduleclass_sfx":"","showHome":"1","homeText":"","showComponent":"1","separator":"","cache":"0","cache_time":"0","cachemode":"itemid"}', 0, '*'),
|
||||
(79, 52, 'Multilanguage status', '', '', 2, 'status', NULL, NULL, 0, 'mod_multilangstatus', 3, 1, '{"layout":"_:default","moduleclass_sfx":"","cache":"0"}', 1, '*'),
|
||||
(79, 52, 'Multilanguage status', '', '', 2, 'status', NULL, NULL, 1, 'mod_multilangstatus', 3, 1, '{"layout":"_:default","moduleclass_sfx":"","cache":"0"}', 1, '*'),
|
||||
(86, 53, 'Joomla Version', '', '', 1, 'status', NULL, NULL, 1, 'mod_version', 3, 1, '{"layout":"_:default","moduleclass_sfx":"","cache":"0"}', 1, '*'),
|
||||
(87, 55, 'Sample Data', '', '', 0, 'cpanel', NULL, NULL, 1, 'mod_sampledata', 6, 1, '{"bootstrap_size": "6"}', 1, '*'),
|
||||
(88, 67, 'Latest Actions', '', '', 0, 'cpanel', NULL, NULL, 1, 'mod_latestactions', 6, 1, '{}', 1, '*'),
|
||||
|
|
|
@ -606,7 +606,7 @@ INSERT INTO "#__modules" ("id", "asset_id", "title", "note", "content", "orderin
|
|||
(15, 49, 'Title', '', '', 1, 'title', NULL, NULL, 1, 'mod_title', 3, 1, '', 1, '*'),
|
||||
(16, 50, 'Login Form', '', '', 7, 'sidebar-right', NULL, NULL, 1, 'mod_login', 1, 1, '{"greeting":"1","name":"0"}', 0, '*'),
|
||||
(17, 51, 'Breadcrumbs', '', '', 1, 'breadcrumbs', NULL, NULL, 1, 'mod_breadcrumbs', 1, 1, '{"moduleclass_sfx":"","showHome":"1","homeText":"","showComponent":"1","separator":"","cache":"0","cache_time":"0","cachemode":"itemid"}', 0, '*'),
|
||||
(79, 52, 'Multilanguage status', '', '', 2, 'status', NULL, NULL, 0, 'mod_multilangstatus', 3, 1, '{"layout":"_:default","moduleclass_sfx":"","cache":"0"}', 1, '*'),
|
||||
(79, 52, 'Multilanguage status', '', '', 2, 'status', NULL, NULL, 1, 'mod_multilangstatus', 3, 1, '{"layout":"_:default","moduleclass_sfx":"","cache":"0"}', 1, '*'),
|
||||
(86, 53, 'Joomla Version', '', '', 1, 'status', NULL, NULL, 1, 'mod_version', 3, 1, '{"layout":"_:default","moduleclass_sfx":"","cache":"0"}', 1, '*'),
|
||||
(87, 55, 'Sample Data', '', '', 0, 'cpanel', NULL, NULL, 1, 'mod_sampledata', 6, 1, '{"bootstrap_size": "6"}', 1, '*'),
|
||||
(88, 67, 'Latest Actions', '', '', 0, 'cpanel', NULL, NULL, 1, 'mod_latestactions', 6, 1, '{}', 1, '*'),
|
||||
|
|
Loading…
Reference in New Issue
Block a user