2026-05-23 17:10:17 -05:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
2026-05-30 19:03:10 -05:00
|
|
|
* @package MokoJoomOpenGraph
|
2026-05-23 17:10:17 -05:00
|
|
|
* @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
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
|
|
|
|
|
|
use Joomla\CMS\Factory;
|
|
|
|
|
use Joomla\CMS\Installer\InstallerAdapter;
|
|
|
|
|
use Joomla\CMS\Language\Text;
|
|
|
|
|
|
|
|
|
|
class Pkg_MokoOGInstallerScript
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Minimum Joomla version required
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $minimumJoomla = '4.0.0';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Minimum PHP version required
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $minimumPhp = '8.1.0';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called before any install/update/uninstall action.
|
|
|
|
|
*
|
|
|
|
|
* @param string $type Action type (install, update, uninstall)
|
|
|
|
|
* @param InstallerAdapter $parent Installer adapter
|
|
|
|
|
*
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
|
|
|
|
public function preflight(string $type, InstallerAdapter $parent): bool
|
|
|
|
|
{
|
|
|
|
|
if (version_compare(PHP_VERSION, $this->minimumPhp, '<')) {
|
|
|
|
|
Factory::getApplication()->enqueueMessage(
|
|
|
|
|
Text::sprintf('PKG_MOKOOG_PHP_VERSION_ERROR', $this->minimumPhp),
|
|
|
|
|
'error'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called after install/update.
|
|
|
|
|
*
|
|
|
|
|
* @param string $type Action type
|
|
|
|
|
* @param InstallerAdapter $parent Installer adapter
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function postflight(string $type, InstallerAdapter $parent): void
|
|
|
|
|
{
|
|
|
|
|
if ($type === 'install') {
|
|
|
|
|
// Enable the system plugin automatically on fresh install
|
|
|
|
|
$db = Factory::getDbo();
|
|
|
|
|
$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('mokoog'));
|
|
|
|
|
|
|
|
|
|
$db->setQuery($query);
|
|
|
|
|
$db->execute();
|
2026-05-23 22:43:18 -05:00
|
|
|
|
2026-05-23 23:22:02 -05:00
|
|
|
// Enable the content plugin automatically
|
|
|
|
|
$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('content'))
|
|
|
|
|
->where($db->quoteName('element') . ' = ' . $db->quote('mokoog'));
|
|
|
|
|
|
|
|
|
|
$db->setQuery($query);
|
|
|
|
|
$db->execute();
|
|
|
|
|
|
2026-05-23 22:43:18 -05:00
|
|
|
// Enable the webservices plugin automatically
|
|
|
|
|
$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('webservices'))
|
|
|
|
|
->where($db->quoteName('element') . ' = ' . $db->quote('mokoog'));
|
|
|
|
|
|
|
|
|
|
$db->setQuery($query);
|
|
|
|
|
$db->execute();
|
2026-05-23 17:10:17 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|