gestione assets
This commit is contained in:
@@ -2,20 +2,30 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
// Force OPcache to reload this file when accessed via web
|
||||
// Force OPcache to reload plugin files when accessed via web
|
||||
if (PHP_SAPI !== 'cli' && function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate(__FILE__, true);
|
||||
$capacity_file = __DIR__ . '/src/Capacity/UrBackupCapacity.php';
|
||||
if (file_exists($capacity_file)) {
|
||||
opcache_invalidate($capacity_file, true);
|
||||
}
|
||||
$asset_tab_file = __DIR__ . '/src/AssetTab.php';
|
||||
if (file_exists($asset_tab_file)) {
|
||||
opcache_invalidate($asset_tab_file, true);
|
||||
}
|
||||
}
|
||||
|
||||
use Glpi\Asset\AssetDefinitionManager;
|
||||
use Glpi\Plugin\Hooks;
|
||||
use GlpiPlugin\Urbackup\AssetTab;
|
||||
use GlpiPlugin\Urbackup\Capacity\UrBackupCapacity;
|
||||
use GlpiPlugin\Urbackup\Config;
|
||||
use GlpiPlugin\Urbackup\Profile;
|
||||
use GlpiPlugin\Urbackup\Server;
|
||||
use GlpiPlugin\Urbackup\ServerAsset;
|
||||
use GlpiPlugin\Urbackup\MassiveAction as PluginUrbackupMassiveAction;
|
||||
|
||||
define('PLUGIN_URBACKUP_VERSION', '0.4.2');
|
||||
define('PLUGIN_URBACKUP_VERSION', '0.5.0');
|
||||
define('PLUGIN_URBACKUP_MIN_GLPI', '11.0.0');
|
||||
define('PLUGIN_URBACKUP_MAX_GLPI', '11.99.99');
|
||||
|
||||
@@ -52,12 +62,19 @@ function plugin_init_urbackup(): void
|
||||
Plugin::registerClass(ServerAsset::class);
|
||||
Plugin::registerClass(PluginUrbackupMassiveAction::class);
|
||||
|
||||
// Register tab on Computer and other assets
|
||||
$enabled_types = Config::getEnabledItemtypes();
|
||||
if (!empty($enabled_types)) {
|
||||
Plugin::registerClass(AssetTab::class, [
|
||||
'addtabon' => $enabled_types,
|
||||
]);
|
||||
// Register tab on Computer (legacy, always enabled)
|
||||
Plugin::registerClass(AssetTab::class, [
|
||||
'addtabon' => ['Computer'],
|
||||
]);
|
||||
|
||||
// Register UrBackupCapacity for GLPI 11 Asset Definition types.
|
||||
// Tab registration happens inside `UrBackupCapacity::onClassBootstrap()`
|
||||
// which is called by `bootDefinitions()` during kernel PostBoot event.
|
||||
// This ensures tabs are registered on all definitions that have the
|
||||
// UrBackup capacity enabled, even if they are created after plugin init.
|
||||
if (class_exists(AssetDefinitionManager::class)) {
|
||||
$manager = AssetDefinitionManager::getInstance();
|
||||
$manager->registerCapacity(new UrBackupCapacity());
|
||||
}
|
||||
|
||||
$PLUGIN_HOOKS['config_page']['urbackup'] = 'front/config.form.php';
|
||||
@@ -75,18 +92,6 @@ function plugin_init_urbackup(): void
|
||||
$PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT]['urbackup'] = [
|
||||
'public/js/urbackup.js',
|
||||
];
|
||||
|
||||
$PLUGIN_HOOKS[Hooks::POST_INIT]['urbackup'] = 'plugin_urbackup_postinit';
|
||||
}
|
||||
|
||||
/**
|
||||
* Post init hook.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function plugin_urbackup_postinit(): void
|
||||
{
|
||||
Config::registerAssetTabs();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user