2026-05-30 15:22:24 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @package Joomla.Site
|
|
|
|
|
* @subpackage mod_mokojoomhero
|
|
|
|
|
*
|
|
|
|
|
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
|
|
|
* @license GPL-3.0-or-later
|
2026-06-04 06:46:47 -05:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2026-05-30 15:22:24 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
|
|
2026-06-04 13:09:27 -05:00
|
|
|
use Joomla\CMS\Factory;
|
2026-05-30 15:22:24 -05:00
|
|
|
use Joomla\CMS\Filesystem\Folder;
|
|
|
|
|
use Joomla\CMS\Installer\InstallerAdapter;
|
|
|
|
|
|
|
|
|
|
class Mod_MokojoomheroInstallerScript
|
|
|
|
|
{
|
2026-06-04 13:09:27 -05:00
|
|
|
public function postflight(string $type, InstallerAdapter $adapter): void
|
|
|
|
|
{
|
|
|
|
|
// Create default image folder on fresh install
|
|
|
|
|
$heroesPath = JPATH_ROOT . '/images/heroes';
|
|
|
|
|
|
|
|
|
|
if (!is_dir($heroesPath)) {
|
|
|
|
|
Folder::create($heroesPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove deprecated system plugin (was part of the old package extension)
|
|
|
|
|
$this->removeDeprecatedPlugin();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Uninstall plg_system_mokojoomhero if it exists — no longer needed.
|
|
|
|
|
*/
|
|
|
|
|
private function removeDeprecatedPlugin(): void
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$db = Factory::getDbo();
|
|
|
|
|
|
|
|
|
|
$query = $db->getQuery(true)
|
|
|
|
|
->select($db->quoteName('extension_id'))
|
|
|
|
|
->from($db->quoteName('#__extensions'))
|
|
|
|
|
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'))
|
|
|
|
|
->where($db->quoteName('folder') . ' = ' . $db->quote('system'))
|
|
|
|
|
->where($db->quoteName('element') . ' = ' . $db->quote('mokojoomhero'));
|
|
|
|
|
$db->setQuery($query);
|
|
|
|
|
$extensionId = (int) $db->loadResult();
|
|
|
|
|
|
|
|
|
|
if ($extensionId) {
|
|
|
|
|
$installer = new \Joomla\CMS\Installer\Installer();
|
|
|
|
|
$installer->uninstall('plugin', $extensionId);
|
|
|
|
|
}
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
|
// Non-critical — plugin may already be gone
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-05-30 15:22:24 -05:00
|
|
|
}
|