butterfly/setup.php
Claude f15af72244 Build VIP: variante sem validação de licença Mindplace
Remove as duas camadas do kill switch (KB-PLUGIN-013) para distribuição
direta a contas estratégicas, fora do catálogo Mindplace:

- plugin_butterfly_load_license() removida;
- plugin_init_butterfly() inicializa sempre, sem checar licença;
- plugin_butterfly_check_config() retorna true incondicionalmente.

Versão marcada como 2.3.1-vip para o suporte identificar o build.
Único arquivo divergente do main é o setup.php — correções de produto
devem ser feitas no main e trazidas com `git merge main`.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-31 13:19:51 -03:00

125 lines
4.2 KiB
PHP

<?php
/**
* BUILD VIP — variante sem validação de licença Mindplace.
*
* Distribuída diretamente a contas estratégicas, fora do catálogo Mindplace.
* Difere do build padrão (branch main) APENAS pela ausência do kill switch:
* qualquer outra correção deve ser feita no main e trazida com `git merge main`.
* O sufixo -vip na versão existe para o suporte identificar o build instalado.
*/
define('PLUGIN_BUTTERFLY_VERSION', '2.3.1-vip');
// Minimal GLPI version, inclusive
define("PLUGIN_BUTTERFLY_MIN_GLPI_VERSION", "11.0.0");
// Maximum GLPI version, exclusive
define("PLUGIN_BUTTERFLY_MAX_GLPI_VERSION", "11.0.99");
$folder = basename(__DIR__);
if (strtolower($folder) !== "butterfly") {
$msg = sprintf("Please, rename the plugin folder \"%s\" to \"butterfly\"", $folder);
Session::addMessageAfterRedirect($msg, true, ERROR);
}
// Init the hooks of the plugins -Needed
function plugin_init_butterfly()
{
global $PLUGIN_HOOKS, $CFG_GLPI;
$PLUGIN_HOOKS['csrf_compliant']['butterfly'] = true;
// Register firewall strategies for legacy scripts even before installation
if (class_exists(\Glpi\Http\Firewall::class)) {
\Glpi\Http\Firewall::addPluginStrategyForLegacyScripts(
'butterfly',
'#^/front/picture\.send\.php$#',
\Glpi\Http\Firewall::STRATEGY_NO_CHECK
);
\Glpi\Http\Firewall::addPluginStrategyForLegacyScripts(
'butterfly',
'#^/front/internal\.css\.php$#',
\Glpi\Http\Firewall::STRATEGY_NO_CHECK
);
\Glpi\Http\Firewall::addPluginStrategyForLegacyScripts(
'butterfly',
'#^/front/internal\.js\.php$#',
\Glpi\Http\Firewall::STRATEGY_NO_CHECK
);
}
// Build VIP: sem kill switch de licença — o plugin inicializa sempre,
// independente da presença do Mindplace.
$plugin = new Plugin();
if ($plugin->isInstalled('butterfly') && $plugin->isActivated('butterfly')) {
$autoload = __DIR__ . '/vendor/autoload.php';
if (file_exists($autoload)) {
include_once $autoload;
}
;
// Sem barra invertida inicial: isPluginItemType() rejeita '\GlpiPlugin\...'
// e registerClass retornaria false silenciosamente (::class nunca tem o \)
Plugin::registerClass(\GlpiPlugin\Butterfly\Config::class, [
'addtabon' => ['Config']
]);
// Register config page only when installed & activated
$PLUGIN_HOOKS['config_page']['butterfly'] = '../../front/config.form.php?itemtype=Config&glpi_tab=' . rawurlencode('GlpiPlugin\Butterfly\Config') . '$1';
$PLUGIN_HOOKS['display_login']['butterfly'] = "plugin_butterfly_display_login";
// GLPI 11 appends ?v=<plugin files version> itself; the endpoints
// handle config-change cache busting via their own timestamp redirect
$PLUGIN_HOOKS["add_css"]['butterfly'] = 'front/internal.css.php';
$PLUGIN_HOOKS["add_javascript"]['butterfly'] = 'front/internal.js.php';
$CFG_GLPI['javascript']['config']['config'][] = 'tinymce';
$CFG_GLPI['javascript']['config']['config'][] = 'monaco';
}
}
// Get the name and the version of the plugin - Needed
function plugin_version_butterfly()
{
return [
'name' => t_butterfly('Butterfly'),
'version' => PLUGIN_BUTTERFLY_VERSION,
'author' => 'Rodolpho Lopes',
'homepage' => 'https://github.com/rodolpholopes',
'license' => 'GPL v2+',
'minGlpiVersion' => PLUGIN_BUTTERFLY_MIN_GLPI_VERSION,
'requirements' => [
'glpi' => [
'min' => PLUGIN_BUTTERFLY_MIN_GLPI_VERSION,
'max' => PLUGIN_BUTTERFLY_MAX_GLPI_VERSION,
]
]
];
}
// Optional : check prerequisites before install : may print errors or add to message after redirect
function plugin_butterfly_check_prerequisites()
{
if (version_compare(GLPI_VERSION, PLUGIN_BUTTERFLY_MIN_GLPI_VERSION, 'lt')) {
echo "This plugin requires GLPI >= " . PLUGIN_BUTTERFLY_MIN_GLPI_VERSION;
return false;
} else {
return true;
}
}
function plugin_butterfly_check_config($verbose = false)
{
// Build VIP: sem validação de licença — ativa em qualquer instalação.
return true;
}
function t_butterfly($str)
{
return __($str, 'butterfly');
}