v2.2.0: ícone na aba de config e kill switch de licença Mindplace
- Aba em Configuração > Geral agora usa createTabEntry com ícone ti ti-butterfly (Tabler v3.34 do core). - Kill switch de licença nas duas camadas do padrão KB-PLUGIN-013: check_config impede ativação sem licença Mindtek válida e plugin_init aborta silenciosamente (mesmo padrão do plugin redmine). - Gotcha operacional: mudar PLUGIN_BUTTERFLY_VERSION desativa o plugin até rodar glpi:plugin:install de novo (checkPluginState). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
020558f14f
commit
9ca8ea616b
2 changed files with 40 additions and 3 deletions
41
setup.php
41
setup.php
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
define('PLUGIN_BUTTERFLY_VERSION', '2.1.0');
|
||||
define('PLUGIN_BUTTERFLY_VERSION', '2.2.0');
|
||||
|
||||
// Minimal GLPI version, inclusive
|
||||
define("PLUGIN_BUTTERFLY_MIN_GLPI_VERSION", "11.0.0");
|
||||
|
|
@ -16,6 +16,26 @@ if (strtolower($folder) !== "butterfly") {
|
|||
Session::addMessageAfterRedirect($msg, true, ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
* Carrega a classe License do Mindplace caso o autoload ainda não tenha rodado.
|
||||
* Necessário porque o plugin pode inicializar antes do mindplace (KB-PLUGIN-013).
|
||||
*/
|
||||
function plugin_butterfly_load_license()
|
||||
{
|
||||
if (class_exists('\GlpiPlugin\Mindplace\License')) {
|
||||
return;
|
||||
}
|
||||
foreach ([
|
||||
GLPI_ROOT . '/plugins/mindplace/src/License.php',
|
||||
GLPI_ROOT . '/marketplace/mindplace/src/License.php',
|
||||
] as $path) {
|
||||
if (file_exists($path)) {
|
||||
include_once $path;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Init the hooks of the plugins -Needed
|
||||
function plugin_init_butterfly()
|
||||
{
|
||||
|
|
@ -41,6 +61,15 @@ function plugin_init_butterfly()
|
|||
);
|
||||
}
|
||||
|
||||
// ──────────────────────────────────────────────────────────────────
|
||||
// KILL SWITCH — aborta silenciosamente se a licença Mindtek for inválida
|
||||
// (KB-PLUGIN-013; camada 2 — a camada 1 é o check_config)
|
||||
// ──────────────────────────────────────────────────────────────────
|
||||
plugin_butterfly_load_license();
|
||||
if (!class_exists('\GlpiPlugin\Mindplace\License') || !\GlpiPlugin\Mindplace\License::isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$plugin = new Plugin();
|
||||
|
||||
if ($plugin->isInstalled('butterfly') && $plugin->isActivated('butterfly')) {
|
||||
|
|
@ -102,8 +131,16 @@ function plugin_butterfly_check_prerequisites()
|
|||
}
|
||||
}
|
||||
|
||||
function plugin_butterfly_check_config()
|
||||
function plugin_butterfly_check_config($verbose = false)
|
||||
{
|
||||
plugin_butterfly_load_license();
|
||||
|
||||
if (!class_exists('\GlpiPlugin\Mindplace\License') || !\GlpiPlugin\Mindplace\License::isValid()) {
|
||||
if ($verbose && !isCommandLine()) {
|
||||
echo "<div class='alert alert-danger'>Licença Mindtek inativa ou Mind Place ausente. O plugin foi desativado por segurança.</div>";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class Config extends \CommonDBTM {
|
|||
function getTabNameForItem(\CommonGLPI $item, $withtemplate = 0) {
|
||||
switch (get_class($item)) {
|
||||
case 'Config':
|
||||
return [1 => t_butterfly('Butterfly')];
|
||||
return [1 => self::createTabEntry(t_butterfly('Butterfly'), 0, null, 'ti ti-butterfly')];
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue