From 91ab7012979f56dfae067115f0453c9bb5c8d58b Mon Sep 17 00:00:00 2001
From: Jonathan Miller <1+jmiller@noreply.git.mokoconsulting.tech>
Date: Sun, 28 Jun 2026 19:03:11 +0000
Subject: [PATCH] feat: add license key warning on install/update
---
source/script.php | 70 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)
create mode 100644 source/script.php
diff --git a/source/script.php b/source/script.php
new file mode 100644
index 0000000..0701e72
--- /dev/null
+++ b/source/script.php
@@ -0,0 +1,70 @@
+warnMissingLicenseKey();
+ }
+
+ private function warnMissingLicenseKey(): void
+ {
+ try
+ {
+ $db = Factory::getDbo();
+ $app = Factory::getApplication();
+
+ $query = $db->getQuery(true)
+ ->select([$db->quoteName('update_site_id'), $db->quoteName('extra_query')])
+ ->from($db->quoteName('#__update_sites'))
+ ->where('(' . $db->quoteName('name') . ' LIKE ' . $db->quote('%MokoSuiteSupport%')
+ . ' OR ' . $db->quoteName('location') . ' LIKE ' . $db->quote('%MokoSuiteSupport%') . ')')
+ ->setLimit(1);
+ $db->setQuery($query);
+ $site = $db->loadObject();
+
+ if ($site)
+ {
+ $extraQuery = (string) ($site->extra_query ?? '');
+
+ if (!empty($extraQuery) && strpos($extraQuery, 'dlid=') !== false)
+ {
+ parse_str($extraQuery, $parsed);
+
+ if (!empty($parsed['dlid']))
+ {
+ return;
+ }
+ }
+
+ $editUrl = 'index.php?option=com_installer&task=updatesite.edit&update_site_id=' . (int) $site->update_site_id;
+ }
+ else
+ {
+ $editUrl = 'index.php?option=com_installer&view=updatesites';
+ }
+
+ $app->enqueueMessage(
+ 'Moko Consulting License Key Required — '
+ . 'No download key is configured. Updates will not be available until a valid license key is entered. '
+ . 'Enter License Key',
+ 'warning'
+ );
+ }
+ catch (\Throwable $e)
+ {
+ }
+ }
+}