Plugin Development with OPM Packages
Plugin Development with OPM Packages
Section titled “Plugin Development with OPM Packages”In this section, you will learn how to create, install, and distribute your own plugins as OPM packages for Znuny.
Section titled “In this section, you will learn how to create, install, and distribute your own plugins as OPM packages for Znuny.”1. Structure of a .sopm
Section titled “1. Structure of a .sopm”The SOPM file (*.sopm) contains all metadata for your package:
`.sopm“
- Name/Version/Framework: Unique package identifier and compatible Znuny version.
- Filelist: All files that are copied during installation.
2. Files & Directory Structure
Section titled “2. Files & Directory Structure”Create your package in its own directory, e.g., MyExtension/:
*.sopm
- Kernel/Config/Files/XML/: Registers modules, menus, or Dynamic Fields.
- Kernel/System/: Business logic class.
- Kernel/Modules/: Frontend controller.
- Templates & Language: TT files + translation .pm.
3. Build & Install Package
Section titled “3. Build & Install Package”3.1 Create OPM
Section titled “3.1 Create OPM”Use the CLI tool to build an OPM from your SOPM:
MyExtension/
3.2 Installation
Section titled “3.2 Installation”Admin UI: Upload package under Admin → Settings → Package Manager.
Console:
Kernel/Config/Files/XML/MyExtension.xml
To uninstall or update:
Kernel/System/DynamicField/Driver/MyCustomField.pm
Section titled “Admin UI: Upload package under Admin → Settings → Package Manager.
Console:
Kernel/Config/Files/XML/MyExtension.xml
To uninstall or update:
Kernel/System/DynamicField/Driver/MyCustomField.pm”4. Extension Points
Section titled “4. Extension Points”4.1 Dynamic Fields
Section titled “4.1 Dynamic Fields”In Kernel/Config/Files/XML/MyExtension.xml, you register a new Dynamic Field Driver:
Kernel/System/Event/Handler/MyHandler.pm
Implement the driver in Kernel/System/DynamicField/Driver/MyCustomField.pm.
4.2 Event Handler
Section titled “4.2 Event Handler”Register your event handler:
Run()
Implement the handler in Kernel/System/Event/Handler/MyHandler.pm (Run() method).
4.3 Output Filter
Section titled “4.3 Output Filter”Kernel/System/Output/Filter/MyFilter.pm
Implement the filter in Kernel/System/Output/Filter/MyFilter.pm.
Section titled “Kernel/System/Output/Filter/MyFilter.pm
Implement the filter in Kernel/System/Output/Filter/MyFilter.pm.”5. Deployment & OTOpar
Section titled “5. Deployment & OTOpar”- Repository Index: Create
Packages.xmlfor your own repo:Packages.xml - Add your repo URL under SysConfig
Package::RepositoryList. - OTOpar: Upload your OPM to https://otopar.perl-services.de so that others can install it directly.
6. Example: MyCalendar Package
Section titled “6. Example: MyCalendar Package”- Create SOPM with the name
MyCalendar. - DB script
sql/create_calendar.sqlfor tablecalendar_events. - Config XML defines new ticket field “Appointment”.
- Core module
Kernel/System/CalendarEvent.pmwith CRUD methods. - Frontend modules
Kernel/Modules/AgentCalendar.pm, templateAgentCalendar.tt. - Build package and upload to OTOpar.
7. Tips & Best Practices
Section titled “7. Tips & Best Practices”- Adjust version number in the
sopm(SemVer). - Version DB migrations in
sql/cleanly. - Create unit tests for system and module classes.
- Documentation in README plus POD in Perl modules.
- Translations in
Language/de_*.pmanden_*.pm. With this, you have a solid foundation to develop, distribute, and maintain your own Znuny plugins in customer projects. Have fun!