feat: cascade enable/disable across all MokoWaaS extensions
Generic: Repo Health / Site Health (push) Has been cancelled
Generic: Repo Health / Access control (push) Has been cancelled
Universal: Auto Version Bump / Version Bump (push) Has been cancelled
Update Server / Update Server (push) Has been cancelled
Platform: moko-platform CI / Gate 1: Code Quality (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (push) Has been cancelled
Platform: moko-platform CI / Gate 3: Self-Health Check (push) Has been cancelled
Platform: moko-platform CI / Gate 4: Governance (push) Has been cancelled
Platform: moko-platform CI / Gate 5: Template Integrity (push) Has been cancelled
Platform: moko-platform CI / CI Summary (push) Has been cancelled
Generic: Repo Health / Release configuration (push) Has been cancelled
Generic: Repo Health / Scripts governance (push) Has been cancelled
Generic: Repo Health / Repository health (push) Has been cancelled
Generic: Repo Health / Site Health (push) Has been cancelled
Generic: Repo Health / Access control (push) Has been cancelled
Universal: Auto Version Bump / Version Bump (push) Has been cancelled
Update Server / Update Server (push) Has been cancelled
Platform: moko-platform CI / Gate 1: Code Quality (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (push) Has been cancelled
Platform: moko-platform CI / Gate 3: Self-Health Check (push) Has been cancelled
Platform: moko-platform CI / Gate 4: Governance (push) Has been cancelled
Platform: moko-platform CI / Gate 5: Template Integrity (push) Has been cancelled
Platform: moko-platform CI / CI Summary (push) Has been cancelled
Generic: Repo Health / Release configuration (push) Has been cancelled
Generic: Repo Health / Scripts governance (push) Has been cancelled
Generic: Repo Health / Repository health (push) Has been cancelled
When the core system plugin is disabled, all feature plugins (firewall, tenant, devtools, monitor) and the cpanel module are automatically disabled too. Re-enabling cascades the same way. Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1463,6 +1463,96 @@ class MokoWaaS extends CMSPlugin implements BootableExtensionInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cascade enable/disable state across all MokoWaaS extensions.
|
||||
*
|
||||
* When the core system plugin (plg_system_mokowaas) is disabled,
|
||||
* all feature plugins and the cpanel module are also disabled.
|
||||
* When re-enabled, they are re-enabled too.
|
||||
*
|
||||
* @param string $context The extension context
|
||||
* @param array $pks Extension IDs being changed
|
||||
* @param int $value New state (1=enabled, 0=disabled)
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 02.32.00
|
||||
*/
|
||||
public function onExtensionChangeState($context, $pks, $value)
|
||||
{
|
||||
if (empty($pks))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
|
||||
// Check if the core MokoWaaS plugin is among the changed extensions
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('extension_id'))
|
||||
->from($db->quoteName('#__extensions'))
|
||||
->where($db->quoteName('element') . ' = ' . $db->quote('mokowaas'))
|
||||
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
|
||||
->where($db->quoteName('folder') . ' = ' . $db->quote('system'));
|
||||
$db->setQuery($query);
|
||||
$coreId = (int) $db->loadResult();
|
||||
|
||||
if (!$coreId || !\in_array($coreId, array_map('intval', $pks), true))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Cascade to all MokoWaaS feature plugins + module
|
||||
$mokoElements = [
|
||||
$db->quote('mokowaas_firewall'),
|
||||
$db->quote('mokowaas_tenant'),
|
||||
$db->quote('mokowaas_devtools'),
|
||||
$db->quote('mokowaas_monitor'),
|
||||
$db->quote('mod_mokowaas_cpanel'),
|
||||
];
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->update($db->quoteName('#__extensions'))
|
||||
->set($db->quoteName('enabled') . ' = ' . (int) $value)
|
||||
->where($db->quoteName('element') . ' IN (' . implode(',', $mokoElements) . ')');
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
$affected = $db->getAffectedRows();
|
||||
|
||||
// Also update module published state
|
||||
if ($value == 0)
|
||||
{
|
||||
$db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->update($db->quoteName('#__modules'))
|
||||
->set($db->quoteName('published') . ' = 0')
|
||||
->where($db->quoteName('module') . ' = ' . $db->quote('mod_mokowaas_cpanel'))
|
||||
)->execute();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->update($db->quoteName('#__modules'))
|
||||
->set($db->quoteName('published') . ' = 1')
|
||||
->where($db->quoteName('module') . ' = ' . $db->quote('mod_mokowaas_cpanel'))
|
||||
)->execute();
|
||||
}
|
||||
|
||||
$state = $value ? 'enabled' : 'disabled';
|
||||
$this->app->enqueueMessage(
|
||||
"MokoWaaS: {$state} {$affected} associated extensions.",
|
||||
'message'
|
||||
);
|
||||
}
|
||||
catch (\Throwable $e)
|
||||
{
|
||||
Log::add('MokoWaaS cascade state error: ' . $e->getMessage(), Log::WARNING, 'mokowaas');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter admin menu items for non-master users.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user