feat: rename mokowaas_tos to mokowaas_offline + auto-migrate from standalone MokoJoomTOS
Renamed plugin element from mokowaas_tos to mokowaas_offline to better reflect its purpose (offline bypass, not just TOS). Added migrateStandalonePlugins() to package script: - Detects if standalone mokojoomtos plugin is installed - Copies its params (configured slugs) to mokowaas_offline - Removes old extension record, update sites, and files - Logs the migration Future standalone-to-MokoWaaS migrations can be added to the $migrations array. Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -45,7 +45,7 @@ class DashboardModel extends BaseDatabaseModel
|
||||
'protected' => false,
|
||||
'configure_only' => false,
|
||||
],
|
||||
'mokowaas_tos' => [
|
||||
'mokowaas_offline' => [
|
||||
'icon' => 'icon-globe',
|
||||
'category' => 'security',
|
||||
'label' => 'Offline Bypass',
|
||||
|
||||
@@ -1411,7 +1411,7 @@ class MokoWaaS extends CMSPlugin implements BootableExtensionInterface
|
||||
$db->quote('mokowaas_firewall'),
|
||||
$db->quote('mokowaas_tenant'),
|
||||
$db->quote('mokowaas_devtools'),
|
||||
$db->quote('mokowaas_tos'),
|
||||
$db->quote('mokowaas_offline'),
|
||||
$db->quote('mod_mokowaas_cpanel'),
|
||||
];
|
||||
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
; MokoWaaS Terms of Service Plugin
|
||||
; Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
; License: GPL-3.0-or-later
|
||||
|
||||
PLG_SYSTEM_MOKOWAAS_OFFLINE="System - MokoWaaS Offline Bypass"
|
||||
PLG_SYSTEM_MOKOWAAS_OFFLINE_DESC="Keep selected pages (Terms of Service, Privacy Policy, etc.) accessible when the site is in offline mode."
|
||||
|
||||
PLG_SYSTEM_MOKOWAAS_OFFLINE_FIELDSET_BASIC="Offline-Accessible Pages"
|
||||
PLG_SYSTEM_MOKOWAAS_OFFLINE_SLUG_LABEL="Menu Items to Keep Online"
|
||||
PLG_SYSTEM_MOKOWAAS_OFFLINE_SLUG_DESC="Select menu items that remain accessible during offline mode. Hold Ctrl/Cmd for multiple."
|
||||
PLG_SYSTEM_MOKOWAAS_OFFLINE_CHILDREN_LABEL="Include Child Menu Items"
|
||||
PLG_SYSTEM_MOKOWAAS_OFFLINE_CHILDREN_DESC="Also allow access to child pages under the selected items."
|
||||
PLG_SYSTEM_MOKOWAAS_OFFLINE_SEF_WARNING="SEF URLs are disabled - path matching requires SEF. Itemid fallback is active."
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
; MokoWaaS Terms of Service Plugin - System strings
|
||||
PLG_SYSTEM_MOKOWAAS_OFFLINE="System - MokoWaaS Offline Bypass"
|
||||
PLG_SYSTEM_MOKOWAAS_OFFLINE_DESC="Keep selected pages (Terms of Service, Privacy Policy, etc.) accessible when the site is in offline mode."
|
||||
+11
-11
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="plugin" group="system" method="upgrade">
|
||||
<name>System - MokoWaaS Offline Bypass</name>
|
||||
<element>mokowaas_tos</element>
|
||||
<element>mokowaas_offline</element>
|
||||
<author>Moko Consulting</author>
|
||||
<creationDate>2026-06-02</creationDate>
|
||||
<copyright>Copyright (C) 2026 Moko Consulting. All rights reserved.</copyright>
|
||||
@@ -9,8 +9,8 @@
|
||||
<authorEmail>hello@mokoconsulting.tech</authorEmail>
|
||||
<authorUrl>https://mokoconsulting.tech</authorUrl>
|
||||
<version>02.32.32</version>
|
||||
<description>PLG_SYSTEM_MOKOWAAS_TOS_DESC</description>
|
||||
<namespace path="src">Moko\Plugin\System\MokoWaaSTos</namespace>
|
||||
<description>PLG_SYSTEM_MOKOWAAS_OFFLINE_DESC</description>
|
||||
<namespace path="src">Moko\Plugin\System\MokoWaaSOffline</namespace>
|
||||
|
||||
<files>
|
||||
<folder>src</folder>
|
||||
@@ -19,21 +19,21 @@
|
||||
</files>
|
||||
|
||||
<languages folder="language">
|
||||
<language tag="en-GB">en-GB/plg_system_mokowaas_tos.ini</language>
|
||||
<language tag="en-GB">en-GB/plg_system_mokowaas_tos.sys.ini</language>
|
||||
<language tag="en-GB">en-GB/plg_system_mokowaas_offline.ini</language>
|
||||
<language tag="en-GB">en-GB/plg_system_mokowaas_offline.sys.ini</language>
|
||||
</languages>
|
||||
|
||||
<config>
|
||||
<fields name="params" addfieldprefix="Moko\Plugin\System\MokoWaaSTos\Field">
|
||||
<fieldset name="basic" label="PLG_SYSTEM_MOKOWAAS_TOS_FIELDSET_BASIC">
|
||||
<fields name="params" addfieldprefix="Moko\Plugin\System\MokoWaaSOffline\Field">
|
||||
<fieldset name="basic" label="PLG_SYSTEM_MOKOWAAS_OFFLINE_FIELDSET_BASIC">
|
||||
<field name="tos_slug" type="menuslug"
|
||||
label="PLG_SYSTEM_MOKOWAAS_TOS_SLUG_LABEL"
|
||||
description="PLG_SYSTEM_MOKOWAAS_TOS_SLUG_DESC"
|
||||
label="PLG_SYSTEM_MOKOWAAS_OFFLINE_SLUG_LABEL"
|
||||
description="PLG_SYSTEM_MOKOWAAS_OFFLINE_SLUG_DESC"
|
||||
multiple="true" />
|
||||
|
||||
<field name="include_children" type="radio" default="1"
|
||||
label="PLG_SYSTEM_MOKOWAAS_TOS_CHILDREN_LABEL"
|
||||
description="PLG_SYSTEM_MOKOWAAS_TOS_CHILDREN_DESC"
|
||||
label="PLG_SYSTEM_MOKOWAAS_OFFLINE_CHILDREN_LABEL"
|
||||
description="PLG_SYSTEM_MOKOWAAS_OFFLINE_CHILDREN_DESC"
|
||||
class="btn-group btn-group-yesno">
|
||||
<option value="1">JYES</option>
|
||||
<option value="0">JNO</option>
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* @package MokoWaaS
|
||||
* @subpackage plg_system_mokowaas_tos
|
||||
* @subpackage plg_system_mokowaas_offline
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
*/
|
||||
@@ -14,7 +14,7 @@ use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Moko\Plugin\System\MokoWaaSTos\Extension\Tos;
|
||||
use Moko\Plugin\System\MokoWaaSOffline\Extension\Tos;
|
||||
|
||||
return new class implements ServiceProviderInterface
|
||||
{
|
||||
@@ -24,7 +24,7 @@ return new class implements ServiceProviderInterface
|
||||
PluginInterface::class,
|
||||
function (Container $container) {
|
||||
$dispatcher = $container->get(DispatcherInterface::class);
|
||||
$plugin = new Tos($dispatcher, (array) PluginHelper::getPlugin('system', 'mokowaas_tos'));
|
||||
$plugin = new Tos($dispatcher, (array) PluginHelper::getPlugin('system', 'mokowaas_offline'));
|
||||
$plugin->setApplication(Factory::getApplication());
|
||||
|
||||
return $plugin;
|
||||
+2
-2
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @package MokoWaaS
|
||||
* @subpackage plg_system_mokowaas_tos
|
||||
* @subpackage plg_system_mokowaas_offline
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
*/
|
||||
|
||||
namespace Moko\Plugin\System\MokoWaaSTos\Extension;
|
||||
namespace Moko\Plugin\System\MokoWaaSOffline\Extension;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* @package MokoWaaS
|
||||
* @subpackage plg_system_mokowaas_tos
|
||||
* @subpackage plg_system_mokowaas_offline
|
||||
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
* @license GNU General Public License version 3 or later; see LICENSE
|
||||
*/
|
||||
|
||||
namespace Moko\Plugin\System\MokoWaaSTos\Field;
|
||||
namespace Moko\Plugin\System\MokoWaaSOffline\Field;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
@@ -30,7 +30,7 @@ class MenuslugField extends ListField
|
||||
{
|
||||
$options[] = (object) [
|
||||
'value' => '',
|
||||
'text' => Text::_('PLG_SYSTEM_MOKOWAAS_TOS_SEF_WARNING'),
|
||||
'text' => Text::_('PLG_SYSTEM_MOKOWAAS_OFFLINE_SEF_WARNING'),
|
||||
'disabled' => true,
|
||||
];
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
; MokoWaaS Terms of Service Plugin
|
||||
; Copyright (C) 2026 Moko Consulting. All rights reserved.
|
||||
; License: GPL-3.0-or-later
|
||||
|
||||
PLG_SYSTEM_MOKOWAAS_TOS="System - MokoWaaS Offline Bypass"
|
||||
PLG_SYSTEM_MOKOWAAS_TOS_DESC="Keep selected pages (Terms of Service, Privacy Policy, etc.) accessible when the site is in offline mode."
|
||||
|
||||
PLG_SYSTEM_MOKOWAAS_TOS_FIELDSET_BASIC="Offline-Accessible Pages"
|
||||
PLG_SYSTEM_MOKOWAAS_TOS_SLUG_LABEL="Menu Items to Keep Online"
|
||||
PLG_SYSTEM_MOKOWAAS_TOS_SLUG_DESC="Select menu items that remain accessible during offline mode. Hold Ctrl/Cmd for multiple."
|
||||
PLG_SYSTEM_MOKOWAAS_TOS_CHILDREN_LABEL="Include Child Menu Items"
|
||||
PLG_SYSTEM_MOKOWAAS_TOS_CHILDREN_DESC="Also allow access to child pages under the selected items."
|
||||
PLG_SYSTEM_MOKOWAAS_TOS_SEF_WARNING="SEF URLs are disabled - path matching requires SEF. Itemid fallback is active."
|
||||
@@ -1,3 +0,0 @@
|
||||
; MokoWaaS Terms of Service Plugin - System strings
|
||||
PLG_SYSTEM_MOKOWAAS_TOS="System - MokoWaaS Offline Bypass"
|
||||
PLG_SYSTEM_MOKOWAAS_TOS_DESC="Keep selected pages (Terms of Service, Privacy Policy, etc.) accessible when the site is in offline mode."
|
||||
@@ -17,7 +17,7 @@
|
||||
<file type="plugin" id="plg_system_mokowaas_firewall" group="system">plg_system_mokowaas_firewall.zip</file>
|
||||
<file type="plugin" id="plg_system_mokowaas_tenant" group="system">plg_system_mokowaas_tenant.zip</file>
|
||||
<file type="plugin" id="plg_system_mokowaas_devtools" group="system">plg_system_mokowaas_devtools.zip</file>
|
||||
<file type="plugin" id="plg_system_mokowaas_tos" group="system">plg_system_mokowaas_tos.zip</file>
|
||||
<file type="plugin" id="plg_system_mokowaas_offline" group="system">plg_system_mokowaas_offline.zip</file>
|
||||
<file type="component" id="com_mokowaas">com_mokowaas.zip</file>
|
||||
<file type="module" id="mod_mokowaas_cpanel" client="administrator">mod_mokowaas_cpanel.zip</file>
|
||||
<file type="plugin" id="plg_webservices_mokowaas" group="webservices">plg_webservices_mokowaas.zip</file>
|
||||
|
||||
+115
-2
@@ -37,12 +37,13 @@ class Pkg_MokowaasInstallerScript
|
||||
// Remove legacy and retired extensions
|
||||
$this->cleanupLegacyExtensions();
|
||||
$this->removeRetiredExtensions();
|
||||
$this->migrateStandalonePlugins();
|
||||
|
||||
$this->enablePlugin('system', 'mokowaas');
|
||||
$this->enablePlugin('system', 'mokowaas_firewall');
|
||||
$this->enablePlugin('system', 'mokowaas_tenant');
|
||||
$this->enablePlugin('system', 'mokowaas_devtools');
|
||||
$this->enablePlugin('system', 'mokowaas_tos');
|
||||
$this->enablePlugin('system', 'mokowaas_offline');
|
||||
$this->enablePlugin('webservices', 'mokowaas');
|
||||
$this->enablePlugin('task', 'mokowaasdemo');
|
||||
$this->enablePlugin('task', 'mokowaassync');
|
||||
@@ -137,6 +138,118 @@ class Pkg_MokowaasInstallerScript
|
||||
*
|
||||
* @since 02.32.00
|
||||
*/
|
||||
private function migrateStandalonePlugins(): void
|
||||
{
|
||||
// Migrate standalone MokoJoomTOS plugin to MokoWaaS Offline Bypass
|
||||
$migrations = [
|
||||
['old_element' => 'mokojoomtos', 'old_folder' => 'system', 'new_element' => 'mokowaas_offline', 'new_folder' => 'system'],
|
||||
];
|
||||
|
||||
try
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
|
||||
foreach ($migrations as $m)
|
||||
{
|
||||
// Check if old plugin exists
|
||||
$query = $db->getQuery(true)
|
||||
->select([$db->quoteName('extension_id'), $db->quoteName('params')])
|
||||
->from($db->quoteName('#__extensions'))
|
||||
->where($db->quoteName('element') . ' = ' . $db->quote($m['old_element']))
|
||||
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
|
||||
->where($db->quoteName('folder') . ' = ' . $db->quote($m['old_folder']));
|
||||
$db->setQuery($query);
|
||||
$old = $db->loadObject();
|
||||
|
||||
if (!$old)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$oldParams = $old->params ?? '{}';
|
||||
|
||||
// Copy params to new plugin (only if new plugin has empty params)
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('params'))
|
||||
->from($db->quoteName('#__extensions'))
|
||||
->where($db->quoteName('element') . ' = ' . $db->quote($m['new_element']))
|
||||
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
|
||||
->where($db->quoteName('folder') . ' = ' . $db->quote($m['new_folder']));
|
||||
$db->setQuery($query);
|
||||
$newParams = (string) $db->loadResult();
|
||||
|
||||
if (empty($newParams) || $newParams === '{}' || $newParams === '[]')
|
||||
{
|
||||
$db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->update($db->quoteName('#__extensions'))
|
||||
->set($db->quoteName('params') . ' = ' . $db->quote($oldParams))
|
||||
->where($db->quoteName('element') . ' = ' . $db->quote($m['new_element']))
|
||||
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
|
||||
->where($db->quoteName('folder') . ' = ' . $db->quote($m['new_folder']))
|
||||
)->execute();
|
||||
|
||||
Factory::getApplication()->enqueueMessage(
|
||||
sprintf('Migrated settings from %s to %s.', $m['old_element'], $m['new_element']),
|
||||
'message'
|
||||
);
|
||||
}
|
||||
|
||||
// Unprotect old plugin
|
||||
$db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->update($db->quoteName('#__extensions'))
|
||||
->set($db->quoteName('protected') . ' = 0')
|
||||
->where($db->quoteName('extension_id') . ' = ' . (int) $old->extension_id)
|
||||
)->execute();
|
||||
|
||||
// Remove old extension record
|
||||
$db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->delete($db->quoteName('#__extensions'))
|
||||
->where($db->quoteName('extension_id') . ' = ' . (int) $old->extension_id)
|
||||
)->execute();
|
||||
|
||||
// Remove old update site entries
|
||||
$db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->delete($db->quoteName('#__update_sites_extensions'))
|
||||
->where($db->quoteName('extension_id') . ' = ' . (int) $old->extension_id)
|
||||
)->execute();
|
||||
|
||||
// Remove old files
|
||||
$dir = JPATH_PLUGINS . '/' . $m['old_folder'] . '/' . $m['old_element'];
|
||||
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$this->rmdirRecursive($dir);
|
||||
}
|
||||
|
||||
Factory::getApplication()->enqueueMessage(
|
||||
sprintf('Removed standalone %s plugin (replaced by %s).', $m['old_element'], $m['new_element']),
|
||||
'message'
|
||||
);
|
||||
|
||||
Log::add(
|
||||
sprintf('Migrated %s → %s and removed old plugin', $m['old_element'], $m['new_element']),
|
||||
Log::INFO,
|
||||
'mokowaas'
|
||||
);
|
||||
}
|
||||
}
|
||||
catch (\Throwable $e)
|
||||
{
|
||||
Log::add('Standalone plugin migration error: ' . $e->getMessage(), Log::WARNING, 'mokowaas');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove extensions that have been retired and merged into core.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 02.32.00
|
||||
*/
|
||||
private function removeRetiredExtensions(): void
|
||||
{
|
||||
$retired = [
|
||||
@@ -290,7 +403,7 @@ class Pkg_MokowaasInstallerScript
|
||||
$db->quote('mokowaas_firewall'),
|
||||
$db->quote('mokowaas_tenant'),
|
||||
$db->quote('mokowaas_devtools'),
|
||||
$db->quote('mokowaas_tos'),
|
||||
$db->quote('mokowaas_offline'),
|
||||
$db->quote('com_mokowaas'),
|
||||
$db->quote('mod_mokowaas_cpanel'),
|
||||
$db->quote('mokowaasdemo'),
|
||||
|
||||
Reference in New Issue
Block a user