From 3df40214f37b1cfcb37eb2572fd7f6ea3a54dc87 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Tue, 21 Apr 2026 17:09:04 -0500 Subject: [PATCH] =?UTF-8?q?feat:=20prefer=20MokoOnyx=20over=20MokoCassiope?= =?UTF-8?q?ia=20=E2=80=94=20lock=20Onyx,=20unlock=20Cassiopeia?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If MokoOnyx is installed, lock it and set as default. Unlock MokoCassiopeia to allow uninstall. Falls back to MokoCassiopeia if Onyx not present. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/script.php | 55 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 11 deletions(-) diff --git a/src/script.php b/src/script.php index cbe4db17..327e2208 100644 --- a/src/script.php +++ b/src/script.php @@ -210,10 +210,11 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface } /** - * Ensure mokocassiopeia template is installed and locked. + * Ensure the active Moko template is installed and locked. * - * If the template exists in #__extensions, lock and protect it. - * If not found, attempt to install from the update server. + * Prefers MokoOnyx (successor). Falls back to MokoCassiopeia. + * If MokoOnyx is found, lock it and unlock MokoCassiopeia. + * If only MokoCassiopeia is found, lock it as before. * * @return void * @@ -221,17 +222,50 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface */ private function ensureMokoCassiopeia() { - $db = Factory::getDbo(); + $db = Factory::getDbo(); + + // Check for MokoOnyx first (successor template) $query = $db->getQuery(true) ->select([$db->quoteName('extension_id'), $db->quoteName('enabled')]) ->from($db->quoteName('#__extensions')) - ->where($db->quoteName('element') . ' = ' - . $db->quote('mokocassiopeia')) - ->where($db->quoteName('type') . ' = ' - . $db->quote('template')); + ->where($db->quoteName('element') . ' = ' . $db->quote('mokoonyx')) + ->where($db->quoteName('type') . ' = ' . $db->quote('template')); + $onyx = $db->setQuery($query)->loadObject(); - $db->setQuery($query); - $template = $db->loadObject(); + if ($onyx) + { + // Lock and protect MokoOnyx + $db->setQuery( + $db->getQuery(true) + ->update($db->quoteName('#__extensions')) + ->set($db->quoteName('enabled') . ' = 1') + ->set($db->quoteName('locked') . ' = 1') + ->set($db->quoteName('protected') . ' = 1') + ->where($db->quoteName('extension_id') . ' = ' . (int) $onyx->extension_id) + )->execute(); + + $this->setDefaultTemplate('mokoonyx', 0); + + // Unlock MokoCassiopeia if present (allow uninstall) + $db->setQuery( + $db->getQuery(true) + ->update($db->quoteName('#__extensions')) + ->set($db->quoteName('locked') . ' = 0') + ->set($db->quoteName('protected') . ' = 0') + ->where($db->quoteName('element') . ' = ' . $db->quote('mokocassiopeia')) + ->where($db->quoteName('type') . ' = ' . $db->quote('template')) + )->execute(); + + return; + } + + // Fallback: MokoCassiopeia + $query = $db->getQuery(true) + ->select([$db->quoteName('extension_id'), $db->quoteName('enabled')]) + ->from($db->quoteName('#__extensions')) + ->where($db->quoteName('element') . ' = ' . $db->quote('mokocassiopeia')) + ->where($db->quoteName('type') . ' = ' . $db->quote('template')); + $template = $db->setQuery($query)->loadObject(); if ($template) { @@ -247,7 +281,6 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface ); $db->execute(); - // Set as default site template $this->setDefaultTemplate('mokocassiopeia', 0); return;