feat: auto-install mokocassiopeia, set as default, lock template

Minor version bump to 02.01.01:
- Auto-install mokocassiopeia from GitHub if not present
- Lock and protect the template (cannot be disabled/uninstalled)
- Set mokocassiopeia as default site template

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 16:22:01 -05:00
parent 7fdfaac7fb
commit c81e409a57
4 changed files with 46 additions and 7 deletions
+40 -1
View File
@@ -233,7 +233,7 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface
if ($template)
{
// Lock and protect
// Lock, protect, and set as default
$db->setQuery(
$db->getQuery(true)
->update($db->quoteName('#__extensions'))
@@ -245,6 +245,9 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface
);
$db->execute();
// Set as default site template
$this->setDefaultTemplate('mokocassiopeia', 0);
return;
}
@@ -302,6 +305,42 @@ class plgSystemMokoWaaSInstallerScript implements InstallerScriptInterface
}
}
/**
* Set a template as the default for a given client.
*
* @param string $template Template element name
* @param int $clientId 0 = site, 1 = admin
*
* @return void
*
* @since 02.01.01
*/
private function setDefaultTemplate($template, $clientId)
{
$db = Factory::getDbo();
// Unset all other defaults for this client
$db->setQuery(
$db->getQuery(true)
->update($db->quoteName('#__template_styles'))
->set($db->quoteName('home') . ' = 0')
->where($db->quoteName('client_id') . ' = ' . $clientId)
->where($db->quoteName('home') . ' = 1')
);
$db->execute();
// Set our template as default
$db->setQuery(
$db->getQuery(true)
->update($db->quoteName('#__template_styles'))
->set($db->quoteName('home') . ' = 1')
->where($db->quoteName('template') . ' = '
. $db->quote($template))
->where($db->quoteName('client_id') . ' = ' . $clientId)
);
$db->execute();
}
private const BLOCK_START = '; ===== BEGIN MokoWaaS Overrides (do not edit this block) =====';
/** Sentinel comment that marks the end of MokoWaaS overrides inside a Joomla override file. */