ITSM-NG features a powerful and flexible plugin system that allows you to extend the core functionality without modifying the base code. The plugin architecture is based on the Cacti plugin system and provides hooks, events, and registration mechanisms for seamless integration.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/itsmng/itsm-ng/llms.txt
Use this file to discover all available pages before exploring further.
Plugin Architecture
The ITSM-NG plugin system is built around several core concepts:Plugin States
Plugins can exist in multiple states throughout their lifecycle:| State | Constant | Description |
|---|---|---|
| Unknown | UNKNOWN (-1) | Plugin state cannot be determined |
| New | ANEW (0) | Plugin discovered but not installed |
| Activated | ACTIVATED (1) | Plugin is installed and enabled |
| Not Installed | NOTINSTALLED (2) | Plugin is not installed |
| To Be Configured | TOBECONFIGURED (3) | Plugin installed but requires configuration |
| Not Activated | NOTACTIVATED (4) | Plugin installed but not enabled |
| To Be Cleaned | TOBECLEANED (5) | Plugin directory missing, needs cleanup |
| Not Updated | NOTUPDATED (6) | Plugin version mismatch, update required |
inc/plugin.class.php:46-87
Plugin Directory Structure
A typical plugin follows this structure:Core Plugin Files
setup.php
Thesetup.php file is the entry point for your plugin. It must contain:
plugin_version_myplugin()- Returns plugin metadataplugin_init_myplugin()- Initializes the plugin when loadedplugin_myplugin_install()- Installs the plugin (creates tables, etc.)plugin_myplugin_uninstall()- Uninstalls the plugin (removes data)
inc/plugin.class.php:228-260
hook.php (Optional)
Thehook.php file contains implementations of various hooks that the plugin responds to. This file is included when hooks need to be executed.
Source: inc/plugin.class.php:1628-1636
Plugin Capabilities
Registering Custom Item Types
Plugins can register custom item types usingPlugin::registerClass():
document_types- Allow documents to be attachedticket_types- Allow tickets to be created for this typenetworkport_types- Allow network portsaddtabon- Add tabs to specified item typesforwardentityfrom- Inherit entity from another item type
inc/plugin.class.php:1307-1372
Hook System
Plugins can respond to various hooks throughout ITSM-NG:post_init- After all plugins are initializedpost_plugin_install- After plugin installationpost_plugin_uninstall- After plugin uninstallationpost_plugin_enable- After plugin activationpost_plugin_disable- After plugin deactivationpost_plugin_clean- After plugin cleanup
inc/plugin.class.php:1383-1427
Adding Search Options
Plugins can add custom search fields to existing item types:inc/plugin.class.php:1650-1680
Database Relations
Define foreign key relationships for your plugin:inc/plugin.class.php:1583-1595
Custom Dropdowns
Register custom dropdown tables:inc/plugin.class.php:1497-1508
Plugin Requirements
Version Requirements
Plugins can specify version requirements inplugin_version_myplugin():
inc/plugin.class.php:1793-1824
CSRF Compliance
All plugins must be CSRF compliant to be activated:inc/plugin.class.php:803-813
Plugin Lifecycle
Initialization Flow
- Discovery - ITSM-NG scans the plugins directory
- Registration - Plugin information is stored in the database
- Installation -
plugin_myplugin_install()is called - Configuration -
plugin_myplugin_check_config()validates setup - Activation -
plugin_myplugin_check_prerequisites()is verified - Loading -
plugin_init_myplugin()initializes the plugin
inc/plugin.class.php:177-216
State Transitions
Plugin Directories
Plugins can be located in multiple directories defined byPLUGINS_DIRECTORIES. The system searches these locations in order when loading plugins.
Source: inc/plugin.class.php:233-259
Localization
Plugins support internationalization through.mo files in the locales/ directory:
- Place translation files in
locales/en_GB.mo,locales/fr_FR.mo, etc. - Translations are automatically loaded when the plugin initializes
- Use standard gettext functions for translation
inc/plugin.class.php:288-378
Best Practices
- Always check prerequisites - Implement
plugin_myplugin_check_prerequisites() - Validate configuration - Use
plugin_myplugin_check_config()for required settings - Clean up on uninstall - Implement proper
plugin_myplugin_uninstall() - Use namespaces - Prefix all classes, functions, and tables with your plugin name
- CSRF compliance - Always set
csrf_complianthook to true - Version requirements - Specify clear GLPI and PHP version requirements
- Database migrations - Handle version updates in your install function
Next Steps
- Installing Plugins - Learn how to install and manage plugins
- Developing Custom Plugins - Create your own ITSM-NG plugins