fix: replace showUpdateSiteNotice with warnMissingLicenseKey (MokoWaaS pattern)
This commit is contained in:
+30
-41
@@ -203,8 +203,8 @@ class Pkg_MokoJoomBackupInstallerScript
|
||||
}
|
||||
}
|
||||
|
||||
// Show update site link after install or update
|
||||
$this->showUpdateSiteNotice();
|
||||
// Warn if no license key configured
|
||||
$this->warnMissingLicenseKey();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -246,49 +246,38 @@ class Pkg_MokoJoomBackupInstallerScript
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show an info message linking directly to the update site record
|
||||
* so the user can configure their download key.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function showUpdateSiteNotice(): void
|
||||
private function warnMissingLicenseKey(): void
|
||||
{
|
||||
try {
|
||||
try
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$db->setQuery(
|
||||
$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('%MokoJoomBackup%') . ' OR ' . $db->quoteName('location') . ' LIKE ' . $db->quote('%MokoJoomBackup%') . ')')
|
||||
->setLimit(1)
|
||||
);
|
||||
$site = $db->loadObject();
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select($db->quoteName('us.update_site_id'))
|
||||
->from($db->quoteName('#__update_sites', 'us'))
|
||||
->join(
|
||||
'INNER',
|
||||
$db->quoteName('#__update_sites_extensions', 'use')
|
||||
. ' ON ' . $db->quoteName('use.update_site_id') . ' = ' . $db->quoteName('us.update_site_id')
|
||||
)
|
||||
->join(
|
||||
'INNER',
|
||||
$db->quoteName('#__extensions', 'e')
|
||||
. ' ON ' . $db->quoteName('e.extension_id') . ' = ' . $db->quoteName('use.extension_id')
|
||||
)
|
||||
->where($db->quoteName('e.element') . ' = ' . $db->quote('pkg_mokojoombackup'))
|
||||
->where($db->quoteName('e.type') . ' = ' . $db->quote('package'))
|
||||
->setLimit(1);
|
||||
|
||||
$db->setQuery($query);
|
||||
$updateSiteId = (int) $db->loadResult();
|
||||
|
||||
if ($updateSiteId > 0) {
|
||||
$editUrl = Route::_(
|
||||
'index.php?option=com_installer&view=updatesites&filter[search]=mokojoombackup'
|
||||
);
|
||||
|
||||
Factory::getApplication()->enqueueMessage(
|
||||
Text::sprintf('PKG_MOKOJOOMBACKUP_POSTINSTALL_UPDATE_SITE', $editUrl),
|
||||
'info'
|
||||
);
|
||||
if ($site)
|
||||
{
|
||||
$eq = (string) ($site->extra_query ?? '');
|
||||
if (!empty($eq) && strpos($eq, 'dlid=') !== false) { parse_str($eq, $p); if (!empty($p['dlid'])) { return; } }
|
||||
$editUrl = 'index.php?option=com_installer&task=updatesite.edit&update_site_id=' . (int) $site->update_site_id;
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
// Non-critical — silently ignore
|
||||
else
|
||||
{
|
||||
$editUrl = 'index.php?option=com_installer&view=updatesites';
|
||||
}
|
||||
|
||||
Factory::getApplication()->enqueueMessage(
|
||||
'<strong>Moko Consulting License Key Required</strong> — '
|
||||
. 'No download key is configured. Updates will not be available until a valid license key is entered. '
|
||||
. '<a href="' . $editUrl . '" class="btn btn-sm btn-warning ms-2">Enter License Key</a>',
|
||||
'warning'
|
||||
);
|
||||
}
|
||||
catch (\Throwable $e) {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user