2026-06-03 21:19:18 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @package MokoJoomHero
|
|
|
|
|
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
|
|
|
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
|
|
|
* @license GNU General Public License version 3 or later; see LICENSE
|
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
|
|
|
|
|
|
use Joomla\CMS\Factory;
|
|
|
|
|
use Joomla\CMS\Installer\InstallerAdapter;
|
|
|
|
|
|
|
|
|
|
class Pkg_MokoJoomHeroInstallerScript
|
|
|
|
|
{
|
|
|
|
|
/**
|
2026-06-04 06:46:47 -05:00
|
|
|
* Called after install/update — only enables the system plugin on fresh install.
|
2026-06-03 21:19:18 -05:00
|
|
|
*
|
|
|
|
|
* @param string $type Action type
|
|
|
|
|
* @param InstallerAdapter $parent Installer adapter
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function postflight(string $type, InstallerAdapter $parent): void
|
|
|
|
|
{
|
|
|
|
|
if ($type === 'install') {
|
2026-06-04 06:46:47 -05:00
|
|
|
try {
|
|
|
|
|
$db = Factory::getDbo();
|
2026-06-03 21:19:18 -05:00
|
|
|
|
2026-06-04 06:46:47 -05:00
|
|
|
// Enable the system plugin automatically on fresh install
|
|
|
|
|
$query = $db->getQuery(true)
|
|
|
|
|
->update($db->quoteName('#__extensions'))
|
|
|
|
|
->set($db->quoteName('enabled') . ' = 1')
|
|
|
|
|
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
|
|
|
|
|
->where($db->quoteName('folder') . ' = ' . $db->quote('system'))
|
|
|
|
|
->where($db->quoteName('element') . ' = ' . $db->quote('mokojoomhero'));
|
2026-06-03 21:19:18 -05:00
|
|
|
|
2026-06-04 06:46:47 -05:00
|
|
|
$db->setQuery($query);
|
|
|
|
|
$db->execute();
|
|
|
|
|
|
|
|
|
|
if ($db->getAffectedRows() === 0) {
|
|
|
|
|
Factory::getApplication()->enqueueMessage(
|
|
|
|
|
'MokoJoomHero: The system plugin could not be auto-enabled. '
|
|
|
|
|
. 'Please enable it manually in Extensions → Plugins.',
|
|
|
|
|
'warning'
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
Factory::getApplication()->enqueueMessage(
|
|
|
|
|
'MokoJoomHero: Failed to auto-enable system plugin: ' . $e->getMessage()
|
|
|
|
|
. ' — Please enable it manually in Extensions → Plugins.',
|
|
|
|
|
'warning'
|
|
|
|
|
);
|
|
|
|
|
}
|
2026-06-03 21:19:18 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|