99871a2ff6
Generic: Project CI / Tests (push) Blocked by required conditions
Generic: Repo Health / Scripts governance (push) Blocked by required conditions
Generic: Repo Health / Repository health (push) Blocked by required conditions
Generic: Repo Health / Report Issues (push) Blocked by required conditions
Generic: Repo Health / Site Health (push) Has been skipped
Generic: Repo Health / Access control (push) Successful in 1s
Universal: Auto Version Bump / Version Bump (push) Successful in 7s
Generic: Project CI / Lint & Validate (push) Successful in 12s
4 sub-extensions: com, system plugin, webservices, content plugin. 4 DB tables: forms, fields, submissions, notifications.
57 lines
1.8 KiB
PHP
57 lines
1.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
* @license GPL-3.0-or-later
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Joomla\CMS\Installer\InstallerAdapter;
|
|
use Joomla\CMS\Language\Text;
|
|
use Joomla\CMS\Log\Log;
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
class Pkg_MokoSuiteFormsInstallerScript
|
|
{
|
|
protected string $minimumPhp = '8.1';
|
|
protected string $minimumJoomla = '5.0.0';
|
|
|
|
public function preflight(string $type, InstallerAdapter $adapter): bool
|
|
{
|
|
if (version_compare(PHP_VERSION, $this->minimumPhp, '<')) {
|
|
Log::add(
|
|
sprintf('MokoSuiteForms requires PHP %s or later. You are running PHP %s.', $this->minimumPhp, PHP_VERSION),
|
|
Log::WARNING,
|
|
'jerror'
|
|
);
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public function postflight(string $type, InstallerAdapter $adapter): void
|
|
{
|
|
if ($type === 'install') {
|
|
// Enable plugins after first install
|
|
$this->enablePlugin('system', 'mokosuiteforms');
|
|
$this->enablePlugin('webservices', 'mokosuiteforms');
|
|
$this->enablePlugin('content', 'mokosuiteforms');
|
|
}
|
|
}
|
|
|
|
private function enablePlugin(string $group, string $element): void
|
|
{
|
|
$db = \Joomla\CMS\Factory::getContainer()->get(\Joomla\Database\DatabaseInterface::class);
|
|
$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($group))
|
|
->where($db->quoteName('element') . ' = ' . $db->quote($element));
|
|
$db->setQuery($query)->execute();
|
|
}
|
|
}
|